1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { Body, Controller, Del, Get, Inject, Param, Post } from '@midwayjs/decorator';
- import { BaseController, ServiceError } from 'free-midway-component';
- import { ConfigService } from '../../service/system/config.service';
- import { CDTO_config, CVO_config, FVO_config, UDTO_config, UVAO_config } from '../../interface/system/config.interface';
- import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
- import { Validate } from '@midwayjs/validate';
- import { I18nService } from '../../service/i18n.service';
- import { FrameErrorEnum } from '../../error/frame.error';
- @ApiTags(['设置表'])
- @Controller('/config')
- export class ConfigController extends BaseController {
- @Inject()
- service: ConfigService;
- @Inject()
- i18n: I18nService;
- @Post('/')
- @Validate()
- @ApiResponse({ type: CVO_config })
- async create(@Body() data: CDTO_config) {
- throw new ServiceError(this.i18n.translateError(FrameErrorEnum.SERVICE_CANT_USE), FrameErrorEnum.SERVICE_CANT_USE);
- // const dbData = await this.service.create(data);
- // const result = new CVO_config(dbData);
- // return result;
- }
- @Get('/')
- @ApiQuery({ name: 'query' })
- @ApiResponse({ type: FVO_config })
- async query() {
- const data = await this.service.getConfig();
- const result = new FVO_config(data);
- return result;
- }
- @Get('/:id')
- @ApiResponse({ type: FVO_config })
- async fetch(@Param('id') id: string) {
- throw new ServiceError(this.i18n.translateError(FrameErrorEnum.SERVICE_CANT_USE), FrameErrorEnum.SERVICE_CANT_USE);
- // const data = await this.service.fetch(id);
- // const result = new FVO_config(data);
- // return result;
- }
- @Post('/:id')
- @Validate()
- @ApiResponse({ type: UVAO_config })
- async update(@Param('id') id: string, @Body() body: UDTO_config) {
- const result = await this.service.updateOne(id, body);
- return result;
- }
- @Del('/:id')
- @Validate()
- async delete(@Param('id') id: string) {
- await this.service.delete(id);
- return 'ok';
- }
- async createMany(...args: any[]) {
- throw new Error('Method not implemented.');
- }
- async updateMany(...args: any[]) {
- throw new Error('Method not implemented.');
- }
- async deleteMany(...args: any[]) {
- throw new Error('Method not implemented.');
- }
- }
|