config.controller.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {
  2. Body,
  3. Controller,
  4. Del,
  5. Get,
  6. Inject,
  7. Param,
  8. Post,
  9. } from '@midwayjs/core';
  10. import { ConfigService } from '../../service/system/config.service';
  11. import { RF } from '../../response/CustomerResponse';
  12. import { ServiceError } from '../../error/CustomerError.error';
  13. import { ErrorCode } from '../../error/Codes';
  14. @Controller('/config')
  15. export class ConfigController {
  16. @Inject()
  17. service: ConfigService;
  18. @Post('/')
  19. async create() {
  20. throw new ServiceError(ErrorCode.INTERFACE_NOT_OPEN);
  21. }
  22. @Get('/')
  23. async query() {
  24. const result = await this.service.getConfig();
  25. return RF.success(result);
  26. }
  27. @Get('/:id')
  28. async fetch(@Param('id') id: number) {
  29. throw new ServiceError(ErrorCode.INTERFACE_NOT_OPEN);
  30. }
  31. @Post('/:id')
  32. async update(@Param('id') id: number, @Body() body) {
  33. const result = await this.service.update({ id }, body);
  34. return RF.success(result)
  35. }
  36. @Del('/:id')
  37. async delete(@Param('id') id: number) {
  38. throw new ServiceError(ErrorCode.INTERFACE_NOT_OPEN);
  39. }
  40. }