zs 1 rok temu
rodzic
commit
6c07c0f40c

+ 3 - 0
src/controller/platform/demand.controller.ts

@@ -31,6 +31,7 @@ export class DemandController extends BaseController {
     const total = await this.service.count(filter);
     return { data, total };
   }
+
   @Get('/list')
   async list(@Query() filter) {
     const list = await this.service.list(filter);
@@ -46,12 +47,14 @@ export class DemandController extends BaseController {
     const result = new FVO_demand(data);
     return result;
   }
+
   @Get('/detail/:id')
   @ApiResponse({ type: FVO_demand })
   async detail(@Param('id') id: string) {
     const data = await this.service.detail(id);
     return data;
   }
+
   @Post('/:id')
   @Validate()
   @ApiResponse({ type: UVAO_demand })

+ 7 - 0
src/controller/platform/match.controller.ts

@@ -40,6 +40,13 @@ export class MatchController extends BaseController {
     return result;
   }
 
+  @Get('/detail/:id')
+  @ApiResponse({ type: FVO_match })
+  async detail(@Param('id') id: string) {
+    const data = await this.service.detail(id);
+    return data;
+  }
+
   @Post('/:id')
   @Validate()
   @ApiResponse({ type: UVAO_match })

+ 1 - 0
src/controller/platform/news.controller.ts

@@ -18,6 +18,7 @@ export class NewsController extends BaseController {
     const result = new CVO_news(dbData);
     return result;
   }
+
   @Get('/')
   @ApiQuery({ name: 'query' })
   @ApiResponse({ type: QVO_news })

+ 1 - 0
src/controller/platform/project.controller.ts

@@ -47,6 +47,7 @@ export class ProjectController extends BaseController {
     const result = new FVO_project(data);
     return result;
   }
+
   @Get('/detail/:id')
   @ApiResponse({ type: FVO_project })
   async detail(@Param('id') id: string) {

+ 18 - 0
src/service/platform/match.service.ts

@@ -3,9 +3,27 @@ import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
 import { BaseService } from 'free-midway-component';
 import { Match } from '../../entity/platform/match.entity';
+import { Collection } from 'mongoose';
+import { get } from 'lodash';
 type modelType = ReturnModelType<typeof Match>;
 @Provide()
 export class MatchService extends BaseService<modelType> {
   @InjectEntityModel(Match)
   model: modelType;
+
+  @InjectEntityModel(Collection)
+  cModel: ReturnModelType<typeof Collection>;
+
+  // 比赛详情
+  async detail(id) {
+    const user = this.ctx.user;
+    const data = { userInfo: {}, is_collection: false };
+    const arr = await this.model.findById(id).lean();
+    if (arr && get(arr, '_id')) {
+      // 查询是否收藏该比赛
+      const collection = await this.cModel.findOne({ user: user._id, source: arr._id }).lean();
+      if (collection) data.is_collection = true;
+    }
+    return { ...arr, ...data };
+  }
 }