zs před 1 rokem
rodič
revize
1c00ac0f1c

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

@@ -32,6 +32,12 @@ export class SignController extends BaseController {
     return { data, total };
   }
 
+  @Get('/sign')
+  async sign(@Query() filter) {
+    const list = await this.service.sign(filter);
+    return list;
+  }
+
   @Get('/:id')
   @ApiResponse({ type: FVO_sign })
   async fetch(@Param('id') id: string) {

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

@@ -3,9 +3,41 @@ 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';
 type modelType = ReturnModelType<typeof Sign>;
 @Provide()
 export class SignService extends BaseService<modelType> {
   @InjectEntityModel(Sign)
   model: modelType;
+
+  @InjectEntityModel(Match)
+  mModel: ReturnModelType<typeof Match>;
+
+  // 列表
+  async sign(query) {
+    const { skip = 0, limit = 0, ...condition } = query;
+    const list = await this.model.find(condition).skip(skip).limit(limit).lean();
+    const data = [];
+    for (const val of list) {
+      if (get(val, 'match')) {
+        // 查询需求发布者
+        const matchInfo = await this.mModel.findById(val.match).lean();
+        if (matchInfo) {
+          data.push({
+            _id: get(val, '_id'),
+            match: get(val, 'match'),
+            money: get(matchInfo, 'money'),
+            match_name: get(matchInfo, 'name'),
+            match_time: get(matchInfo, 'time'),
+            organization: get(matchInfo, 'organization'),
+            time: get(val, 'time'),
+            status: get(matchInfo, 'match_status'),
+          });
+        }
+      }
+    }
+    const total = await this.model.count(condition);
+    return { data, total };
+  }
 }