Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
f94eb2ec
Commit
f94eb2ec
authored
Nov 05, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#23
added router on creation project
parent
8ccdf527
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
9 deletions
+41
-9
Project.ts
planner-api/src/models/Project.ts
+19
-1
Task.ts
planner-api/src/models/Task.ts
+5
-5
projects.ts
planner-api/src/routers/projects.ts
+17
-3
No files found.
planner-api/src/models/Project.ts
View file @
f94eb2ec
...
...
@@ -11,6 +11,15 @@ import {
import
{
User
}
from
'./User'
;
import
{
Task
}
from
'./Task'
;
// type IncomingData={
// title: string | null;
// color: string
// admin:User
// workers?: User[]
// tasks?: Task[]
// dateDue?:Date
// department?:boolean
// }
interface
IProject
{
id
:
string
;
...
...
@@ -26,9 +35,18 @@ import {
@
Entity
({
name
:
'Project'
})
export
class
Project
extends
BaseEntity
implements
IProject
{
// data: IncomingData;
// constructor(data:IncomingData){
// super();
// this.data = data
// }
@
PrimaryGeneratedColumn
(
'uuid'
)
id
!
:
string
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
100
,
nullable
:
false
})
// @Column({ name: 'title', type: 'varchar', length:100,nullable: false, default: this.data.title })
// title!: string
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
100
,
nullable
:
false
})
title
!
:
string
@
CreateDateColumn
({
name
:
'createdAt'
,
type
:
Date
,
default
:
new
Date
()
})
...
...
planner-api/src/models/Task.ts
View file @
f94eb2ec
...
...
@@ -15,8 +15,8 @@ import {
interface
ITask
{
id
:
string
;
title
:
string
;
//
description: string;
createdAt
:
Date
|
undefined
;
description
:
string
;
createdAt
:
Date
;
// dateTimeStart:Date| null;
// dateTimeDue:Date| null;
assignedTo
:
User
[];
...
...
@@ -31,10 +31,10 @@ import {
id
!
:
string
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
50
,
nullable
:
false
})
title
!
:
string
// @Column({ name: 'description', type: 'varchar', length:50,nullable: fals
e })
//
description!: string
@
Column
({
name
:
'description'
,
type
:
'varchar'
,
length
:
50
,
nullable
:
tru
e
})
description
!
:
string
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
createdAt
:
Date
|
undefined
;
createdAt
!
:
Date
;
// @CreateDateColumn({ name: 'dateTimeStart', type: Date,nullable: true })
// dateTimeStart!: Date | null;
// @CreateDateColumn({ name: 'dateTimeDue', type: Date,nullable: true })
...
...
planner-api/src/routers/projects.ts
View file @
f94eb2ec
...
...
@@ -6,12 +6,12 @@ const router:Router = express.Router();
const
dataSource
=
myDataSource
;
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
projects
:
Project
[]
|
undefined
=
await
dataSource
.
manager
.
find
(
Project
)
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
:
Promise
<
Response
>
=>
{
const
projects
:
Project
[]
=
await
dataSource
.
manager
.
find
(
Project
)
return
res
.
send
({
projects
})
})
router
.
get
(
"/:project_id"
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
router
.
get
(
"/:project_id"
,
async
(
req
:
Request
,
res
:
Response
)
:
Promise
<
Response
>
=>
{
const
project
:
Project
|
null
=
await
dataSource
.
manager
.
findOneBy
(
Project
,
{
id
:
req
.
params
.
project_id
})
...
...
@@ -19,4 +19,18 @@ router.get("/:project_id",async (req:Request, res:Response) => {
return
res
.
send
({
project
})
})
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>
=>
{
if
(
!
req
.
body
)
return
res
.
status
(
400
).
send
({
Message
:
'problem in incoming req.body'
})
const
{
title
,
dateDue
,
department
,
admin
,
workers
,
tasks
}
=
req
.
body
const
project
:
Project
=
new
Project
()
project
.
title
=
title
;
project
.
dateDue
=
dateDue
||
null
;
project
.
department
=
department
||
null
;
project
.
workers
=
workers
||
null
;
project
.
tasks
=
tasks
||
null
;
project
.
admin
=
admin
||
null
;
await
project
.
save
()
return
res
.
send
({
project
})
})
export
default
router
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment