zs 1 год назад
Родитель
Сommit
aa4c17cc08

+ 68 - 0
src/controller/platform/sign.controller.ts

@@ -0,0 +1,68 @@
+import { Body, Controller, Del, Get, Inject, Param, Post, Query } from '@midwayjs/decorator';
+import { BaseController } from 'free-midway-component';
+import { SignService } from '../../service/platform/sign.service';
+import { CDTO_sign, CVO_sign, FVO_sign, QDTO_sign, QVO_sign, UDTO_sign, UVAO_sign } from '../../interface/platform/sign.interface';
+import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { Validate } from '@midwayjs/validate';
+@ApiTags(['赛事报名表'])
+@Controller('/sign')
+export class SignController extends BaseController {
+  @Inject()
+  service: SignService;
+
+  @Post('/')
+  @Validate()
+  @ApiResponse({ type: CVO_sign })
+  async create(@Body() data: CDTO_sign) {
+    const dbData = await this.service.create(data);
+    const result = new CVO_sign(dbData);
+    return result;
+  }
+  @Get('/')
+  @ApiQuery({ name: 'query' })
+  @ApiResponse({ type: QVO_sign })
+  async query(@Query() filter: QDTO_sign, @Query('skip') skip: number, @Query('limit') limit: number) {
+    const list = await this.service.query(filter, { skip, limit });
+    const data = [];
+    for (const i of list) {
+      const newData = new QVO_sign(i);
+      data.push(newData);
+    }
+    const total = await this.service.count(filter);
+    return { data, total };
+  }
+
+  @Get('/:id')
+  @ApiResponse({ type: FVO_sign })
+  async fetch(@Param('id') id: string) {
+    const data = await this.service.fetch(id);
+    const result = new FVO_sign(data);
+    return result;
+  }
+
+  @Post('/:id')
+  @Validate()
+  @ApiResponse({ type: UVAO_sign })
+  async update(@Param('id') id: string, @Body() body: UDTO_sign) {
+    const result = await this.service.updateOne(id, body);
+    return result;
+  }
+
+  @Del('/:id')
+  @Validate()
+  async delete(@Param('id') id: string) {
+    await this.service.delete(id);
+    return 'ok';
+  }
+  async createMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async updateMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+
+  async deleteMany(...args: any[]) {
+    throw new Error('Method not implemented.');
+  }
+}

+ 2 - 2
src/entity/platform/match.entity.ts

@@ -16,7 +16,7 @@ export class Match extends BaseModel {
   time: Array<any>;
   @prop({ required: false, index: false, zh: '奖金' })
   money: string;
-  @prop({ required: false, index: false, zh: '赛事规则' })
+  @prop({ required: false, index: false, zh: '赛事规则', default: {} })
   rules: object;
   @prop({ required: false, index: false, zh: '简介' })
   brief: string;
@@ -26,6 +26,6 @@ export class Match extends BaseModel {
   match_status: string;
   @prop({ required: false, index: true, zh: '是否公开', default: '1' })
   is_use: string;
-  @prop({ required: false, index: true, zh: '状态' , default: '0'})
+  @prop({ required: false, index: true, zh: '状态', default: '0' })
   status: string;
 }

+ 25 - 0
src/entity/platform/sign.entity.ts

@@ -0,0 +1,25 @@
+import { modelOptions, prop } from '@typegoose/typegoose';
+import { BaseModel } from 'free-midway-component';
+@modelOptions({
+  schemaOptions: { collection: 'sign' },
+})
+export class Sign extends BaseModel {
+  @prop({ required: false, index: true, zh: '平台用户id' })
+  user: string;
+  @prop({ required: false, index: true, zh: '赛事id' })
+  match: string;
+  @prop({ required: false, index: true, zh: '姓名' })
+  name: string;
+  @prop({ required: false, index: false, zh: '电话号' })
+  phone: string;
+  @prop({ required: false, index: false, zh: '证件类型' })
+  cardType: string;
+  @prop({ required: false, index: false, zh: '证件号码' })
+  card: string;
+  @prop({ required: false, index: false, zh: '微信/QQ' })
+  communication: string;
+  @prop({ required: false, index: false, zh: '电子邮箱' })
+  email: string;
+  @prop({ required: false, index: false, zh: '备注' })
+  remark: string;
+}

+ 107 - 0
src/interface/platform/sign.interface.ts

@@ -0,0 +1,107 @@
+import { Rule, RuleType } from '@midwayjs/validate';
+import { ApiProperty } from '@midwayjs/swagger';
+import { SearchBase } from 'free-midway-component';
+import get = require('lodash/get');
+const dealVO = (cla, data) => {
+  for (const key in cla) {
+    const val = get(data, key);
+    if (val || val === 0) cla[key] = val;
+  }
+};
+export class FVO_sign {
+  constructor(data: object) {
+    dealVO(this, data);
+  }
+  @ApiProperty({ description: '数据id' })
+  _id: string = undefined;
+  @ApiProperty({ description: '平台用户id' })
+  'user': string = undefined;
+  @ApiProperty({ description: '赛事id' })
+  'match': string = undefined;
+  @ApiProperty({ description: '姓名' })
+  'name': string = undefined;
+  @ApiProperty({ description: '电话号' })
+  'phone': string = undefined;
+  @ApiProperty({ description: '证件类型' })
+  'cardType': string = undefined;
+  @ApiProperty({ description: '证件号码' })
+  'card': string = undefined;
+  @ApiProperty({ description: '微信/QQ' })
+  'communication': string = undefined;
+  @ApiProperty({ description: '电子邮箱' })
+  'email': string = undefined;
+  @ApiProperty({ description: '备注' })
+  'remark': string = undefined;
+}
+
+export class QDTO_sign extends SearchBase {
+  constructor() {
+    const like_prop = [];
+    const props = ['user', 'match', 'name'];
+    const mapping = [];
+    super({ like_prop, props, mapping });
+  }
+  @ApiProperty({ description: '平台用户id' })
+  'user': string = undefined;
+  @ApiProperty({ description: '赛事id' })
+  'match': string = undefined;
+  @ApiProperty({ description: '姓名' })
+  'name': string = undefined;
+}
+
+export class QVO_sign extends FVO_sign {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class CDTO_sign {
+  @ApiProperty({ description: '平台用户id' })
+  @Rule(RuleType['string']().empty(''))
+  'user': string = undefined;
+  @ApiProperty({ description: '赛事id' })
+  @Rule(RuleType['string']().empty(''))
+  'match': string = undefined;
+  @ApiProperty({ description: '姓名' })
+  @Rule(RuleType['string']().empty(''))
+  'name': string = undefined;
+  @ApiProperty({ description: '电话号' })
+  @Rule(RuleType['string']().empty(''))
+  'phone': string = undefined;
+  @ApiProperty({ description: '证件类型' })
+  @Rule(RuleType['string']().empty(''))
+  'cardType': string = undefined;
+  @ApiProperty({ description: '证件号码' })
+  @Rule(RuleType['string']().empty(''))
+  'card': string = undefined;
+  @ApiProperty({ description: '微信/QQ' })
+  @Rule(RuleType['string']().empty(''))
+  'communication': string = undefined;
+  @ApiProperty({ description: '电子邮箱' })
+  @Rule(RuleType['string']().empty(''))
+  'email': string = undefined;
+  @ApiProperty({ description: '备注' })
+  @Rule(RuleType['string']().empty(''))
+  'remark': string = undefined;
+}
+
+export class CVO_sign extends FVO_sign {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}
+
+export class UDTO_sign extends CDTO_sign {
+  @ApiProperty({ description: '数据id' })
+  @Rule(RuleType['string']().empty(''))
+  _id: string = undefined;
+}
+
+export class UVAO_sign extends FVO_sign {
+  constructor(data: object) {
+    super(data);
+    dealVO(this, data);
+  }
+}

+ 11 - 0
src/service/platform/sign.service.ts

@@ -0,0 +1,11 @@
+import { Provide } from '@midwayjs/decorator';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { BaseService } from 'free-midway-component';
+import { Sign } from '../../entity/platform/sign.entity';
+type modelType = ReturnModelType<typeof Sign>;
+@Provide()
+export class SignService extends BaseService<modelType> {
+  @InjectEntityModel(Sign)
+  model: modelType;
+}