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
6a0bcd24
Commit
6a0bcd24
authored
Nov 08, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#32
fix role
parent
9171ead8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
11 deletions
+16
-11
Task.ts
planner-api/src/models/Task.ts
+7
-4
User.ts
planner-api/src/models/User.ts
+5
-5
tasks.ts
planner-api/src/routers/tasks.ts
+2
-1
users.ts
planner-api/src/routers/users.ts
+2
-1
No files found.
planner-api/src/models/Task.ts
View file @
6a0bcd24
...
@@ -30,16 +30,19 @@ import {
...
@@ -30,16 +30,19 @@ import {
export
class
Task
extends
BaseEntity
implements
ITask
{
export
class
Task
extends
BaseEntity
implements
ITask
{
@
PrimaryGeneratedColumn
(
'uuid'
)
@
PrimaryGeneratedColumn
(
'uuid'
)
id
!
:
string
id
!
:
string
@
Column
({
name
:
'dateTimeStart'
,
type
:
Date
,
nullable
:
true
})
dateTimeStart
!
:
Date
|
null
;
@
Column
({
name
:
'dateTimeDue'
,
type
:
Date
,
nullable
:
true
})
dateTimeDue
!
:
Date
|
null
;
@
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
:
true
})
@
Column
({
name
:
'description'
,
type
:
'varchar'
,
length
:
50
,
nullable
:
true
})
description
!
:
string
description
!
:
string
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
createdAt
!
:
Date
;
createdAt
!
:
Date
;
@
Column
({
name
:
'dateTimeStart'
,
type
:
'varchar'
,
nullable
:
true
})
dateTimeStart
!
:
Date
|
null
;
@
Column
({
name
:
'dateTimeDue'
,
type
:
'varchar'
,
nullable
:
true
})
dateTimeDue
!
:
Date
|
null
;
@
Column
({
@
Column
({
type
:
"enum"
,
type
:
"enum"
,
enum
:
[
"opened"
,
"done"
,
"failed"
],
enum
:
[
"opened"
,
"done"
,
"failed"
],
...
...
planner-api/src/models/User.ts
View file @
6a0bcd24
...
@@ -20,17 +20,17 @@ import {Project} from './Project';
...
@@ -20,17 +20,17 @@ import {Project} from './Project';
const
SALT_WORK_FACTOR
=
10
;
const
SALT_WORK_FACTOR
=
10
;
type
userRoleType
=
[
"user"
,
"director"
,
"superuser"
];
export
enum
UserRole
{
USER
=
"user"
,
DIRECTOR
=
"director"
,
SUPERUSER
=
"superuser"
}
interface
IUser
{
interface
IUser
{
id
:
string
;
id
:
string
;
role
:
UserRole
;
name
:
string
;
name
:
string
;
surname
:
string
;
surname
:
string
;
email
:
string
;
email
:
string
;
displayName
:
string
;
displayName
:
string
;
password
:
string
;
password
:
string
;
token
:
string
;
token
:
string
;
role
:
userRoleType
;
createdAt
:
Date
;
createdAt
:
Date
;
createdTasks
:
Task
[];
createdTasks
:
Task
[];
workerInProjects
:
Project
[];
workerInProjects
:
Project
[];
...
@@ -67,10 +67,10 @@ export class User extends BaseEntity implements IUser {
...
@@ -67,10 +67,10 @@ export class User extends BaseEntity implements IUser {
@
Column
({
@
Column
({
type
:
"enum"
,
type
:
"enum"
,
enum
:
[
"user"
,
"director"
,
"superuser"
]
,
enum
:
UserRole
,
default
:
"user"
default
:
UserRole
.
SUPERUSER
})
})
role
!
:
userRoleTyp
e
role
!
:
UserRol
e
@
Column
({
type
:
'varchar'
,
nullable
:
false
,
select
:
true
})
@
Column
({
type
:
'varchar'
,
nullable
:
false
,
select
:
true
})
@
Exclude
({
toPlainOnly
:
true
})
@
Exclude
({
toPlainOnly
:
true
})
...
...
planner-api/src/routers/tasks.ts
View file @
6a0bcd24
...
@@ -17,7 +17,7 @@ export default router;
...
@@ -17,7 +17,7 @@ export default router;
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
token
=
req
.
get
(
'Authorization'
);
const
token
=
req
.
get
(
'Authorization'
);
const
newTask
=
new
Task
();
const
newTask
=
new
Task
();
const
{
title
,
description
,
project
,
executors
,
dateTimeDue
,
dateTimeStart
}
=
req
.
body
;
const
{
title
,
description
,
project
,
executors
,
dateTimeDue
,
dateTimeStart
,
accomplish
}
=
req
.
body
;
const
user
=
await
dataSource
const
user
=
await
dataSource
.
createQueryBuilder
()
.
createQueryBuilder
()
.
select
(
"user"
)
.
select
(
"user"
)
...
@@ -32,6 +32,7 @@ router.post('/', async(req:Request, res:Response):Promise<Response>=>{
...
@@ -32,6 +32,7 @@ router.post('/', async(req:Request, res:Response):Promise<Response>=>{
newTask
.
dateTimeDue
=
dateTimeDue
;
newTask
.
dateTimeDue
=
dateTimeDue
;
newTask
.
dateTimeStart
=
dateTimeStart
;
newTask
.
dateTimeStart
=
dateTimeStart
;
newTask
.
author
=
user
;
newTask
.
author
=
user
;
newTask
.
accomplish
=
accomplish
;
await
newTask
.
save
();
await
newTask
.
save
();
return
res
.
send
({
newTask
})
return
res
.
send
({
newTask
})
})
})
...
...
planner-api/src/routers/users.ts
View file @
6a0bcd24
...
@@ -17,7 +17,7 @@ return res.send({users})
...
@@ -17,7 +17,7 @@ return res.send({users})
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
router
.
post
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
const
{
name
,
surname
,
password
,
email
}
=
req
.
body
;
const
{
name
,
surname
,
password
,
email
,
role
}
=
req
.
body
;
const
displayName
=
surname
+
' '
+
name
[
0
]
+
'.'
const
displayName
=
surname
+
' '
+
name
[
0
]
+
'.'
const
user
=
new
User
();
const
user
=
new
User
();
user
.
name
=
name
;
user
.
name
=
name
;
...
@@ -25,6 +25,7 @@ router.post('/', async (req : Request, res : Response):Promise<object> => {
...
@@ -25,6 +25,7 @@ router.post('/', async (req : Request, res : Response):Promise<object> => {
user
.
password
=
password
;
user
.
password
=
password
;
user
.
displayName
=
displayName
;
user
.
displayName
=
displayName
;
user
.
email
=
email
;
user
.
email
=
email
;
user
.
role
=
role
;
user
.
generateToken
()
user
.
generateToken
()
await
user
.
save
();
await
user
.
save
();
const
userToFront
:
User
|
null
=
await
dataSource
.
manager
.
findOneBy
(
User
,
{
const
userToFront
:
User
|
null
=
await
dataSource
.
manager
.
findOneBy
(
User
,
{
...
...
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