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
9c90a525
Commit
9c90a525
authored
Nov 05, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#25
added admin in request of one porject by id
parent
eec5934c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
22 deletions
+29
-22
Project.ts
planner-api/src/models/Project.ts
+1
-1
projects.ts
planner-api/src/routers/projects.ts
+28
-21
No files found.
planner-api/src/models/Project.ts
View file @
9c90a525
...
...
@@ -59,7 +59,7 @@ import {
dateDue
!
:
Date
|
null
;
@
Column
({
name
:
'department'
,
type
:
Boolean
,
nullable
:
true
,
default
:
false
})
department
!
:
boolean
|
false
;
department
!
:
boolean
;
@
ManyToOne
(()
=>
User
,
(
user
:
{
projects
:
Project
[];
})
=>
user
.
projects
)
admin
!
:
User
;
...
...
planner-api/src/routers/projects.ts
View file @
9c90a525
...
...
@@ -12,11 +12,18 @@ router.get('/',async (req:Request, res:Response): Promise<Response>=> {
return
res
.
send
({
projects
})
})
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
})
if
(
!
project
)
return
res
.
status
(
404
).
send
({
Message
:
'no info in the base'
})
router
.
get
(
"/project_id/:project_id"
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>
=>
{
const
project
=
await
dataSource
.
createQueryBuilder
()
.
select
(
"project"
)
.
from
(
Project
,
"project"
)
// .where("user.workerInProjects= :projects", {projects.id : req.params.project_id } )
// .innerJoinAndSelect('project.workers','user')
.
leftJoinAndSelect
(
'project.admin'
,
'user'
)
.
where
(
"project.id = :id"
,
{
id
:
req
.
params
.
project_id
})
.
getOne
()
if
(
!
project
)
return
res
.
status
(
404
).
send
({
Message
:
'no such project in the base'
})
return
res
.
send
({
project
})
})
...
...
@@ -43,21 +50,21 @@ router.post('/', async (req:Request, res:Response): Promise<Response> => {
})
//
router.get('/:userId', async (req : Request, res : Response): Promise<Response>=>{
//
const userId:string = req.params.userId
//
const user = await dataSource
//
.createQueryBuilder()
//
.select("user")
//
.from(User, "user")
//
.where("user.id = :id", { id: userId })
//
.getOne()
//
console.log('user ', user)
//
const userProjects = await dataSource
//
.createQueryBuilder()
//
.select('project')
//
.from(Project, "project")
//
.where("Project_adminId = :id", { id: userId })
//
return res.send({userProjects})
//
})
router
.
get
(
'/:userId'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
userId
:
string
=
req
.
params
.
userId
const
user
=
await
dataSource
.
createQueryBuilder
()
.
select
(
"user"
)
.
from
(
User
,
"user"
)
.
where
(
"user.id = :id"
,
{
id
:
userId
})
.
getOne
()
console
.
log
(
'user '
,
user
)
const
userProjects
=
await
dataSource
.
createQueryBuilder
()
.
select
(
'project'
)
.
from
(
Project
,
"project"
)
.
where
(
"Project_adminId = :id"
,
{
id
:
userId
})
return
res
.
send
({
userProjects
})
})
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