|
@@ -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 };
|
|
|
+ }
|
|
|
}
|