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
Show 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 {
...
@@ -11,6 +11,15 @@ import {
import
{
User
}
from
'./User'
;
import
{
User
}
from
'./User'
;
import
{
Task
}
from
'./Task'
;
import
{
Task
}
from
'./Task'
;
// type IncomingData={
// title: string | null;
// color: string
// admin:User
// workers?: User[]
// tasks?: Task[]
// dateDue?:Date
// department?:boolean
// }
interface
IProject
{
interface
IProject
{
id
:
string
;
id
:
string
;
...
@@ -26,9 +35,18 @@ import {
...
@@ -26,9 +35,18 @@ import {
@
Entity
({
name
:
'Project'
})
@
Entity
({
name
:
'Project'
})
export
class
Project
extends
BaseEntity
implements
IProject
{
export
class
Project
extends
BaseEntity
implements
IProject
{
// data: IncomingData;
// constructor(data:IncomingData){
// super();
// this.data = data
// }
@
PrimaryGeneratedColumn
(
'uuid'
)
@
PrimaryGeneratedColumn
(
'uuid'
)
id
!
:
string
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
title
!
:
string
@
CreateDateColumn
({
name
:
'createdAt'
,
type
:
Date
,
default
:
new
Date
()
})
@
CreateDateColumn
({
name
:
'createdAt'
,
type
:
Date
,
default
:
new
Date
()
})
...
...
planner-api/src/models/Task.ts
View file @
f94eb2ec
...
@@ -15,8 +15,8 @@ import {
...
@@ -15,8 +15,8 @@ import {
interface
ITask
{
interface
ITask
{
id
:
string
;
id
:
string
;
title
:
string
;
title
:
string
;
//
description: string;
description
:
string
;
createdAt
:
Date
|
undefined
;
createdAt
:
Date
;
// dateTimeStart:Date| null;
// dateTimeStart:Date| null;
// dateTimeDue:Date| null;
// dateTimeDue:Date| null;
assignedTo
:
User
[];
assignedTo
:
User
[];
...
@@ -31,10 +31,10 @@ import {
...
@@ -31,10 +31,10 @@ import {
id
!
:
string
id
!
:
string
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
50
,
nullable
:
false
})
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
50
,
nullable
:
false
})
title
!
:
string
title
!
:
string
// @Column({ name: 'description', type: 'varchar', length:50,nullable: fals
e })
@
Column
({
name
:
'description'
,
type
:
'varchar'
,
length
:
50
,
nullable
:
tru
e
})
//
description!: string
description
!
:
string
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
createdAt
:
Date
|
undefined
;
createdAt
!
:
Date
;
// @CreateDateColumn({ name: 'dateTimeStart', type: Date,nullable: true })
// @CreateDateColumn({ name: 'dateTimeStart', type: Date,nullable: true })
// dateTimeStart!: Date | null;
// dateTimeStart!: Date | null;
// @CreateDateColumn({ name: 'dateTimeDue', type: Date,nullable: true })
// @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();
...
@@ -6,12 +6,12 @@ const router:Router = express.Router();
const
dataSource
=
myDataSource
;
const
dataSource
=
myDataSource
;
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
:
Promise
<
Response
>
=>
{
const
projects
:
Project
[]
|
undefined
=
await
dataSource
.
manager
.
find
(
Project
)
const
projects
:
Project
[]
=
await
dataSource
.
manager
.
find
(
Project
)
return
res
.
send
({
projects
})
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
,
{
const
project
:
Project
|
null
=
await
dataSource
.
manager
.
findOneBy
(
Project
,
{
id
:
req
.
params
.
project_id
id
:
req
.
params
.
project_id
})
})
...
@@ -19,4 +19,18 @@ router.get("/:project_id",async (req:Request, res:Response) => {
...
@@ -19,4 +19,18 @@ router.get("/:project_id",async (req:Request, res:Response) => {
return
res
.
send
({
project
})
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
;
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