mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
feat: 权限控制
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
import { CrudController } from '../../../basic/crud-controller';
|
||||
import { SettingsService } from '../service/settings-service';
|
||||
import { SettingsEntity } from '../entity/settings';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -23,53 +24,51 @@ export class SettingsController extends CrudController<SettingsService> {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
@Post('/page')
|
||||
@Post('/page', { summary: Constants.per.authOnly })
|
||||
async page(@Body(ALL) body) {
|
||||
body.query = body.query ?? {};
|
||||
body.query.userId = this.ctx.user.id;
|
||||
return super.page(body);
|
||||
}
|
||||
|
||||
@Post('/list')
|
||||
@Post('/list', { summary: Constants.per.authOnly })
|
||||
async list(@Body(ALL) body) {
|
||||
body.userId = this.ctx.user.id;
|
||||
return super.list(body);
|
||||
}
|
||||
|
||||
@Post('/add')
|
||||
@Post('/add', { summary: Constants.per.authOnly })
|
||||
async add(@Body(ALL) bean) {
|
||||
bean.userId = this.ctx.user.id;
|
||||
return super.add(bean);
|
||||
}
|
||||
|
||||
@Post('/update')
|
||||
@Post('/update', { summary: Constants.per.authOnly })
|
||||
async update(@Body(ALL) bean) {
|
||||
await this.service.checkUserId(bean.id, this.ctx.user.id);
|
||||
return super.update(bean);
|
||||
}
|
||||
@Post('/info')
|
||||
@Post('/info', { summary: Constants.per.authOnly })
|
||||
async info(@Query('id') id) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Post('/delete')
|
||||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@Post('/save')
|
||||
@Post('/save', { summary: Constants.per.authOnly })
|
||||
async save(@Body(ALL) bean: SettingsEntity) {
|
||||
await this.service.checkUserId(bean.key, this.ctx.user.id, 'userId', 'key');
|
||||
bean.userId = this.ctx.user.id;
|
||||
await this.service.save(bean);
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post('/get')
|
||||
@Post('/get', { summary: Constants.per.authOnly })
|
||||
async get(@Query('key') key: string) {
|
||||
await this.service.checkUserId(key, this.ctx.user.id, 'userId', 'key');
|
||||
const entity = await this.service.getByKey(key, this.ctx.user.id);
|
||||
return this.ok(entity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user