chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -1,22 +1,22 @@
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';
import { ApiTags } from '@midwayjs/swagger';
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";
import { ApiTags } from "@midwayjs/swagger";
/**
*/
@Provide()
@Controller('/api/enterprise/project')
@ApiTags(['enterprise-project'])
@Controller("/api/enterprise/project")
@ApiTags(["enterprise-project"])
export class UserProjectController extends BaseController {
@Inject()
service: ProjectService;
@Inject()
projectMemberService: ProjectMemberService;
@Inject()
authService: AuthService;
@@ -24,54 +24,52 @@ export class UserProjectController extends BaseController {
return this.service;
}
/**
* @param body
* @returns
/**
* @param body
* @returns
*/
@Post('/detail', { description: Constants.per.authOnly, summary: "查询项目详情" })
@Post("/detail", { description: Constants.per.authOnly, summary: "查询项目详情" })
async detail(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdRead();
const res = await this.service.getDetail(projectId,this.getUserId());
const { projectId } = await this.getProjectUserIdRead();
const res = await this.service.getDetail(projectId, this.getUserId());
return this.ok(res);
}
/**
* 我的项目
* @param body
* @returns
* @param body
* @returns
*/
@Post('/list', { description: Constants.per.authOnly, summary: "查询我的项目列表" })
@Post("/list", { description: Constants.per.authOnly, summary: "查询我的项目列表" })
async list(@Body(ALL) body: any) {
const userId= this.getUserId();
const userId = this.getUserId();
const res = await this.service.getUserProjects(userId);
return this.ok(res);
}
/**
*
*
* @param body 所有项目
* @returns
* @returns
*/
@Post('/all', { description: Constants.per.authOnly, summary: "查询所有项目" })
@Post("/all", { description: Constants.per.authOnly, summary: "查询所有项目" })
async all(@Body(ALL) body: any) {
const userId= this.getUserId();
const userId = this.getUserId();
const res = await this.service.getAllWithStatus(userId);
return this.ok(res);
}
@Post('/applyJoin', { description: Constants.per.authOnly, summary: "申请加入项目" })
@Post("/applyJoin", { description: Constants.per.authOnly, summary: "申请加入项目" })
async applyJoin(@Body(ALL) body: any) {
const userId= this.getUserId();
const userId = this.getUserId();
const res = await this.service.applyJoin({ userId, projectId: body.projectId });
return this.ok(res);
}
@Post('/updateMember', { description: Constants.per.authOnly, summary: "更新项目成员" })
@Post("/updateMember", { description: Constants.per.authOnly, summary: "更新项目成员" })
async updateMember(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdAdmin();
const {status,permission,userId} = body;
const { projectId } = await this.getProjectUserIdAdmin();
const { status, permission, userId } = body;
const member = await this.projectMemberService.findOne({
where: {
projectId,
@@ -79,7 +77,7 @@ export class UserProjectController extends BaseController {
},
});
if (!member) {
throw new Error('成员不存在');
throw new Error("成员不存在");
}
const res = await this.projectMemberService.update({
id: member.id,
@@ -89,17 +87,17 @@ export class UserProjectController extends BaseController {
return this.ok(res);
}
@Post('/approveJoin', { description: Constants.per.authOnly, summary: "审批加入项目申请" })
@Post("/approveJoin", { description: Constants.per.authOnly, summary: "审批加入项目申请" })
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 });
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', { description: Constants.per.authOnly, summary: "删除项目成员" })
@Post("/delete", { description: Constants.per.authOnly, summary: "删除项目成员" })
async delete(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdAdmin();
const { projectId } = await this.getProjectUserIdAdmin();
await this.projectMemberService.deleteWhere({
projectId,
userId: this.getUserId(),
@@ -107,15 +105,14 @@ export class UserProjectController extends BaseController {
return this.ok();
}
@Post('/leave', { description: Constants.per.authOnly, summary: "离开项目" })
@Post("/leave", { description: Constants.per.authOnly, summary: "离开项目" })
async leave(@Body(ALL) body: any) {
const {projectId} = body
const userId = this.getUserId();
const { projectId } = body;
const userId = this.getUserId();
await this.projectMemberService.deleteWhere({
projectId,
userId,
});
return this.ok();
}
}
@@ -1,4 +1,4 @@
import { CrudController, SysSettingsService,Constants } from "@certd/lib-server";
import { CrudController, SysSettingsService, Constants } from "@certd/lib-server";
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { ProjectMemberEntity } from "../../../modules/sys/enterprise/entity/project-member.js";
import { ProjectMemberService } from "../../../modules/sys/enterprise/service/project-member-service.js";
@@ -9,7 +9,7 @@ import { ApiTags } from "@midwayjs/swagger";
*/
@Provide()
@Controller("/api/enterprise/projectMember")
@ApiTags(['enterprise-project-member'])
@ApiTags(["enterprise-project-member"])
export class ProjectMemberController extends CrudController<ProjectMemberEntity> {
@Inject()
service: ProjectMemberService;
@@ -26,7 +26,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
@Post("/page", { description: Constants.per.authOnly, summary: "查询项目成员分页列表" })
async page(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdRead();
const { projectId } = await this.getProjectUserIdRead();
body.query = body.query ?? {};
body.query.projectId = projectId;
return await super.page(body);
@@ -34,7 +34,7 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
@Post("/list", { description: Constants.per.authOnly, summary: "查询项目成员列表" })
async list(@Body(ALL) body: any) {
const {projectId} = await this.getProjectUserIdRead();
const { projectId } = await this.getProjectUserIdRead();
body.query = body.query ?? {};
body.query.projectId = projectId;
return super.list(body);
@@ -56,12 +56,12 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
return super.add(bean);
}
@Post("/update", { description: Constants.per.authOnly, summary: "更新项目成员" })
@Post("/update", { description: Constants.per.authOnly, summary: "更新项目成员" })
async update(@Body(ALL) bean: any) {
if (!bean.id) {
throw new Error("id is required");
}
const projectId = await this.service.getProjectId(bean.id)
const projectId = await this.service.getProjectId(bean.id);
await this.projectService.checkAdminPermission({
userId: this.getUserId(),
projectId: projectId,
@@ -77,13 +77,13 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
@Post("/info", { description: Constants.per.authOnly, summary: "查询项目成员详情" })
async info(@Query("id") id: number) {
if (!id) {
if (!id) {
throw new Error("id is required");
}
const projectId = await this.service.getProjectId(id)
const projectId = await this.service.getProjectId(id);
await this.projectService.checkReadPermission({
userId: this.getUserId(),
projectId:projectId,
projectId: projectId,
});
return super.info(id);
}
@@ -93,10 +93,10 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
if (!id) {
throw new Error("id is required");
}
const projectId = await this.service.getProjectId(id)
const projectId = await this.service.getProjectId(id);
await this.projectService.checkAdminPermission({
userId: this.getUserId(),
projectId:projectId,
projectId: projectId,
});
return super.delete(id);
}
@@ -107,14 +107,14 @@ export class ProjectMemberController extends CrudController<ProjectMemberEntity>
if (!id) {
throw new Error("id is required");
}
const projectId = await this.service.getProjectId(id)
const projectId = await this.service.getProjectId(id);
await this.projectService.checkAdminPermission({
userId: this.getUserId(),
projectId:projectId,
projectId: projectId,
});
await this.service.delete(id as any);
}
return this.ok({});
}
}
@@ -1,44 +1,43 @@
import { BaseController, Constants } from '@certd/lib-server';
import { Controller, Inject, Post, Provide } from '@midwayjs/core';
import { TransferService } from '../../../modules/sys/enterprise/service/transfer-service.js';
import { ApiTags } from '@midwayjs/swagger';
import { BaseController, Constants } from "@certd/lib-server";
import { Controller, Inject, Post, Provide } from "@midwayjs/core";
import { TransferService } from "../../../modules/sys/enterprise/service/transfer-service.js";
import { ApiTags } from "@midwayjs/swagger";
/**
*/
@Provide()
@Controller('/api/enterprise/transfer')
@ApiTags(['enterprise-project'])
@Controller("/api/enterprise/transfer")
@ApiTags(["enterprise-project"])
export class TransferController extends BaseController {
@Inject()
service: TransferService;
getService(): TransferService {
return this.service;
}
/**
* 我自己的资源
* @param body
* @returns
/**
* 我自己的资源
* @param body
* @returns
*/
@Post('/selfResources', { description: Constants.per.authOnly, summary: "查询我自己的资源" })
@Post("/selfResources", { description: Constants.per.authOnly, summary: "查询我自己的资源" })
async selfResources() {
const userId = this.getUserId();
const res = await this.service.getUserResources(userId);
return this.ok(res);
}
/**
* 迁移项目
* @param body
* @returns
/**
* 迁移项目
* @param body
* @returns
*/
@Post('/doTransfer', { description: Constants.per.authOnly, summary: "迁移项目资源" })
@Post("/doTransfer", { description: Constants.per.authOnly, summary: "迁移项目资源" })
async doTransfer() {
const {projectId} = await this.getProjectUserIdRead();
const userId = this.getUserId();
await this.service.transferAll(userId,projectId);
const { projectId } = await this.getProjectUserIdRead();
const userId = this.getUserId();
await this.service.transferAll(userId, projectId);
return this.ok();
}
}