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
28da95c7
Commit
28da95c7
authored
Nov 17, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#51
added post tasks/project
parent
1ba82002
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
tasks.ts
planner-api/src/routers/tasks.ts
+29
-0
No files found.
planner-api/src/routers/tasks.ts
View file @
28da95c7
...
@@ -2,6 +2,7 @@ import express,{Router, Request, Response} from 'express';
...
@@ -2,6 +2,7 @@ import express,{Router, Request, Response} from 'express';
import
{
Task
}
from
'../models/Task'
;
import
{
Task
}
from
'../models/Task'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
User
}
from
'../models/User'
;
import
{
User
}
from
'../models/User'
;
import
{
Project
}
from
'../models/Project'
;
const
router
:
Router
=
express
.
Router
();
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
const
dataSource
=
myDataSource
;
...
@@ -111,4 +112,32 @@ router.put('/',async(req:Request, res:Response)=> {
...
@@ -111,4 +112,32 @@ router.put('/',async(req:Request, res:Response)=> {
})
})
router
.
post
(
'/project'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
let
projectArray
:
string
[]
=
req
.
body
;
console
.
log
(
'projectArray '
,
projectArray
)
if
(
projectArray
.
length
===
0
)
{
const
rawTasks
=
await
dataSource
.
getRepository
(
Task
)
.
find
({
relations
:{
executors
:
true
,
author
:
true
,
project
:
true
}
})
const
tasks
:
object
[]
=
rawTasks
.
filter
(
task
=>
task
.
project
===
null
)
return
res
.
send
({
tasks
})
}
const
tasks
=
await
dataSource
.
getRepository
(
Task
)
.
createQueryBuilder
(
'task'
)
.
innerJoinAndSelect
(
'task.project'
,
'project'
)
.
where
(
'task.project IN(:...projects)'
,
{
projects
:
projectArray
})
.
getMany
()
return
res
.
send
({
tasks
})
})
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