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
6d19d5d3
Commit
6d19d5d3
authored
Nov 04, 2022
by
“Yevgeniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#23
adde model Project
parent
e5346cd0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
Project.ts
planner-api/src/models/Project.ts
+49
-0
User.ts
planner-api/src/models/User.ts
+9
-0
No files found.
planner-api/src/models/Project.ts
0 → 100644
View file @
6d19d5d3
import
{
Column
,
Entity
,
PrimaryGeneratedColumn
,
CreateDateColumn
,
BaseEntity
,
ManyToOne
,
ManyToMany
}
from
'typeorm'
;
import
{
User
}
from
'./User'
;
interface
IProject
{
id
:
string
;
title
:
string
;
color
:
string
;
admin
:
User
;
workers
:
User
[]
|
undefined
;
createdAt
:
Date
;
dateDue
:
Date
|
null
;
department
:
boolean
|
false
;
}
@
Entity
({
name
:
'Project'
})
export
class
Project
extends
BaseEntity
implements
IProject
{
@
PrimaryGeneratedColumn
(
'uuid'
)
id
!
:
string
@
Column
({
name
:
'title'
,
type
:
'varchar'
,
length
:
100
,
nullable
:
false
})
title
!
:
string
@
CreateDateColumn
({
name
:
'createdAt'
,
type
:
Date
,
default
:
new
Date
()
})
createdAt
!
:
Date
;
@
Column
({
name
:
'color'
,
type
:
'varchar'
,
length
:
100
,
nullable
:
false
})
color
!
:
string
@
Column
({
name
:
'dateDue'
,
type
:
Date
,
default
:
null
})
dateDue
!
:
Date
|
null
;
@
Column
({
name
:
'department'
,
type
:
Boolean
,
default
:
false
})
department
!
:
boolean
|
false
;
@
ManyToOne
(()
=>
User
,
(
user
:
{
projects
:
Project
[];
})
=>
user
.
projects
)
admin
!
:
User
;
@
ManyToMany
(()
=>
User
,
(
user
:
{
projects
:
Project
[];
})
=>
user
.
projects
)
workers
!
:
User
[];
}
planner-api/src/models/User.ts
View file @
6d19d5d3
...
@@ -12,6 +12,7 @@ import {
...
@@ -12,6 +12,7 @@ import {
import
bcrypt
from
'bcrypt'
;
import
bcrypt
from
'bcrypt'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
Task
}
from
'./Task'
;
import
{
Task
}
from
'./Task'
;
import
{
Project
}
from
'./Project'
;
const
SALT_WORK_FACTOR
=
10
;
const
SALT_WORK_FACTOR
=
10
;
...
@@ -75,6 +76,14 @@ export class User extends BaseEntity implements IUser {
...
@@ -75,6 +76,14 @@ export class User extends BaseEntity implements IUser {
@
ManyToMany
(()
=>
Task
,
(
task
:
{
users
:
User
[]
})
=>
task
.
users
)
@
ManyToMany
(()
=>
Task
,
(
task
:
{
users
:
User
[]
})
=>
task
.
users
)
tasksToMake
!
:
Task
[];
tasksToMake
!
:
Task
[];
@
OneToMany
(()
=>
Project
,
(
project
:
{
user
:
User
})
=>
project
.
user
)
adminInProjects
!
:
Project
[];
@
ManyToMany
(()
=>
Project
,
(
project
:
{
users
:
User
[]
})
=>
project
.
users
)
workerInProjects
!
:
Project
[];
@
BeforeInsert
()
@
BeforeInsert
()
protected
async
beforeInserthashPassword
():
Promise
<
void
>
{
protected
async
beforeInserthashPassword
():
Promise
<
void
>
{
const
salt
=
await
bcrypt
.
genSalt
(
SALT_WORK_FACTOR
);
const
salt
=
await
bcrypt
.
genSalt
(
SALT_WORK_FACTOR
);
...
...
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