|
@@ -1,4 +1,3 @@
|
|
|
-import { CVO_match, FVO_match, QVO_match, UVAO_match } from '../../interface/platform/match.interface';
|
|
|
import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
|
|
|
import { Validate } from '@midwayjs/validate';
|
|
|
import { Controller, Inject, Get, Param, Post, Body, Del, Query, Config } from '@midwayjs/core';
|
|
@@ -38,7 +37,6 @@ export class MatchRegistrationController implements BaseController {
|
|
|
@Get('/')
|
|
|
@ApiTags('列表查询')
|
|
|
@ApiQuery({ name: 'query' })
|
|
|
- @ApiResponse({ type: QVO_match })
|
|
|
async index(@Query() query: object) {
|
|
|
const qobj = omit(query, ['skip', 'limit']);
|
|
|
const others: any = pick(query, ['skip', 'limit']);
|
|
@@ -60,17 +58,14 @@ export class MatchRegistrationController implements BaseController {
|
|
|
|
|
|
@Get('/:id')
|
|
|
@ApiTags('单查询')
|
|
|
- @ApiResponse({ type: FVO_match })
|
|
|
async fetch(@Param('id') id: number) {
|
|
|
const data = await this.service.fetch({ id });
|
|
|
- const result = new FVO_match(data);
|
|
|
- return result;
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
@Post('/', { routerName: `创建${namePrefix}` })
|
|
|
@ApiTags('创建数据')
|
|
|
@Validate()
|
|
|
- @ApiResponse({ type: CVO_match })
|
|
|
async create(@Body() data: object) {
|
|
|
const userColumns = ['user', 'user_id'];
|
|
|
let regData = omit(data, userColumns);
|
|
@@ -93,9 +88,14 @@ export class MatchRegistrationController implements BaseController {
|
|
|
}
|
|
|
returnUser = { password, account: get(user, 'account') }
|
|
|
|
|
|
- const phone = get(user, 'phone')
|
|
|
- const msg = { "账号": get(user, 'account'), "密码": password }
|
|
|
- await this.smsService.send(phone, msg)
|
|
|
+ try {
|
|
|
+ const phone = get(user, 'phone')
|
|
|
+ const msg = { "账号": get(user, 'account'), "密码": password }
|
|
|
+ await this.smsService.send(phone, msg)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('matchReg - create:发送短信发生错误')
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
const dbData = await this.userService.create(user);
|
|
|
regData = { user_id: dbData.id, ...regData };
|
|
@@ -116,10 +116,26 @@ export class MatchRegistrationController implements BaseController {
|
|
|
@Post('/:id', { routerName: `修改${namePrefix}` })
|
|
|
@ApiTags('修改数据')
|
|
|
@Validate()
|
|
|
- @ApiResponse({ type: UVAO_match })
|
|
|
async update(@Param('id') id: number, @Body() data: object) {
|
|
|
if (!id) throw new ServiceError(ErrorCode.ID_NOT_FOUND);
|
|
|
const result = await this.service.update({ id }, data);
|
|
|
+ if (get(result, 'stauts') === '-1') {
|
|
|
+
|
|
|
+ const user_id = get(result, 'user_id')
|
|
|
+ const user = await this.userService.fetch({ id: user_id })
|
|
|
+ if (!user) throw new ServiceError(ErrorCode.USER_NOT_FOUND)
|
|
|
+ const match_id = get(result, 'match_id')
|
|
|
+ const match = await this.matchService.fetch({ id: match_id })
|
|
|
+ if (!match) throw new ServiceError(ErrorCode.MATCH_NOT_FOUND)
|
|
|
+ const match_name = get(match, 'match_name')
|
|
|
+ const phone = get(user, 'phone')
|
|
|
+ const msg = `您提交的的 ${match_name} 赛事申请已被退回,请登录平台进行修改后提交`
|
|
|
+ try {
|
|
|
+ await this.smsService.send(phone, msg)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('matchReg - update:发送短信发生错误')
|
|
|
+ }
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -133,21 +149,39 @@ export class MatchRegistrationController implements BaseController {
|
|
|
}
|
|
|
|
|
|
@Get('/detail/:id')
|
|
|
- @ApiResponse({ type: FVO_match })
|
|
|
async detail(@Param('id') id: string) {
|
|
|
const data = await this.service.fetch({ id });
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
- @Get('/export/:match_id')
|
|
|
+ @Get('/view/:match_id', { routerName: '查看初赛名单结果' })
|
|
|
+ async viewOrderByScore(@Param('match_id') match_id: string) {
|
|
|
+ const query = { match_id, status: '0' }
|
|
|
+ const others = { order: { score: 'DESC' } }
|
|
|
+ const { data: list } = await this.service.query(query, others)
|
|
|
+ const match = await this.matchService.fetch({ id: match_id })
|
|
|
+ const match_name = get(match, 'name')
|
|
|
+ for (const i of list) {
|
|
|
+ const user_id = get(i, 'user_id')
|
|
|
+ const user = await this.userService.fetch({ id: user_id })
|
|
|
+ if (user) i.user_name = get(user, 'nick_name')
|
|
|
+ if (match_name) i.match_name = match_name
|
|
|
+ delete i.info;
|
|
|
+ }
|
|
|
+ return list
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Get('/export/:match_id', { routerName: `导出初赛名单` })
|
|
|
@ApiTags('导出初赛名单')
|
|
|
async exportList(@Param('match_id') match_id: string) {
|
|
|
|
|
|
const { data } = await this.service.query({ match_id, status: '0' })
|
|
|
-
|
|
|
+
|
|
|
if (data.length <= 0) throw new ServiceError(ErrorCode.MATCH_NO_PERSON_TO_EXPORT)
|
|
|
const match = await this.matchService.fetch({ id: match_id })
|
|
|
-
|
|
|
+
|
|
|
if (!match) throw new ServiceError(ErrorCode.MATCH_NOT_FOUND)
|
|
|
|
|
|
const match_name = get(match, 'name')
|