mirror of
https://github.com/certd/certd.git
synced 2026-04-14 20:40:53 +08:00
chore: plugin管理
This commit is contained in:
@@ -2,59 +2,42 @@ import { ALL, Body, Post, Query } from '@midwayjs/core';
|
||||
import { BaseController } from './base-controller.js';
|
||||
|
||||
export abstract class CrudController<T> extends BaseController {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
abstract getService<T>();
|
||||
|
||||
@Post('/page')
|
||||
async page(
|
||||
@Body(ALL)
|
||||
body
|
||||
) {
|
||||
async page(@Body(ALL) body: any) {
|
||||
const pageRet = await this.getService().page(body?.query, body?.page, body?.sort, null);
|
||||
return this.ok(pageRet);
|
||||
}
|
||||
|
||||
@Post('/list')
|
||||
async list(
|
||||
@Body(ALL)
|
||||
body
|
||||
) {
|
||||
async list(@Body(ALL) body: any) {
|
||||
const listRet = await this.getService().list(body, null, null);
|
||||
return this.ok(listRet);
|
||||
}
|
||||
|
||||
@Post('/add')
|
||||
async add(
|
||||
@Body(ALL)
|
||||
bean
|
||||
) {
|
||||
async add(@Body(ALL) bean: any) {
|
||||
delete bean.id;
|
||||
const id = await this.getService().add(bean);
|
||||
return this.ok(id);
|
||||
}
|
||||
|
||||
@Post('/info')
|
||||
async info(
|
||||
@Query('id')
|
||||
id
|
||||
) {
|
||||
async info(@Query('id') id: number) {
|
||||
const bean = await this.getService().info(id);
|
||||
return this.ok(bean);
|
||||
}
|
||||
|
||||
@Post('/update')
|
||||
async update(
|
||||
@Body(ALL)
|
||||
bean
|
||||
) {
|
||||
async update(@Body(ALL) bean: any) {
|
||||
await this.getService().update(bean);
|
||||
return this.ok(null);
|
||||
}
|
||||
|
||||
@Post('/delete')
|
||||
async delete(
|
||||
@Query('id')
|
||||
id
|
||||
) {
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.getService().delete([id]);
|
||||
return this.ok(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user