|
@@ -1,5 +1,5 @@
|
|
|
import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
|
|
|
-import { BaseController } from 'free-midway-component';
|
|
|
+import { BaseController, FrameworkErrorEnum, ServiceError } from 'free-midway-component';
|
|
|
import { StudioService } from '../service/studio.service';
|
|
|
import { CDTO_studio, CVO_studio, FVO_studio, QDTO_studio, QVO_studio, UDTO_studio, UVAO_studio } from '../interface/studio.interface';
|
|
|
import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
|
|
@@ -40,11 +40,19 @@ export class StudioController extends BaseController {
|
|
|
|
|
|
@Post('/:id') @Validate() @ApiResponse({ type: UVAO_studio })
|
|
|
async update(@Param('id') id: string, @Body() body: UDTO_studio) {
|
|
|
- const result = await this.service.updateOne(id, body);
|
|
|
- return result;
|
|
|
+ const data:any = await this.service.findOne({ name: body.name });
|
|
|
+ if (data) {
|
|
|
+ if (data._id === id) {
|
|
|
+ const result = await this.service.updateOne(id, body);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ throw new ServiceError('工作室名称已被占用', FrameworkErrorEnum.SERVICE_FAULT);
|
|
|
+ } else {
|
|
|
+ const result = await this.service.updateOne(id, body);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Del('/:id') @Validate()
|
|
|
async delete(@Param('id') id: string) {
|
|
|
await this.service.delete(id);
|