lrf 1 éve
szülő
commit
49b4eb0a37

+ 6 - 3
src/controller/system/config.controller.ts

@@ -4,17 +4,20 @@ 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 { FrameErrorEnum } from '../../error/frame.error';
+import { I18nService } from '../../service/i18n.service';
 @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('功能暂不开放', FrameworkErrorEnum.SERVICE_FAULT);
+    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;
@@ -31,7 +34,7 @@ export class ConfigController extends BaseController {
   @Get('/:id')
   @ApiResponse({ type: FVO_config })
   async fetch(@Param('id') id: string) {
-    throw new ServiceError('功能暂不开放', FrameworkErrorEnum.SERVICE_FAULT);
+    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;

+ 2 - 0
src/error/frame.error.ts

@@ -1,6 +1,8 @@
 import { registerErrorCode } from '@midwayjs/core';
 
 export enum ErrorCode {
+  SERVICE_ERROR = '400',
+  SERVICE_CANT_USE = '400-1',
   NO_PERMISSION = '401',
   USER_NOT_FOUND = '401-1',
   BAD_PASSWORD = '401-2',

+ 2 - 0
src/locales/en_us/errors.ts

@@ -13,6 +13,8 @@ const codes = {
   '-500': 'request falut',
   '-3000': 'ElasticSearch error',
   '-3001': 'ElasticSearch error, index not found',
+  '400': 'Service encountered an error',
+  '400-1': 'Function temporarily unavailable',
   '401': 'You do not have permission for the current function!',
   '401-1': 'User not found',
   '401-2': 'Password error',

+ 2 - 0
src/locales/zh_cn/errors.ts

@@ -13,6 +13,8 @@ const codes = {
   '-500': '请求错误',
   '-3000': 'ElasticSearch发生错误',
   '-3001': 'ElasticSearch发生错误,未找到索引',
+  '400': '服务发生错误',
+  '400-1': '功能暂不开放',
   '401': '您没有当前功能的权限!',
   '401-1': '未找到用户',
   '401-2': '密码错误',