chore: plugin管理

This commit is contained in:
xiaojunnuo
2024-10-13 01:27:08 +08:00
parent 6f8fe62087
commit ccfe72a0d9
29 changed files with 729 additions and 163 deletions

View File

@@ -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);
}