Files
certd/packages/ui/certd-server/src/modules/system/controller/sys-settings-controller.ts

81 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-06-25 15:30:18 +08:00
import {
ALL,
Body,
Controller,
Inject,
Post,
Provide,
Query,
} from '@midwayjs/decorator';
import { CrudController } from '../../../basic/crud-controller';
import { SysSettingsService } from '../service/sys-settings-service';
import { SysSettingsEntity } from '../entity/sys-settings';
2023-06-07 23:36:42 +08:00
/**
*/
@Provide()
@Controller('/api/sys/settings')
export class SysSettingsController extends CrudController<SysSettingsService> {
2023-06-07 23:36:42 +08:00
@Inject()
service: SysSettingsService;
2023-06-07 23:36:42 +08:00
getService() {
return this.service;
}
@Post('/page', { summary: 'sys:settings:view' })
2023-06-07 23:36:42 +08:00
async page(@Body(ALL) body) {
body.query = body.query ?? {};
body.query.userId = this.ctx.user.id;
return super.page(body);
}
@Post('/list', { summary: 'sys:settings:view' })
2023-06-07 23:36:42 +08:00
async list(@Body(ALL) body) {
body.userId = this.ctx.user.id;
return super.list(body);
}
@Post('/add', { summary: 'sys:settings:edit' })
2023-06-07 23:36:42 +08:00
async add(@Body(ALL) bean) {
bean.userId = this.ctx.user.id;
return super.add(bean);
}
@Post('/update', { summary: 'sys:settings:edit' })
2023-06-07 23:36:42 +08:00
async update(@Body(ALL) bean) {
await this.service.checkUserId(bean.id, this.ctx.user.id);
return super.update(bean);
}
@Post('/info', { summary: 'sys:settings:view' })
2023-06-07 23:36:42 +08:00
async info(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
return super.info(id);
}
@Post('/delete', { summary: 'sys:settings:edit' })
2023-06-07 23:36:42 +08:00
async delete(@Query('id') id) {
await this.service.checkUserId(id, this.ctx.user.id);
return super.delete(id);
}
@Post('/save', { summary: 'sys:settings:edit' })
async save(@Body(ALL) bean: SysSettingsEntity) {
2023-06-25 15:30:18 +08:00
await this.service.save(bean);
return this.ok({});
}
@Post('/get', { summary: 'sys:settings:view' })
2023-06-25 15:30:18 +08:00
async get(@Query('key') key: string) {
const entity = await this.service.getByKey(key);
2023-06-25 15:30:18 +08:00
return this.ok(entity);
}
// savePublicSettings
@Post('/savePublicSettings', { summary: 'sys:settings:edit' })
async savePublicSettings(@Body(ALL) body) {
await this.service.savePublicSettings(body);
return this.ok({});
}
2023-06-07 23:36:42 +08:00
}