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
36e04fb1
Commit
36e04fb1
authored
Nov 14, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'task-36-fix/fix_back_put_task' into 'development'
Task 36 fix/fix back put task See merge request
!24
parents
354ab632
ec3efe63
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
35 deletions
+21
-35
Project.ts
planner-api/src/models/Project.ts
+1
-1
Task.ts
planner-api/src/models/Task.ts
+2
-5
tasks.ts
planner-api/src/routers/tasks.ts
+18
-27
users.ts
planner-api/src/routers/users.ts
+0
-2
No files found.
planner-api/src/models/Project.ts
View file @
36e04fb1
...
...
@@ -68,7 +68,7 @@ import {
@
OneToMany
(()
=>
Task
,
(
task
:
{
project
:
Project
;
})
=>
task
.
project
,{
eager
:
true
})
tasks
!
:
Task
[]
|
null
;
@
ManyToMany
(()
=>
User
,
(
user
:
{
projects
:
Project
[];
})
=>
user
.
projects
,{
eager
:
true
})
@
ManyToMany
(()
=>
User
,
(
user
:
{
projects
:
Project
[];
})
=>
user
.
projects
,{
eager
:
true
,
cascade
:
true
,
onUpdate
:
'CASCADE'
,
onDelete
:
'CASCADE'
})
@
JoinTable
()
workers
!
:
User
[];
}
\ No newline at end of file
planner-api/src/models/Task.ts
View file @
36e04fb1
...
...
@@ -25,7 +25,7 @@ import {
priority
:
priorityType
|
null
;
author
:
User
;
project
:
Project
|
null
;
executors
:
User
[]
executors
:
User
[]
;
}
@
Entity
({
name
:
'Task'
})
...
...
@@ -64,13 +64,10 @@ import {
@
ManyToOne
(()
=>
User
,
(
user
:
{
tasks
:
Task
[];
})
=>
user
.
tasks
,{
eager
:
true
})
author
!
:
User
;
@
ManyToMany
(()
=>
User
,{
eager
:
true
})
@
ManyToMany
(()
=>
User
,{
eager
:
true
,
cascade
:
true
,
onUpdate
:
'CASCADE'
,
onDelete
:
'CASCADE'
})
@
JoinTable
()
executors
!
:
User
[];
@
ManyToOne
(()
=>
Project
,(
project
:{
tasks
:
Task
[]})
=>
project
.
tasks
)
project
!
:
Project
|
null
;
}
planner-api/src/routers/tasks.ts
View file @
36e04fb1
...
...
@@ -68,14 +68,6 @@ router.get('/my', async (req: Request, res: Response):Promise<Response>=>{
})
router
.
delete
(
'/:taskId'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
// const token = req.get('Authorization');
// const user = await dataSource
// .createQueryBuilder()
// .select("user")
// .from(User, "user")
// .where("user.token = :token", { token: token })
// .getOne()
// if(!user) return res.status(404).send({Message:'user not found'})
const
taskId
=
req
.
params
.
taskId
;
await
myDataSource
.
createQueryBuilder
()
...
...
@@ -96,24 +88,23 @@ router.put('/',async(req:Request, res:Response)=> {
.
where
(
"user.token = :token"
,
{
token
:
token
})
.
getOne
()
if
(
!
user
)
return
res
.
status
(
404
).
send
({
Message
:
'user not found'
})
const
{
id
,
title
,
description
,
project
,
dateTimeDue
,
dateTimeStart
,
accomplish
,
priority
}
=
req
.
body
;
await
dataSource
const
{
id
,
title
,
description
,
project
,
dateTimeDue
,
dateTimeStart
,
executors
,
accomplish
,
priority
}
=
req
.
body
;
const
task
=
await
dataSource
.
createQueryBuilder
()
.
update
(
Task
)
.
set
({
title
:
title
,
description
:
description
,
project
:
project
,
dateTimeDue
:
dateTimeDue
,
dateTimeStart
:
dateTimeStart
,
author
:
user
,
accomplish
:
accomplish
,
priority
:
priority
})
.
where
(
"id = :id"
,
{
id
:
id
})
.
execute
()
.
select
(
"task"
)
.
from
(
Task
,
"task"
)
.
where
(
"task.id = :id"
,
{
id
})
.
getOne
()
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
task
.
title
=
title
task
.
description
=
description
task
.
project
=
project
task
.
dateTimeDue
=
dateTimeDue
task
.
dateTimeStart
=
dateTimeStart
task
.
author
=
user
task
.
executors
=
executors
task
.
accomplish
=
accomplish
task
.
priority
=
priority
await
task
.
save
()
res
.
send
({
message
:
'update task successfully'
})
// res.send({task})
})
planner-api/src/routers/users.ts
View file @
36e04fb1
...
...
@@ -60,7 +60,6 @@ router.post('/', upload.single("avatar"), async (req : Request, res : Response):
router
.
post
(
'/sessions/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
const
{
email
,
password
}
=
req
.
body
;
console
.
log
(
"email"
+
email
,
"password"
+
password
)
const
user
=
await
dataSource
.
createQueryBuilder
()
.
select
(
"user"
)
...
...
@@ -70,7 +69,6 @@ router.post('/sessions/', async (req : Request, res : Response):Promise<object>
.
getOne
()
if
(
!
user
)
return
res
.
status
(
404
).
send
({
Message
:
'user not found'
})
const
isMatch
:
boolean
=
await
user
.
checkPassword
(
password
);
console
.
log
(
"123"
)
if
(
!
isMatch
)
return
res
.
status
(
400
).
send
({
error
:
"Wrong Password"
})
...
...
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