mirror of
https://github.com/certd/certd.git
synced 2026-07-14 17:53:28 +08:00
chore: format
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { Constants, CrudController } from '@certd/lib-server';
|
||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
||||
import { GroupService } from '../../../modules/basic/service/group-service.js';
|
||||
import { ApiTags } from '@midwayjs/swagger';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
|
||||
import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { GroupService } from "../../../modules/basic/service/group-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
|
||||
/**
|
||||
* 通知
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/basic/group')
|
||||
@ApiTags(['basic-group'])
|
||||
@Controller("/api/basic/group")
|
||||
@ApiTags(["basic-group"])
|
||||
export class GroupController extends CrudController<GroupService> {
|
||||
@Inject()
|
||||
service: GroupService;
|
||||
@@ -20,14 +20,14 @@ export class GroupController extends CrudController<GroupService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
@Post('/page', { description: Constants.per.authOnly, summary: "查询分组分页列表" })
|
||||
@Post("/page", { description: Constants.per.authOnly, summary: "查询分组分页列表" })
|
||||
async page(@Body(ALL) body: any) {
|
||||
const {projectId,userId} = await this.getProjectUserIdRead();
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
body.query = body.query ?? {};
|
||||
body.query.projectId = projectId;
|
||||
delete body.query.userId;
|
||||
const buildQuery = qb => {
|
||||
qb.andWhere('user_id = :userId', { userId });
|
||||
qb.andWhere("user_id = :userId", { userId });
|
||||
};
|
||||
const res = await this.service.page({
|
||||
query: body.query,
|
||||
@@ -38,45 +38,45 @@ export class GroupController extends CrudController<GroupService> {
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
@Post('/list', { description: Constants.per.authOnly, summary: "查询分组列表" })
|
||||
@Post("/list", { description: Constants.per.authOnly, summary: "查询分组列表" })
|
||||
async list(@Body(ALL) body: any) {
|
||||
const {projectId,userId} = await this.getProjectUserIdRead();
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
body.query = body.query ?? {};
|
||||
body.query.projectId = projectId;
|
||||
body.query.userId = userId;
|
||||
return await super.list(body);
|
||||
}
|
||||
|
||||
@Post('/add', { description: Constants.per.authOnly, summary: "添加分组" })
|
||||
@Post("/add", { description: Constants.per.authOnly, summary: "添加分组" })
|
||||
async add(@Body(ALL) bean: any) {
|
||||
const {projectId,userId} = await this.getProjectUserIdRead();
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
bean.projectId = projectId;
|
||||
bean.userId = userId;
|
||||
return await super.add(bean);
|
||||
}
|
||||
|
||||
@Post('/update', { description: Constants.per.authOnly, summary: "更新分组" })
|
||||
@Post("/update", { description: Constants.per.authOnly, summary: "更新分组" })
|
||||
async update(@Body(ALL) bean) {
|
||||
await this.checkOwner(this.getService(), bean.id, "write");
|
||||
delete bean.userId;
|
||||
delete bean.projectId;
|
||||
return await super.update(bean);
|
||||
}
|
||||
@Post('/info', { description: Constants.per.authOnly, summary: "查询分组详情" })
|
||||
async info(@Query('id') id: number) {
|
||||
@Post("/info", { description: Constants.per.authOnly, summary: "查询分组详情" })
|
||||
async info(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "read");
|
||||
return await super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete', { description: Constants.per.authOnly, summary: "删除分组" })
|
||||
async delete(@Query('id') id: number) {
|
||||
@Post("/delete", { description: Constants.per.authOnly, summary: "删除分组" })
|
||||
async delete(@Query("id") id: number) {
|
||||
await this.checkOwner(this.getService(), id, "write");
|
||||
return await super.delete(id);
|
||||
}
|
||||
|
||||
@Post('/all', { description: Constants.per.authOnly, summary: "查询所有分组" })
|
||||
async all(@Query('type') type: string) {
|
||||
const {projectId,userId} = await this.getProjectUserIdRead();
|
||||
@Post("/all", { description: Constants.per.authOnly, summary: "查询所有分组" })
|
||||
async all(@Query("type") type: string) {
|
||||
const { projectId, userId } = await this.getProjectUserIdRead();
|
||||
const list: any = await this.service.find({
|
||||
where: {
|
||||
projectId,
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
import { Constants, isEnterprise } from '@certd/lib-server';
|
||||
import { Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { In } from 'typeorm';
|
||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
||||
import { UserService } from '../../../modules/sys/authority/service/user-service.js';
|
||||
import { BasicController } from '../../basic/code-controller.js';
|
||||
import { RoleService } from '../../../modules/sys/authority/service/role-service.js';
|
||||
import { ApiTags } from '@midwayjs/swagger';
|
||||
import { Constants, isEnterprise } from "@certd/lib-server";
|
||||
import { Body, Controller, Inject, Post, Provide } from "@midwayjs/core";
|
||||
import { In } from "typeorm";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { UserService } from "../../../modules/sys/authority/service/user-service.js";
|
||||
import { BasicController } from "../../basic/code-controller.js";
|
||||
import { RoleService } from "../../../modules/sys/authority/service/role-service.js";
|
||||
import { ApiTags } from "@midwayjs/swagger";
|
||||
|
||||
/**
|
||||
* 通知
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/basic/user')
|
||||
@ApiTags(['basic-user'])
|
||||
@Controller("/api/basic/user")
|
||||
@ApiTags(["basic-user"])
|
||||
export class BasicUserController extends BasicController {
|
||||
@Inject()
|
||||
service: UserService;
|
||||
@Inject()
|
||||
authService: AuthService;
|
||||
@Inject()
|
||||
@Inject()
|
||||
roleService: RoleService;
|
||||
|
||||
getService(): UserService {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
@Post('/getSimpleUserByIds', { description: Constants.per.authOnly, summary: "根据ID列表获取用户简单信息" })
|
||||
async getSimpleUserByIds(@Body('ids') ids: number[]) {
|
||||
if(!isEnterprise()){
|
||||
throw new Error('非企业模式不能获取用户信息');
|
||||
@Post("/getSimpleUserByIds", { description: Constants.per.authOnly, summary: "根据ID列表获取用户简单信息" })
|
||||
async getSimpleUserByIds(@Body("ids") ids: number[]) {
|
||||
if (!isEnterprise()) {
|
||||
throw new Error("非企业模式不能获取用户信息");
|
||||
}
|
||||
const users = await this.service.find({
|
||||
select: {
|
||||
@@ -45,10 +45,10 @@ export class BasicUserController extends BasicController {
|
||||
return this.ok(users);
|
||||
}
|
||||
|
||||
@Post('/getSimpleUsers', {description: Constants.per.authOnly, summary: "获取所有用户简单信息"})
|
||||
@Post("/getSimpleUsers", { description: Constants.per.authOnly, summary: "获取所有用户简单信息" })
|
||||
async getSimpleUsers() {
|
||||
if(!isEnterprise()){
|
||||
throw new Error('非企业模式不能获取所有用户信息');
|
||||
if (!isEnterprise()) {
|
||||
throw new Error("非企业模式不能获取所有用户信息");
|
||||
}
|
||||
const users = await this.service.find({
|
||||
select: {
|
||||
@@ -62,7 +62,7 @@ export class BasicUserController extends BasicController {
|
||||
return this.ok(users);
|
||||
}
|
||||
|
||||
@Post('/getSimpleRoles', {description: Constants.per.authOnly, summary: "获取所有角色简单信息"})
|
||||
@Post("/getSimpleRoles", { description: Constants.per.authOnly, summary: "获取所有角色简单信息" })
|
||||
async getSimpleRoles() {
|
||||
const roles = await this.roleService.find({
|
||||
select: {
|
||||
@@ -72,5 +72,4 @@ export class BasicUserController extends BasicController {
|
||||
});
|
||||
return this.ok(roles);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user