|
@@ -1,11 +1,25 @@
|
|
|
import { Provide } from '@midwayjs/decorator';
|
|
|
import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
|
-import { BaseService } from 'free-midway-component';
|
|
|
+import { BaseService, FrameworkErrorEnum, ServiceError } from 'free-midway-component';
|
|
|
import { Scientistsettle } from '../entity/scientistsettle.entity';
|
|
|
type modelType = ReturnModelType<typeof Scientistsettle>;
|
|
|
@Provide()
|
|
|
export class ScientistsettleService extends BaseService<modelType> {
|
|
|
@InjectEntityModel(Scientistsettle)
|
|
|
model: modelType;
|
|
|
+ async create(body) {
|
|
|
+ const data = await this.model.findOne({ studio_id: body.studio_id });
|
|
|
+ if (data) {
|
|
|
+ if (data.user_id === body.user_id) {
|
|
|
+ throw new ServiceError('已有入驻数据,不可重复入驻', FrameworkErrorEnum.SERVICE_FAULT);
|
|
|
+ } else {
|
|
|
+ const res = await this.model.create(body);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const res = await this.model.create(body);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|