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
@@ -6,7 +6,7 @@ import { AccessController } from "../../user/pipeline/access-controller.js";
* 授权
*/
@Provide()
@Controller('/api/sys/access')
@Controller("/api/sys/access")
export class SysAccessController extends AccessController {
@Inject()
service2: AccessService;
@@ -15,10 +15,11 @@ export class SysAccessController extends AccessController {
return this.service2;
}
async getProjectUserId(permission:string){
async getProjectUserId(permission: string) {
return {
projectId:null,userId:0
}
projectId: null,
userId: 0,
};
}
getUserId() {
@@ -26,58 +27,58 @@ export class SysAccessController extends AccessController {
return 0;
}
@Post('/page', { description: 'sys:settings:view' })
@Post("/page", { description: "sys:settings:view" })
async page(@Body(ALL) body: any) {
return await super.page(body);
}
@Post('/list', { description: 'sys:settings:view' })
@Post("/list", { description: "sys:settings:view" })
async list(@Body(ALL) body: any) {
return await super.list(body);
}
@Post('/add', { description: 'sys:settings:edit' })
@Post("/add", { description: "sys:settings:edit" })
async add(@Body(ALL) bean: any) {
return await super.add(bean);
}
@Post('/update', { description: 'sys:settings:edit' })
@Post("/update", { description: "sys:settings:edit" })
async update(@Body(ALL) bean: any) {
return await super.update(bean);
}
@Post('/info', { description: 'sys:settings:view' })
async info(@Query('id') id: number) {
@Post("/info", { description: "sys:settings:view" })
async info(@Query("id") id: number) {
return await super.info(id);
}
@Post('/delete', { description: 'sys:settings:edit' })
async delete(@Query('id') id: number) {
@Post("/delete", { description: "sys:settings:edit" })
async delete(@Query("id") id: number) {
return await super.delete(id);
}
@Post('/define', { description: 'sys:settings:view' })
async define(@Query('type') type: string) {
@Post("/define", { description: "sys:settings:view" })
async define(@Query("type") type: string) {
return await super.define(type);
}
@Post('/getSecretPlain', { description: 'sys:settings:view' })
@Post("/getSecretPlain", { description: "sys:settings:view" })
async getSecretPlain(@Body(ALL) body: { id: number; key: string }) {
const value = await this.service.getById(body.id, 0);
return this.ok(value[body.key]);
}
@Post('/accessTypeDict', { description: 'sys:settings:view' })
@Post("/accessTypeDict", { description: "sys:settings:view" })
async getAccessTypeDict() {
return await super.getAccessTypeDict();
}
@Post('/simpleInfo', { description: 'sys:settings:view' })
async simpleInfo(@Query('id') id: number) {
@Post("/simpleInfo", { description: "sys:settings:view" })
async simpleInfo(@Query("id") id: number) {
return await super.simpleInfo(id);
}
@Post('/getDictByIds', { description: 'sys:settings:view' })
async getDictByIds(@Body('ids') ids: number[]) {
return await super.getDictByIds(ids);
}
@Post("/getDictByIds", { description: "sys:settings:view" })
async getDictByIds(@Body("ids") ids: number[]) {
return await super.getDictByIds(ids);
}
}
@@ -1,5 +1,5 @@
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
import { BaseController, PlusService, SysInstallInfo, SysSettingsService } from '@certd/lib-server';
import { ALL, Body, Controller, Inject, Post, Provide } from "@midwayjs/core";
import { BaseController, PlusService, SysInstallInfo, SysSettingsService } from "@certd/lib-server";
export type PreBindUserReq = {
userId: number;
@@ -10,7 +10,7 @@ export type BindUserReq = {
/**
*/
@Provide()
@Controller('/api/sys/account')
@Controller("/api/sys/account")
export class BasicController extends BaseController {
@Inject()
plusService: PlusService;
@@ -18,7 +18,7 @@ export class BasicController extends BaseController {
@Inject()
sysSettingsService: SysSettingsService;
@Post('/preBindUser', { description: 'sys:settings:edit' })
@Post("/preBindUser", { description: "sys:settings:edit" })
public async preBindUser(@Body(ALL) body: PreBindUserReq) {
// 设置缓存内容
if (body.userId == null || body.userId <= 0) {
@@ -28,7 +28,7 @@ export class BasicController extends BaseController {
return this.ok({});
}
@Post('/bindUser', { description: 'sys:settings:edit' })
@Post("/bindUser", { description: "sys:settings:edit" })
public async bindUser(@Body(ALL) body: BindUserReq) {
if (body.userId == null || body.userId <= 0) {
throw new Error("用户ID不能为空");
@@ -39,7 +39,7 @@ export class BasicController extends BaseController {
return this.ok({});
}
@Post('/unbindUser', { description: 'sys:settings:edit' })
@Post("/unbindUser", { description: "sys:settings:edit" })
public async unbindUser() {
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
installInfo.bindUserId = null;
@@ -47,7 +47,7 @@ export class BasicController extends BaseController {
return this.ok({});
}
@Post('/updateLicense', { description: 'sys:settings:edit' })
@Post("/updateLicense", { description: "sys:settings:edit" })
public async updateLicense(@Body(ALL) body: { license: string }) {
await this.plusService.updateLicense(body.license);
return this.ok(true);
@@ -3,7 +3,7 @@ import { AddonRequestHandleReq, AddonService, Constants } from "@certd/lib-serve
import { AddonController } from "../../user/addon/addon-controller.js";
@Provide()
@Controller('/api/sys/addon')
@Controller("/api/sys/addon")
export class SysAddonController extends AddonController {
@Inject()
service2: AddonService;
@@ -12,77 +12,77 @@ export class SysAddonController extends AddonController {
return this.service2;
}
async getProjectUserId(permission:string){
async getProjectUserId(permission: string) {
return {
projectId:null,userId:0 //0为系统级别
}
projectId: null,
userId: 0, //0为系统级别
};
}
getUserId() {
// checkComm();
return 0;
}
@Post('/page', { description: 'sys:settings:view' })
@Post("/page", { description: "sys:settings:view" })
async page(@Body(ALL) body: any) {
return await super.page(body);
}
@Post('/list', { description: 'sys:settings:view' })
@Post("/list", { description: "sys:settings:view" })
async list(@Body(ALL) body: any) {
return await super.list(body);
}
@Post('/add', { description: 'sys:settings:edit' })
@Post("/add", { description: "sys:settings:edit" })
async add(@Body(ALL) bean: any) {
return await super.add(bean);
}
@Post('/update', { description: 'sys:settings:edit' })
@Post("/update", { description: "sys:settings:edit" })
async update(@Body(ALL) bean: any) {
return await super.update(bean);
}
@Post('/info', { description: 'sys:settings:view' })
async info(@Query('id') id: number) {
@Post("/info", { description: "sys:settings:view" })
async info(@Query("id") id: number) {
return await super.info(id);
}
@Post('/delete', { description: 'sys:settings:edit' })
async delete(@Query('id') id: number) {
@Post("/delete", { description: "sys:settings:edit" })
async delete(@Query("id") id: number) {
return await super.delete(id);
}
@Post('/define', { description: Constants.per.authOnly })
async define(@Query('type') type: string,@Query('addonType') addonType: string) {
return await super.define(type,addonType);
@Post("/define", { description: Constants.per.authOnly })
async define(@Query("type") type: string, @Query("addonType") addonType: string) {
return await super.define(type, addonType);
}
@Post('/getTypeDict', { description: Constants.per.authOnly })
async getTypeDict(@Query('addonType') addonType: string) {
@Post("/getTypeDict", { description: Constants.per.authOnly })
async getTypeDict(@Query("addonType") addonType: string) {
return await super.getTypeDict(addonType);
}
@Post('/simpleInfo', { description: Constants.per.authOnly })
async simpleInfo(@Query('addonType') addonType: string,@Query('id') id: number) {
return await super.simpleInfo(addonType,id);
@Post("/simpleInfo", { description: Constants.per.authOnly })
async simpleInfo(@Query("addonType") addonType: string, @Query("id") id: number) {
return await super.simpleInfo(addonType, id);
}
@Post('/getDefaultId', { description: Constants.per.authOnly })
async getDefaultId(@Query('addonType') addonType: string) {
return await super.getDefaultId(addonType);
@Post("/getDefaultId", { description: Constants.per.authOnly })
async getDefaultId(@Query("addonType") addonType: string) {
return await super.getDefaultId(addonType);
}
@Post('/setDefault', { description: Constants.per.authOnly })
async setDefault(@Query('addonType') addonType: string,@Query('id') id: number) {
return await super.setDefault(addonType,id);
@Post("/setDefault", { description: Constants.per.authOnly })
async setDefault(@Query("addonType") addonType: string, @Query("id") id: number) {
return await super.setDefault(addonType, id);
}
@Post('/options', { description: Constants.per.authOnly })
async options(@Query('addonType') addonType: string) {
@Post("/options", { description: Constants.per.authOnly })
async options(@Query("addonType") addonType: string) {
return await super.options(addonType);
}
@Post('/handle', { description: Constants.per.authOnly })
@Post("/handle", { description: Constants.per.authOnly })
async handle(@Body(ALL) body: AddonRequestHandleReq) {
return await super.handle(body);
return await super.handle(body);
}
}
@@ -1,12 +1,12 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { CrudController } from '@certd/lib-server';
import { PermissionService } from '../../../modules/sys/authority/service/permission-service.js';
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { CrudController } from "@certd/lib-server";
import { PermissionService } from "../../../modules/sys/authority/service/permission-service.js";
/**
* 权限资源
*/
@Provide()
@Controller('/api/sys/authority/permission')
@Controller("/api/sys/authority/permission")
export class PermissionController extends CrudController<PermissionService> {
@Inject()
service: PermissionService;
@@ -15,7 +15,7 @@ export class PermissionController extends CrudController<PermissionService> {
return this.service;
}
@Post('/page', { description: 'sys:auth:per:view' })
@Post("/page", { description: "sys:auth:per:view" })
async page(
@Body(ALL)
body
@@ -23,7 +23,7 @@ export class PermissionController extends CrudController<PermissionService> {
return await super.page(body);
}
@Post('/add', { description: 'sys:auth:per:add' })
@Post("/add", { description: "sys:auth:per:add" })
async add(
@Body(ALL)
bean
@@ -31,22 +31,22 @@ export class PermissionController extends CrudController<PermissionService> {
return await super.add(bean);
}
@Post('/update', { description: 'sys:auth:per:edit' })
@Post("/update", { description: "sys:auth:per:edit" })
async update(
@Body(ALL)
bean
) {
return await super.update(bean);
}
@Post('/delete', { description: 'sys:auth:per:remove' })
@Post("/delete", { description: "sys:auth:per:remove" })
async delete(
@Query('id')
@Query("id")
id: number
) {
return await super.delete(id);
}
@Post('/tree', { description: 'sys:auth:per:view' })
@Post("/tree", { description: "sys:auth:per:view" })
async tree() {
const tree = await this.service.tree({});
return this.ok(tree);
@@ -1,12 +1,12 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { CrudController } from '@certd/lib-server';
import { RoleService } from '../../../modules/sys/authority/service/role-service.js';
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { CrudController } from "@certd/lib-server";
import { RoleService } from "../../../modules/sys/authority/service/role-service.js";
/**
* 系统用户
*/
@Provide()
@Controller('/api/sys/authority/role')
@Controller("/api/sys/authority/role")
export class RoleController extends CrudController<RoleService> {
@Inject()
service: RoleService;
@@ -15,7 +15,7 @@ export class RoleController extends CrudController<RoleService> {
return this.service;
}
@Post('/page', { description: 'sys:auth:role:view' })
@Post("/page", { description: "sys:auth:role:view" })
async page(
@Body(ALL)
body
@@ -23,13 +23,13 @@ export class RoleController extends CrudController<RoleService> {
return await super.page(body);
}
@Post('/list', { description: 'sys:auth:role:view' })
@Post("/list", { description: "sys:auth:role:view" })
async list() {
const ret = await this.service.find({});
return this.ok(ret);
}
@Post('/add', { description: 'sys:auth:role:add' })
@Post("/add", { description: "sys:auth:role:add" })
async add(
@Body(ALL)
bean
@@ -37,36 +37,36 @@ export class RoleController extends CrudController<RoleService> {
return await super.add(bean);
}
@Post('/update', { description: 'sys:auth:role:edit' })
@Post("/update", { description: "sys:auth:role:edit" })
async update(
@Body(ALL)
bean
) {
return await super.update(bean);
}
@Post('/delete', { description: 'sys:auth:role:remove' })
@Post("/delete", { description: "sys:auth:role:remove" })
async delete(
@Query('id')
@Query("id")
id: number
) {
if (id === 1) {
throw new Error('不能删除默认的管理员角色');
throw new Error("不能删除默认的管理员角色");
}
return await super.delete(id);
}
@Post('/getPermissionTree', { description: 'sys:auth:role:view' })
@Post("/getPermissionTree", { description: "sys:auth:role:view" })
async getPermissionTree(
@Query('id')
@Query("id")
id: number
) {
const ret = await this.service.getPermissionTreeByRoleId(id);
return this.ok(ret);
}
@Post('/getPermissionIds', { description: 'sys:auth:role:view' })
@Post("/getPermissionIds", { description: "sys:auth:role:view" })
async getPermissionIds(
@Query('id')
@Query("id")
id: number
) {
const ret = await this.service.getPermissionIdsByRoleId(id);
@@ -78,8 +78,8 @@ export class RoleController extends CrudController<RoleService> {
* @param roleId
* @param permissionIds
*/
@Post('/authz', { description: 'sys:auth:role:edit' })
async authz(@Body('roleId') roleId, @Body('permissionIds') permissionIds) {
@Post("/authz", { description: "sys:auth:role:edit" })
async authz(@Body("roleId") roleId, @Body("permissionIds") permissionIds) {
await this.service.authz(roleId, permissionIds);
return this.ok(null);
}
@@ -1,17 +1,17 @@
import {Provide, Controller, Post, Inject, Body, Query, ALL} from '@midwayjs/core';
import {UserService} from '../../../modules/sys/authority/service/user-service.js';
import {CrudController} from '@certd/lib-server';
import {RoleService} from '../../../modules/sys/authority/service/role-service.js';
import {PermissionService} from '../../../modules/sys/authority/service/permission-service.js';
import {Constants} from '@certd/lib-server';
import {In} from 'typeorm';
import {LoginService} from "../../../modules/login/service/login-service.js";
import { Provide, Controller, Post, Inject, Body, Query, ALL } from "@midwayjs/core";
import { UserService } from "../../../modules/sys/authority/service/user-service.js";
import { CrudController } from "@certd/lib-server";
import { RoleService } from "../../../modules/sys/authority/service/role-service.js";
import { PermissionService } from "../../../modules/sys/authority/service/permission-service.js";
import { Constants } from "@certd/lib-server";
import { In } from "typeorm";
import { LoginService } from "../../../modules/login/service/login-service.js";
/**
* 系统用户
*/
@Provide()
@Controller('/api/sys/authority/user')
@Controller("/api/sys/authority/user")
export class UserController extends CrudController<UserService> {
@Inject()
service: UserService;
@@ -28,8 +28,8 @@ export class UserController extends CrudController<UserService> {
return this.service;
}
@Post('/getSimpleUserByIds', {description: 'sys:auth:user:view'})
async getSimpleUserByIds(@Body('ids') ids: number[]) {
@Post("/getSimpleUserByIds", { description: "sys:auth:user:view" })
async getSimpleUserByIds(@Body("ids") ids: number[]) {
const users = await this.service.find({
select: {
id: true,
@@ -46,8 +46,7 @@ export class UserController extends CrudController<UserService> {
return this.ok(users);
}
@Post('/getSimpleUsers', {description: 'sys:auth:user:view'})
@Post("/getSimpleUsers", { description: "sys:auth:user:view" })
async getSimpleUsers() {
const users = await this.service.find({
select: {
@@ -61,10 +60,10 @@ export class UserController extends CrudController<UserService> {
return this.ok(users);
}
@Post('/page', {description: 'sys:auth:user:view'})
@Post("/page", { description: "sys:auth:user:view" })
async page(
@Body(ALL)
body
body
) {
const ret = await super.page(body);
@@ -93,32 +92,32 @@ export class UserController extends CrudController<UserService> {
return ret;
}
@Post('/add', {description: 'sys:auth:user:add'})
@Post("/add", { description: "sys:auth:user:add" })
async add(
@Body(ALL)
bean
bean
) {
return await super.add(bean);
}
@Post('/update', {description: 'sys:auth:user:edit'})
@Post("/update", { description: "sys:auth:user:edit" })
async update(
@Body(ALL)
bean
bean
) {
return await super.update(bean);
}
@Post('/delete', {description: 'sys:auth:user:remove'})
@Post("/delete", { description: "sys:auth:user:remove" })
async delete(
@Query('id')
id: number
@Query("id")
id: number
) {
if (id === 1) {
throw new Error('不能删除默认的管理员角色');
throw new Error("不能删除默认的管理员角色");
}
if (id === 3) {
throw new Error('不能删除默认的普通用户角色');
throw new Error("不能删除默认的普通用户角色");
}
return await super.delete(id);
}
@@ -126,12 +125,12 @@ export class UserController extends CrudController<UserService> {
/**
* 解除登录锁定
*/
@Post('/unlockBlock', {description: "sys:auth:user:edit"})
public async unlockBlock(@Body('id') id: number) {
const info = await this.service.info(id, ['password']);
this.loginService.clearCacheOnSuccess(info.username)
@Post("/unlockBlock", { description: "sys:auth:user:edit" })
public async unlockBlock(@Body("id") id: number) {
const info = await this.service.info(id, ["password"]);
this.loginService.clearCacheOnSuccess(info.username);
if (info.mobile) {
this.loginService.clearCacheOnSuccess(info.mobile)
this.loginService.clearCacheOnSuccess(info.mobile);
}
return this.ok(info);
}
@@ -139,17 +138,17 @@ export class UserController extends CrudController<UserService> {
/**
* 当前登录用户的个人信息
*/
@Post('/mine', {description: Constants.per.authOnly})
@Post("/mine", { description: Constants.per.authOnly })
public async mine() {
const id = this.getUserId();
const info = await this.service.info(id, ['password']);
const info = await this.service.info(id, ["password"]);
return this.ok(info);
}
/**
* 当前登录用户的权限列表
*/
@Post('/permissions', {description: Constants.per.authOnly})
@Post("/permissions", { description: Constants.per.authOnly })
public async permissions() {
const id = this.getUserId();
const permissions = await this.service.getUserPermissions(id);
@@ -159,15 +158,11 @@ export class UserController extends CrudController<UserService> {
/**
* 当前登录用户的权限树形列表
*/
@Post('/permissionTree', {description: Constants.per.authOnly})
@Post("/permissionTree", { description: Constants.per.authOnly })
public async permissionTree() {
const id = this.getUserId();
const permissions = await this.service.getUserPermissions(id);
const tree = this.permissionService.buildTree(permissions);
return this.ok(tree);
}
}
@@ -1,13 +1,13 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { CrudController } from '@certd/lib-server';
import { merge } from 'lodash-es';
import { CnameProviderService } from '../../../modules/cname/service/cname-provider-service.js';
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { CrudController } from "@certd/lib-server";
import { merge } from "lodash-es";
import { CnameProviderService } from "../../../modules/cname/service/cname-provider-service.js";
/**
* 授权
*/
@Provide()
@Controller('/api/sys/cname/provider')
@Controller("/api/sys/cname/provider")
export class CnameRecordController extends CrudController<CnameProviderService> {
@Inject()
service: CnameProviderService;
@@ -16,18 +16,18 @@ export class CnameRecordController extends CrudController<CnameProviderService>
return this.service;
}
@Post('/page', { description: 'sys:settings:view' })
@Post("/page", { description: "sys:settings:view" })
async page(@Body(ALL) body: any) {
body.query = body.query ?? {};
return await super.page(body);
}
@Post('/list', { description: 'sys:settings:view' })
@Post("/list", { description: "sys:settings:view" })
async list(@Body(ALL) body: any) {
return super.list(body);
}
@Post('/add', { description: 'sys:settings:edit' })
@Post("/add", { description: "sys:settings:edit" })
async add(@Body(ALL) bean: any) {
const def: any = {
isDefault: false,
@@ -38,36 +38,36 @@ export class CnameRecordController extends CrudController<CnameProviderService>
return super.add(bean);
}
@Post('/update', { description: 'sys:settings:edit' })
@Post("/update", { description: "sys:settings:edit" })
async update(@Body(ALL) bean: any) {
bean.userId = this.getUserId();
return super.update(bean);
}
@Post('/info', { description: 'sys:settings:view' })
async info(@Query('id') id: number) {
@Post("/info", { description: "sys:settings:view" })
async info(@Query("id") id: number) {
return super.info(id);
}
@Post('/delete', { description: 'sys:settings:edit' })
async delete(@Query('id') id: number) {
@Post("/delete", { description: "sys:settings:edit" })
async delete(@Query("id") id: number) {
return super.delete(id);
}
@Post('/deleteByIds', { description: 'sys:settings:edit' })
async deleteByIds(@Body('ids') ids: number[]) {
@Post("/deleteByIds", { description: "sys:settings:edit" })
async deleteByIds(@Body("ids") ids: number[]) {
const res = await this.service.delete(ids);
return this.ok(res);
}
@Post('/setDefault', { description: 'sys:settings:edit' })
async setDefault(@Body('id') id: number) {
@Post("/setDefault", { description: "sys:settings:edit" })
async setDefault(@Body("id") id: number) {
await this.service.setDefault(id);
return this.ok();
}
@Post('/setDisabled', { description: 'sys:settings:edit' })
async setDisabled(@Body('id') id: number, @Body('disabled') disabled: boolean) {
@Post("/setDisabled", { description: "sys:settings:edit" })
async setDisabled(@Body("id") id: number, @Body("disabled") disabled: boolean) {
await this.service.setDisabled(id, disabled);
return this.ok();
}
@@ -1,9 +1,9 @@
import { Controller, Inject, Post, Provide } from '@midwayjs/core';
import { BaseController } from '@certd/lib-server';
import { UserService } from '../../../modules/sys/authority/service/user-service.js';
import { RoleService } from '../../../modules/sys/authority/service/role-service.js';
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
import { HistoryService } from '../../../modules/pipeline/service/history-service.js';
import { Controller, Inject, Post, Provide } from "@midwayjs/core";
import { BaseController } from "@certd/lib-server";
import { UserService } from "../../../modules/sys/authority/service/user-service.js";
import { RoleService } from "../../../modules/sys/authority/service/role-service.js";
import { PipelineService } from "../../../modules/pipeline/service/pipeline-service.js";
import { HistoryService } from "../../../modules/pipeline/service/history-service.js";
export type ChartItem = {
name: string;
@@ -19,7 +19,7 @@ export type SysStatisticCount = {
/**
*/
@Provide()
@Controller('/api/sys/statistic/')
@Controller("/api/sys/statistic/")
export class SysStatisticController extends BaseController {
@Inject()
userService: UserService;
@@ -31,7 +31,7 @@ export class SysStatisticController extends BaseController {
@Inject()
historyService: HistoryService;
@Post('/count', { description: 'sys:settings:view' })
@Post("/count", { description: "sys:settings:view" })
public async count() {
const userCount = await this.userService.count();
const userRegisterCountPerDay = await this.userService.registerCountPerDay({ days: 7 });
@@ -40,7 +40,7 @@ export class SysProjectController extends CrudController<ProjectEntity> {
bean.userId = this.getUserId();
return super.add({
...bean,
userId:-1, //企业用户id固定为-1
userId: -1, //企业用户id固定为-1
adminId: bean.userId,
});
}
@@ -55,12 +55,12 @@ export class SysProjectMemberController extends CrudController<ProjectMemberEnti
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,
});
const res =await this.service.update({
const res = await this.service.update({
id: bean.id,
permission: bean.permission,
status: bean.status,
@@ -70,13 +70,13 @@ export class SysProjectMemberController extends CrudController<ProjectMemberEnti
@Post("/info", { description: "sys:settings:view" })
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);
}
@@ -86,10 +86,10 @@ export class SysProjectMemberController extends CrudController<ProjectMemberEnti
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);
}
@@ -100,14 +100,14 @@ export class SysProjectMemberController extends CrudController<ProjectMemberEnti
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,46 +1,39 @@
import { BaseController } from '@certd/lib-server';
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
import { NetTestService } from '../../../modules/sys/nettest/nettest-service.js';
import { BaseController } from "@certd/lib-server";
import { ALL, Body, Controller, Inject, Post, Provide } from "@midwayjs/core";
import { NetTestService } from "../../../modules/sys/nettest/nettest-service.js";
@Provide()
@Controller('/api/sys/nettest/')
@Controller("/api/sys/nettest/")
export class SysNetTestController extends BaseController {
@Inject()
netTestService: NetTestService;
@Post('/domainResolve', { description: 'sys:settings:view' })
@Post("/domainResolve", { description: "sys:settings:view" })
public async domainResolve(@Body(ALL) body: { domain: string }) {
const { domain } = body;
const result = await this.netTestService.domainResolve(domain);
return this.ok(result);
}
// ping
@Post('/ping', { description: 'sys:settings:view' })
@Post("/ping", { description: "sys:settings:view" })
public async ping(@Body(ALL) body: { domain: string }) {
const { domain } = body;
const result = await this.netTestService.ping(domain);
return this.ok(result);
}
// telnet
@Post('/telnet', { description: 'sys:settings:view' })
public async telnet(@Body(ALL) body: { domain: string, port: number }) {
// telnet
@Post("/telnet", { description: "sys:settings:view" })
public async telnet(@Body(ALL) body: { domain: string; port: number }) {
const { domain, port } = body;
const result = await this.netTestService.telnet(domain, port);
return this.ok(result);
}
// telnet
@Post('/serverInfo', { description: 'sys:settings:view' })
// telnet
@Post("/serverInfo", { description: "sys:settings:view" })
public async serverInfo() {
const result = await this.netTestService.serverInfo();
return this.ok(result);
}
@@ -1,17 +1,13 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { merge } from 'lodash-es';
import { CrudController } from '@certd/lib-server';
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { merge } from "lodash-es";
import { CrudController } from "@certd/lib-server";
import { PluginImportReq, PluginService } from "../../../modules/plugin/service/plugin-service.js";
import {
CommPluginConfig,
PluginConfig,
PluginConfigService
} from '../../../modules/plugin/service/plugin-config-service.js';
import { CommPluginConfig, PluginConfig, PluginConfigService } from "../../../modules/plugin/service/plugin-config-service.js";
/**
* 插件
*/
@Provide()
@Controller('/api/sys/plugin')
@Controller("/api/sys/plugin")
export class PluginController extends CrudController<PluginService> {
@Inject()
service: PluginService;
@@ -23,18 +19,18 @@ export class PluginController extends CrudController<PluginService> {
return this.service;
}
@Post('/page', { description: 'sys:settings:view' })
@Post("/page", { description: "sys:settings:view" })
async page(@Body(ALL) body: any) {
body.query = body.query ?? {};
return await super.page(body);
}
@Post('/list', { description: 'sys:settings:view' })
@Post("/list", { description: "sys:settings:view" })
async list(@Body(ALL) body: any) {
return super.list(body);
}
@Post('/add', { description: 'sys:settings:edit' })
@Post("/add", { description: "sys:settings:edit" })
async add(@Body(ALL) bean: any) {
const def: any = {
isDefault: false,
@@ -44,69 +40,68 @@ export class PluginController extends CrudController<PluginService> {
return super.add(bean);
}
@Post('/update', { description: 'sys:settings:edit' })
@Post("/update", { description: "sys:settings:edit" })
async update(@Body(ALL) bean: any) {
const res = await super.update(bean);
return res
return res;
}
@Post('/info', { description: 'sys:settings:view' })
async info(@Query('id') id: number) {
@Post("/info", { description: "sys:settings:view" })
async info(@Query("id") id: number) {
return super.info(id);
}
@Post('/delete', { description: 'sys:settings:edit' })
async delete(@Query('id') id: number) {
@Post("/delete", { description: "sys:settings:edit" })
async delete(@Query("id") id: number) {
const res = await this.service.deleteByIds([id]);
return this.ok(res);
}
@Post('/deleteByIds', { description: 'sys:settings:edit' })
async deleteByIds(@Body('ids') ids: number[]) {
@Post("/deleteByIds", { description: "sys:settings:edit" })
async deleteByIds(@Body("ids") ids: number[]) {
const res = await this.service.deleteByIds(ids);
return this.ok(res);
}
@Post('/setDisabled', { description: 'sys:settings:edit' })
@Post("/setDisabled", { description: "sys:settings:edit" })
async setDisabled(@Body(ALL) body: { id: number; name: string; type: string; disabled: boolean }) {
await this.service.setDisabled(body);
return this.ok();
}
@Post('/getCommPluginConfigs', { description: 'sys:settings:view' })
@Post("/getCommPluginConfigs", { description: "sys:settings:view" })
async getCommPluginConfigs() {
const res = await this.pluginConfigService.getCommPluginConfig();
return this.ok(res);
}
@Post('/saveCommPluginConfigs', { description: 'sys:settings:edit' })
@Post("/saveCommPluginConfigs", { description: "sys:settings:edit" })
async saveCommPluginConfigs(@Body(ALL) body: CommPluginConfig) {
const res = await this.pluginConfigService.saveCommPluginConfig(body);
return this.ok(res);
}
@Post('/getPluginByName', { description: 'sys:settings:view' })
async getPluginByName(@Body('name') name: string) {
@Post("/getPluginByName", { description: "sys:settings:view" })
async getPluginByName(@Body("name") name: string) {
const res = await this.pluginConfigService.getPluginConfig({
name: name,
type: 'builtIn'
type: "builtIn",
});
return this.ok(res);
}
@Post('/saveSetting', { description: 'sys:settings:edit' })
@Post("/saveSetting", { description: "sys:settings:edit" })
async saveSetting(@Body(ALL) body: PluginConfig) {
const res = await this.pluginConfigService.savePluginConfig(body);
return this.ok(res);
}
@Post('/import', { description: 'sys:settings:edit' })
@Post("/import", { description: "sys:settings:edit" })
async import(@Body(ALL) body: PluginImportReq) {
const res = await this.service.importPlugin(body);
return this.ok(res);
}
@Post('/export', { description: 'sys:settings:edit' })
async export(@Body('id') id: number) {
@Post("/export", { description: "sys:settings:edit" })
async export(@Body("id") id: number) {
const res = await this.service.exportPlugin(id);
return this.ok(res);
}
@@ -1,11 +1,11 @@
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
import { BaseController, PlusService, SysInstallInfo, SysSettingsService } from '@certd/lib-server';
import { logger } from '@certd/basic';
import { ALL, Body, Controller, Inject, Post, Provide } from "@midwayjs/core";
import { BaseController, PlusService, SysInstallInfo, SysSettingsService } from "@certd/lib-server";
import { logger } from "@certd/basic";
/**
*/
@Provide()
@Controller('/api/sys/plus')
@Controller("/api/sys/plus")
export class SysPlusController extends BaseController {
@Inject()
sysSettingsService: SysSettingsService;
@@ -13,7 +13,7 @@ export class SysPlusController extends BaseController {
@Inject()
plusService: PlusService;
@Post('/active', { description: 'sys:settings:edit' })
@Post("/active", { description: "sys:settings:edit" })
async active(@Body(ALL) body) {
const { code, inviteCode } = body;
@@ -21,33 +21,32 @@ export class SysPlusController extends BaseController {
return this.ok(true);
}
@Post('/bindUrl', { description: 'sys:settings:edit' })
async bindUrl(@Body(ALL) body: { url: string ,url2?:string }) {
const { url,url2 } = body;
@Post("/bindUrl", { description: "sys:settings:edit" })
async bindUrl(@Body(ALL) body: { url: string; url2?: string }) {
const { url, url2 } = body;
await this.plusService.register();
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
await this.plusService.bindUrl(url,url2);
await this.plusService.bindUrl(url, url2);
installInfo.bindUrl = url;
installInfo.bindUrl2 = url2;
await this.sysSettingsService.saveSetting(installInfo);
//重新验证vip
try{
try {
await this.plusService.verify();
}catch(e){
} catch (e) {
logger.error(`验证配置失败:${e}`);
}
return this.ok(true);
}
@Post('/getVipTrial', { description: 'sys:settings:edit' })
async getVipTrial(@Body("vipType") vipType?:string) {
@Post("/getVipTrial", { description: "sys:settings:edit" })
async getVipTrial(@Body("vipType") vipType?: string) {
const res = await this.plusService.getVipTrial(vipType);
return this.ok(res);
}
@Post('/getTodayVipOrderCount', { description: 'sys:settings:edit' })
@Post("/getTodayVipOrderCount", { description: "sys:settings:edit" })
async getTodayVipOrderCount() {
const res = await this.plusService.getTodayOrderCount();
return this.ok(res);
@@ -3,21 +3,18 @@ import { BaseController, SysSafeSetting } from "@certd/lib-server";
import { cloneDeep } from "lodash-es";
import { SafeService } from "../../../modules/sys/settings/safe-service.js";
/**
*/
@Provide()
@Controller('/api/sys/settings/safe')
@Controller("/api/sys/settings/safe")
export class SysSettingsController extends BaseController {
@Inject()
safeService: SafeService;
@Post("/get", { description: "sys:settings:view" })
async safeGet() {
const res = await this.safeService.getSafeSetting()
const clone:SysSafeSetting = cloneDeep(res);
const res = await this.safeService.getSafeSetting();
const clone: SysSafeSetting = cloneDeep(res);
delete clone.hidden?.openPassword;
return this.ok(clone);
}
@@ -1,14 +1,5 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query, RequestIP } from "@midwayjs/core";
import {
addonRegistry,
AddonService,
CrudController,
SysPrivateSettings,
SysPublicSettings,
SysSafeSetting,
SysSettingsEntity,
SysSettingsService
} from "@certd/lib-server";
import { addonRegistry, AddonService, CrudController, SysPrivateSettings, SysPublicSettings, SysSafeSetting, SysSettingsEntity, SysSettingsService } from "@certd/lib-server";
import { cloneDeep, merge } from "lodash-es";
import { PipelineService } from "../../../modules/pipeline/service/pipeline-service.js";
import { UserSettingsService } from "../../../modules/mine/service/user-settings-service.js";
@@ -17,11 +8,10 @@ import { http, logger, utils } from "@certd/basic";
import { CodeService } from "../../../modules/basic/service/code-service.js";
import { SmsServiceFactory } from "../../../modules/basic/sms/factory.js";
/**
*/
@Provide()
@Controller('/api/sys/settings')
@Controller("/api/sys/settings")
export class SysSettingsController extends CrudController<SysSettingsService> {
@Inject()
service: SysSettingsService;
@@ -31,84 +21,84 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
pipelineService: PipelineService;
@Inject()
codeService: CodeService;
@Inject()
@Inject()
addonService: AddonService;
getService() {
return this.service;
}
@Post('/page', { description: 'sys:settings:view' })
@Post("/page", { description: "sys:settings:view" })
async page(@Body(ALL) body) {
return super.page(body);
}
@Post('/list', { description: 'sys:settings:view' })
@Post("/list", { description: "sys:settings:view" })
async list(@Body(ALL) body) {
return super.list(body);
}
@Post('/add', { description: 'sys:settings:edit' })
@Post("/add", { description: "sys:settings:edit" })
async add(@Body(ALL) bean) {
return super.add(bean);
}
@Post('/update', { description: 'sys:settings:edit' })
@Post("/update", { description: "sys:settings:edit" })
async update(@Body(ALL) bean) {
await this.service.checkUserId(bean.id, this.getUserId());
return super.update(bean);
}
@Post('/info', { description: 'sys:settings:view' })
async info(@Query('id') id: number) {
@Post("/info", { description: "sys:settings:view" })
async info(@Query("id") id: number) {
await this.service.checkUserId(id, this.getUserId());
return super.info(id);
}
@Post('/delete', { description: 'sys:settings:edit' })
async delete(@Query('id') id: number) {
@Post("/delete", { description: "sys:settings:edit" })
async delete(@Query("id") id: number) {
await this.service.checkUserId(id, this.getUserId());
return super.delete(id);
}
@Post('/save', { description: 'sys:settings:edit' })
@Post("/save", { description: "sys:settings:edit" })
async save(@Body(ALL) bean: SysSettingsEntity) {
await this.service.save(bean);
return this.ok({});
}
@Post('/get', { description: 'sys:settings:view' })
async get(@Query('key') key: string) {
@Post("/get", { description: "sys:settings:view" })
async get(@Query("key") key: string) {
const entity = await this.service.getByKey(key);
return this.ok(entity);
}
// savePublicSettings
@Post('/getEmailSettings', { description: 'sys:settings:view' })
@Post("/getEmailSettings", { description: "sys:settings:view" })
async getEmailSettings(@Body(ALL) body) {
const conf = await getEmailSettings(this.service, this.userSettingsService);
return this.ok(conf);
}
@Post('/getEmailTemplates', { description: 'sys:settings:view' })
@Post("/getEmailTemplates", { description: "sys:settings:view" })
async getEmailTemplates(@Body(ALL) body) {
const conf = await getEmailSettings(this.service, this.userSettingsService);
const templates = conf.templates || {}
const templates = conf.templates || {};
const emailTemplateProviders = await this.addonService.getDefineList("emailTemplate")
const emailTemplateProviders = await this.addonService.getDefineList("emailTemplate");
const proviers = []
const proviers = [];
for (const item of emailTemplateProviders) {
const templateConf = templates[item.name] || {}
const templateConf = templates[item.name] || {};
proviers.push({
name: item.name,
title: item.title,
addonId : templateConf.addonId,
})
addonId: templateConf.addonId,
});
}
return this.ok(proviers);
}
@Post('/saveEmailSettings', { description: 'sys:settings:edit' })
@Post("/saveEmailSettings", { description: "sys:settings:edit" })
async saveEmailSettings(@Body(ALL) body) {
const conf = await getEmailSettings(this.service, this.userSettingsService);
merge(conf, body);
@@ -116,7 +106,7 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
return this.ok(conf);
}
@Post('/getSysSettings', { description: 'sys:settings:view' })
@Post("/getSysSettings", { description: "sys:settings:view" })
async getSysSettings() {
const publicSettings = await this.service.getPublicSettings();
let privateSettings = await this.service.getPrivateSettings();
@@ -125,7 +115,7 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
}
// savePublicSettings
@Post('/saveSysSettings', { description: 'sys:settings:edit' })
@Post("/saveSysSettings", { description: "sys:settings:edit" })
async saveSysSettings(@Body(ALL) body: { public: SysPublicSettings; private: SysPrivateSettings }) {
const publicSettings = await this.service.getPublicSettings();
const privateSettings = await this.service.getPrivateSettings();
@@ -136,21 +126,21 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
return this.ok({});
}
@Post('/stopOtherUserTimer', { description: 'sys:settings:edit' })
@Post("/stopOtherUserTimer", { description: "sys:settings:edit" })
async stopOtherUserTimer(@Body(ALL) body) {
await this.pipelineService.stopOtherUserPipeline(1);
return this.ok({});
}
@Post('/testProxy', { description: 'sys:settings:edit' })
@Post("/testProxy", { description: "sys:settings:edit" })
async testProxy(@Body(ALL) body) {
const google = 'https://www.google.com/';
const baidu = 'https://www.baidu.com/';
const google = "https://www.google.com/";
const baidu = "https://www.baidu.com/";
let googleRes = false;
try {
await http.request({
url: google,
method: 'GET',
method: "GET",
timeout: 5000,
logRes: false,
logParams: false,
@@ -158,13 +148,13 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
googleRes = true;
} catch (e) {
googleRes = e.message;
logger.info('test google error:', e);
logger.info("test google error:", e);
}
let baiduRes = false;
try {
await http.request({
url: baidu,
method: 'GET',
method: "GET",
timeout: 5000,
logRes: false,
logParams: false,
@@ -172,7 +162,7 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
baiduRes = true;
} catch (e) {
baiduRes = e.message;
logger.info('test baidu error:', e);
logger.info("test baidu error:", e);
}
return this.ok({
google: googleRes,
@@ -180,51 +170,48 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
});
}
@Post('/testSms', { description: 'sys:settings:edit' })
@Post("/testSms", { description: "sys:settings:edit" })
async testSms(@Body(ALL) body) {
await this.codeService.sendSmsCode(body.phoneCode, body.mobile );
await this.codeService.sendSmsCode(body.phoneCode, body.mobile);
return this.ok({});
}
@Post('/getSmsTypeDefine', { description: 'sys:settings:view' })
async getSmsTypeDefine(@Body('type') type: string) {
const define =await SmsServiceFactory.getDefine(type);
@Post("/getSmsTypeDefine", { description: "sys:settings:view" })
async getSmsTypeDefine(@Body("type") type: string) {
const define = await SmsServiceFactory.getDefine(type);
return this.ok(define);
}
@Post("/safe/get", { description: "sys:settings:view" })
async safeGet() {
const res = await this.service.getSetting<SysSafeSetting>(SysSafeSetting);
const clone:SysSafeSetting = cloneDeep(res);
const clone: SysSafeSetting = cloneDeep(res);
delete clone.hidden?.openPassword;
return this.ok(clone);
}
@Post("/safe/save", { description: "sys:settings:edit" })
async safeSave(@Body(ALL) body: any) {
if(body.hidden.openPassword){
if (body.hidden.openPassword) {
body.hidden.openPassword = utils.hash.md5(body.hidden.openPassword);
}
const blankSetting = new SysSafeSetting()
const blankSetting = new SysSafeSetting();
const setting = await this.service.getSetting<SysSafeSetting>(SysSafeSetting);
const newSetting = merge(blankSetting,cloneDeep(setting), body);
if(newSetting.hidden?.enabled && !newSetting.hidden?.openPassword){
throw new Error("首次设置需要填写解锁密码")
const newSetting = merge(blankSetting, cloneDeep(setting), body);
if (newSetting.hidden?.enabled && !newSetting.hidden?.openPassword) {
throw new Error("首次设置需要填写解锁密码");
}
await this.service.saveSetting(blankSetting);
return this.ok({});
}
@Post("/captchaTest", { description: "sys:settings:edit" })
async captchaTest(@Body(ALL) body: any,@RequestIP() remoteIp: string) {
await this.codeService.checkCaptcha(body,{remoteIp});
async captchaTest(@Body(ALL) body: any, @RequestIP() remoteIp: string) {
await this.codeService.checkCaptcha(body, { remoteIp });
return this.ok({});
}
@Post('/oauth/providers', { description: 'sys:settings:view' })
@Post("/oauth/providers", { description: "sys:settings:view" })
async oauthProviders() {
const list = await addonRegistry.getDefineList("oauth");
return this.ok(list);