mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore: join project
This commit is contained in:
@@ -2,6 +2,7 @@ import { BaseController, Constants } from '@certd/lib-server';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
||||
import { ProjectService } from '../../../modules/sys/enterprise/service/project-service.js';
|
||||
import { ProjectMemberService } from '../../../modules/sys/enterprise/service/project-member-service.js';
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -10,6 +11,10 @@ import { ProjectService } from '../../../modules/sys/enterprise/service/project-
|
||||
export class UserProjectController extends BaseController {
|
||||
@Inject()
|
||||
service: ProjectService;
|
||||
|
||||
@Inject()
|
||||
projectMemberService: ProjectMemberService;
|
||||
|
||||
@Inject()
|
||||
authService: AuthService;
|
||||
|
||||
@@ -17,6 +22,11 @@ export class UserProjectController extends BaseController {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的项目
|
||||
* @param body
|
||||
* @returns
|
||||
*/
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Body(ALL) body: any) {
|
||||
const userId= this.getUserId();
|
||||
@@ -24,4 +34,74 @@ export class UserProjectController extends BaseController {
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param body 所有项目
|
||||
* @returns
|
||||
*/
|
||||
@Post('/all', { summary: Constants.per.authOnly })
|
||||
async all(@Body(ALL) body: any) {
|
||||
const userId= this.getUserId();
|
||||
const res = await this.service.getAllWithStatus(userId);
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/applyJoin', { summary: Constants.per.authOnly })
|
||||
async applyJoin(@Body(ALL) body: any) {
|
||||
const userId= this.getUserId();
|
||||
const res = await this.service.applyJoin({ userId, projectId: body.projectId });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/updateMember', { summary: Constants.per.authOnly })
|
||||
async updateMember(@Body(ALL) body: any) {
|
||||
const {projectId} = await this.getProjectUserIdAdmin();
|
||||
const {status,permission,userId} = body;
|
||||
const member = await this.projectMemberService.findOne({
|
||||
where: {
|
||||
projectId,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
if (!member) {
|
||||
throw new Error('成员不存在');
|
||||
}
|
||||
const res = await this.projectMemberService.update({
|
||||
id: member.id,
|
||||
status,
|
||||
permission,
|
||||
});
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/approveJoin', { summary: Constants.per.authOnly })
|
||||
async approveJoin(@Body(ALL) body: any) {
|
||||
const {projectId} = await this.getProjectUserIdAdmin();
|
||||
const {status,permission,userId} = body;
|
||||
const res = await this.service.approveJoin({ userId, projectId: projectId,status,permission });
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Body(ALL) body: any) {
|
||||
const {projectId} = await this.getProjectUserIdAdmin();
|
||||
await this.projectMemberService.deleteWhere({
|
||||
projectId,
|
||||
userId: this.getUserId(),
|
||||
});
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
@Post('/leave', { summary: Constants.per.authOnly })
|
||||
async leave(@Body(ALL) body: any) {
|
||||
const {projectId} = body
|
||||
const userId = this.getUserId();
|
||||
await this.projectMemberService.deleteWhere({
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user