|
@@ -1,10 +1,13 @@
|
|
|
-import { Provide } from '@midwayjs/decorator';
|
|
|
+import { Provide, Inject } from '@midwayjs/decorator';
|
|
|
+import { ServiceError } from 'free-midway-component';
|
|
|
import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
|
import { BaseService } from 'free-midway-component';
|
|
|
import { Sign } from '../../entity/platform/sign.entity';
|
|
|
import { Match } from '../../entity/platform/match.entity';
|
|
|
import { get } from 'lodash';
|
|
|
+import { I18nService } from '../i18n.service';
|
|
|
+import { FrameErrorEnum } from '../../error/frame.error';
|
|
|
type modelType = ReturnModelType<typeof Sign>;
|
|
|
@Provide()
|
|
|
export class SignService extends BaseService<modelType> {
|
|
@@ -14,6 +17,16 @@ export class SignService extends BaseService<modelType> {
|
|
|
@InjectEntityModel(Match)
|
|
|
mModel: ReturnModelType<typeof Match>;
|
|
|
|
|
|
+ @Inject()
|
|
|
+ i18n: I18nService;
|
|
|
+
|
|
|
+ // 报名检查
|
|
|
+ async createExamine(data) {
|
|
|
+ const { user, match } = data;
|
|
|
+ const result = await this.model.findOne({ user, match }).lean();
|
|
|
+ if (result) throw new ServiceError(this.i18n.translateError(FrameErrorEnum.SERVICE_REPEAT), FrameErrorEnum.SERVICE_REPEAT);
|
|
|
+ }
|
|
|
+
|
|
|
// 列表
|
|
|
async sign(query) {
|
|
|
const { skip = 0, limit = 0, ...condition } = query;
|