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
b4ec39d4
Commit
b4ec39d4
authored
Nov 22, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#58
deleted unknow file
parent
e7982023
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
211 deletions
+0
-211
[B[B[B[B[B[B[B[A[A[Aq
[B[B[B[B[B[B[B[A[A[Aq
+0
-211
No files found.
[B[B[B[B[B[B[B[A[A[Aq
deleted
100644 → 0
View file @
e7982023
[1mdiff --git a/planner-api/src/fixtures.ts b/planner-api/src/fixtures.ts[m
[1mindex 8734749..b80ffb6 100644[m
[1m--- a/planner-api/src/fixtures.ts[m
[1m+++ b/planner-api/src/fixtures.ts[m
[36m@@ -4,6 +4,7 @@[m [mimport { User, UserRole } from "./models/User";[m
import { faker } from '@faker-js/faker';[m
import { Task } from "./models/Task";[m
import { Project } from "./models/Project";[m
[32m+[m[32mimport { Member, MemberRole } from "./models/Member";[m
[m
function randomIntFromInterval(min:number, max:number) { [m
return Math.floor(Math.random() * (max - min + 1) + min)[m
[36m@@ -50,7 +51,7 @@[m [mconst loadFixtures = async () => {[m
const newTask = new Task();[m
newTask.title = `Buy ${faker.commerce.productName()}`;[m
newTask.description = faker.random.words(4);[m
[31m- newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));[m
[32m+[m[32m newTask.executor = faker.helpers.arrayElement(users);[m
newTask.dateTimeDue = faker.date.soon(randomIntFromInterval(1, 15));[m
newTask.dateTimeStart = faker.date.recent((randomIntFromInterval(0, 8)));[m
newTask.author = faker.helpers.arrayElement(users);[m
[36m@@ -62,7 +63,7 @@[m [mconst loadFixtures = async () => {[m
const newTask = new Task();[m
newTask.title = `Buy ${faker.commerce.productName()}`;[m
newTask.description = faker.random.words(4);[m
[31m- newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));[m
[32m+[m[32m newTask.executor = faker.helpers.arrayElement(users);[m
newTask.dateTimeDue = null;[m
newTask.dateTimeStart = null;[m
newTask.author = faker.helpers.arrayElement(users);[m
[36m@@ -73,14 +74,24 @@[m [mconst loadFixtures = async () => {[m
}[m
}[m
[m
[32m+[m[32m const members:Member[]=[][m
[32m+[m[32m for (let i = 0; i < 5; i++) {[m
[32m+[m[32m const newMember = new Member();[m
[32m+[m[32m newMember.user = faker.helpers.arrayElement(users);[m
[32m+[m[32m newMember.role=faker.helpers.objectValue(MemberRole);[m
[32m+[m[32m await newMember.save();[m
[32m+[m[32m members.push(newMember)[m
[32m+[m[32m }[m
[32m+[m
const projects:Project[] = [][m
for (let i = 0; i < 5; i++) {[m
const newProject = new Project();[m
newProject.title = `Project ${faker.random.words(1)}`;[m
newProject.color = faker.random.words(1);[m
[31m- newProject.admin = faker.helpers.arrayElement(users);[m
[32m+[m[32m newProject.members = faker.helpers.arrayElements(members,randomIntFromInterval(1, 3))[m
[32m+[m[32m // newProject.admin = faker.helpers.arrayElement(users);[m
newProject.tasks= faker.helpers.arrayElements(tasks, randomIntFromInterval(1, 3));[m
[31m- newProject.workers = faker.helpers.arrayElements(users, randomIntFromInterval(1, 3));[m
[32m+[m[32m // newProject.workers = faker.helpers.arrayElements(users, randomIntFromInterval(1, 3));[m
await newProject.save();[m
projects.push(newProject)[m
}[m
[1mdiff --git a/planner-api/src/models/Member.ts b/planner-api/src/models/Member.ts[m
[1mindex 37bb23c..9bd0a66 100644[m
[1m--- a/planner-api/src/models/Member.ts[m
[1m+++ b/planner-api/src/models/Member.ts[m
[36m@@ -37,7 +37,7 @@[m [mimport {[m
@ManyToOne(() => User, (user: { members: Member[]; }) => user.members,{cascade: true, onUpdate:'CASCADE'})[m
user!: User;[m
[m
[31m- @ManyToOne(() => Project, (project: { members: Member[]; }) => project.members,{cascade: true, onUpdate:'CASCADE'})[m
[32m+[m[32m @ManyToOne(() => Project, (project: { members: Member[]; }) => project.members,{cascade: true, onUpdate:'CASCADE',nullable:true})[m
project!: Project;[m
[m
@Column({[m
[1mdiff --git a/planner-api/src/models/Task.ts b/planner-api/src/models/Task.ts[m
[1mindex a5e9f83..c8a1650 100644[m
[1m--- a/planner-api/src/models/Task.ts[m
[1m+++ b/planner-api/src/models/Task.ts[m
[36m@@ -5,7 +5,7 @@[m [mimport {[m
CreateDateColumn,[m
BaseEntity,[m
ManyToOne,[m
[31m- ManyToMany,[m
[32m+[m[32m OneToOne,[m
JoinTable[m
} from 'typeorm';[m
import {User} from './User';[m
[36m@@ -25,7 +25,7 @@[m [mimport {[m
priority: priorityType | null;[m
author: User;[m
project:Project|null;[m
[31m- executors:User[];[m
[32m+[m[32m executor:User;[m
}[m
[m
@Entity({ name: 'Task' })[m
[36m@@ -64,9 +64,9 @@[m [mimport {[m
@ManyToOne(() => User, (user: { tasks: Task[]; }) => user.tasks,{eager : true})[m
author!: User;[m
[m
[31m- @ManyToMany(() => User,{eager : true, cascade: true, onUpdate:'CASCADE'})[m
[32m+[m[32m @ManyToOne(() =>User, (user: { tasks: Task[]}) => user.tasks,{eager : true,nullable: true, onUpdate:'CASCADE'})[m
@JoinTable()[m
[31m- executors!: User[];[m
[32m+[m[32m executor!: User;[m
[m
@ManyToOne(()=>Project,(project:{tasks: Task[]}) => project.tasks,{eager : true,nullable: true,onUpdate:'CASCADE'})[m
project!: Project;[m
[1mdiff --git a/planner-api/src/models/User.ts b/planner-api/src/models/User.ts[m
[1mindex 9b967fe..855ee37 100644[m
[1m--- a/planner-api/src/models/User.ts[m
[1m+++ b/planner-api/src/models/User.ts[m
[36m@@ -8,6 +8,7 @@[m [mimport {[m
ManyToMany,[m
OneToMany,[m
JoinTable,[m
[32m+[m[32m OneToOne,[m
} from 'typeorm';[m
import {IsEmail[m
} from "class-validator";[m
[36m@@ -82,7 +83,7 @@[m [mexport class User extends BaseEntity implements IUser {[m
@OneToMany(() => Task, (task: { user: User }) => task.user)[m
createdTasks!: Task[];[m
[m
[31m- @ManyToMany(() => Task, (task: { users: User[] }) =>task.users)[m
[32m+[m[32m @OneToMany(() => Task, (task: { user: User }) =>task.user)[m
tasks!: Task[];[m
[m
[m
[1mdiff --git a/planner-api/src/routers/projects.ts b/planner-api/src/routers/projects.ts[m
[1mindex bea1f3a..0cfa624 100644[m
[1m--- a/planner-api/src/routers/projects.ts[m
[1m+++ b/planner-api/src/routers/projects.ts[m
[36m@@ -29,10 +29,10 @@[m [mrouter.post('/', async (req:Request, res:Response): Promise<Response> => {[m
project.title = title;[m
project.color = color; [m
project.dateDue = dateDue || null;[m
[31m- project.department = department;[m
[31m- project.workers = workers|| null;[m
[32m+[m[32m // project.department = department;[m
[32m+[m[32m // project.workers = workers|| null;[m
project.tasks = tasks || null;[m
[31m- project.admin = user;[m
[32m+[m[32m // project.admin = user;[m
await project.save()[m
return res.send({project})[m
})[m
[1mdiff --git a/planner-api/src/routers/tasks.ts b/planner-api/src/routers/tasks.ts[m
[1mindex 7d70d2c..b51ae60 100644[m
[1m--- a/planner-api/src/routers/tasks.ts[m
[1m+++ b/planner-api/src/routers/tasks.ts[m
[36m@@ -3,6 +3,7 @@[m [mimport {Task} from '../models/Task';[m
import {myDataSource} from '../app-data-source';[m
import { User } from '../models/User';[m
import { Project } from '../models/Project';[m
[32m+[m[32mimport { Member } from '../models/Member';[m
const router:Router = express.Router();[m
const dataSource = myDataSource;[m
[m
[36m@@ -28,7 +29,7 @@[m [mrouter.post('/', async(req:Request, res:Response):Promise<Response>=>{[m
newTask.title = title;[m
newTask.description = description;[m
newTask.project = project;[m
[31m- newTask.executors = executors;[m
[32m+[m[32m // newTask.executors = executors;[m
newTask.dateTimeDue = dateTimeDue;[m
newTask.dateTimeStart = dateTimeStart;[m
newTask.author= user;[m
[36m@@ -38,13 +39,23 @@[m [mrouter.post('/', async(req:Request, res:Response):Promise<Response>=>{[m
return res.send({newTask})[m
})[m
[m
[31m-router.get('/:userId', async (req: Request, res: Response):Promise<Response>=>{ [m
[32m+[m[32mrouter.get('/user/:userId', async (req: Request, res: Response):Promise<Response>=>{[m[41m [m
const userId = req.params.userId;[m
[32m+[m[32m // const tasks = await dataSource[m
[32m+[m[32m // .getRepository(Task)[m
[32m+[m[32m // .createQueryBuilder('task')[m
[32m+[m[32m // .innerJoinAndSelect('task.executors', 'user')[m
[32m+[m[32m // .where('user.id = :userId', {userId :userId})[m
[32m+[m[32m // .getMany()[m
[32m+[m[32m // return res.send({tasks})[m
const tasks = await dataSource[m
[31m- .getRepository(Task)[m
[31m- .createQueryBuilder('task')[m
[31m- .innerJoinAndSelect('task.executors', 'user')[m
[31m- .where('user.id = :userId', {userId :userId})[m
[32m+[m[32m .getRepository(Member)[m
[32m+[m[32m .createQueryBuilder('member')[m
[32m+[m[32m .innerJoinAndSelect('member.project','project')[m
[32m+[m[32m .innerJoinAndSelect('project.tasks','task')[m
[32m+[m[32m .where('member.user.id = :userId')[m
[32m+[m[32m .andWhere('member.project.id= task.project.id')[m
[32m+[m[32m .select('task.*')[m
.getMany()[m
return res.send({tasks})[m
})[m
[36m@@ -104,7 +115,7 @@[m [mrouter.put('/',async(req:Request, res:Response)=> {[m
task.dateTimeDue= dateTimeDue[m
task.dateTimeStart= dateTimeStart[m
task.author=user[m
[31m- task.executors=executors[m
[32m+[m[32m // task.executors=executors[m
task.accomplish= accomplish[m
task.priority= priority [m
await task.save()[m
[36m@@ -121,7 +132,7 @@[m [mrouter.post('/project',async (req: Request, res: Response):Promise<Response>=>{[m
.getRepository(Task)[m
.find({[m
relations:{[m
[31m- executors:true,[m
[32m+[m[32m // executors:true,[m
author:true,[m
project:true[m
}[m
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