zs hace 8 meses
padre
commit
b614ddd5de

+ 20 - 7
src/controller/platform/collection.controller.ts

@@ -24,6 +24,18 @@ export class CollectionController implements BaseController {
     return result;
   }
 
+  @Get('/list')
+  async list(@Query() query: object) {
+    const qobj = omit(query, ['skip', 'limit']);
+    const others = pick(query, ['skip', 'limit']);
+    const { data, total } = await this.service.query(qobj, others);
+    const list = [];
+    for (const i of data) {
+      list.push(await this.service.fillScource(i));
+    }
+    return { data: list, total };
+  }
+
   @Get('/:id')
   @ApiTags('单查询')
   @ApiResponse({ type: FVO_collection })
@@ -43,6 +55,14 @@ export class CollectionController implements BaseController {
     return result;
   }
 
+  @Post('/cancel')
+  @Validate()
+  @ApiResponse({ type: CVO_collection })
+  async cancel(@Body() data: CDTO_collection) {
+    await this.service.cancel(data);
+    return 'ok';
+  }
+
   @Post('/:id', { routerName: `修改${namePrefix}` })
   @ApiTags('修改数据')
   @Validate()
@@ -61,11 +81,4 @@ export class CollectionController implements BaseController {
     const result = await this.service.delete({ id });
     return result;
   }
-  @Post('/cancel')
-  @Validate()
-  @ApiResponse({ type: CVO_collection })
-  async cancel(@Body() data: CDTO_collection) {
-    await this.service.cancel(data);
-    return 'ok';
-  }
 }

+ 2 - 1
src/controller/platform/match.controller.ts

@@ -21,7 +21,8 @@ export class MatchController implements BaseController {
   @ApiResponse({ type: QVO_match })
   async index(@Query() query: object) {
     const qobj = omit(query, ['skip', 'limit']);
-    const others = pick(query, ['skip', 'limit']);
+    const others: any = pick(query, ['skip', 'limit']);
+    others.order = { order_num: 'ASC' };
     const result = await this.service.query(qobj, others);
     return result;
   }

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

@@ -19,7 +19,8 @@ export class NewsController implements BaseController {
   @ApiResponse({ type: QVO_news })
   async index(@Query() query: object) {
     const qobj = omit(query, ['skip', 'limit']);
-    const others = pick(query, ['skip', 'limit']);
+    const others: any = pick(query, ['skip', 'limit']);
+    others.order = { order_num: 'ASC' };
     const result = await this.service.query(qobj, others);
     return result;
   }

+ 4 - 0
src/entity/platform/match.entity.ts

@@ -39,6 +39,10 @@ export class Match extends BaseModel {
   match_status: string;
   @Column({ type: 'character varying', nullable: true, comment: '是否公开', default: '0' })
   is_use: string;
+  @Column({ type: 'character varying', nullable: true, comment: '是否在首页显示', default: '1' })
+  is_show: string;
+  @Column({ type: 'integer', nullable: true, comment: '显示顺序' })
+  order_num: number;
   @Column({ type: 'character varying', nullable: true, comment: '状态', default: '0' })
   status: string;
 }

+ 4 - 0
src/entity/platform/news.entity.ts

@@ -24,6 +24,10 @@ export class News extends BaseModel {
   type: string;
   @Column({ type: 'character varying', nullable: true, comment: '是否使用', default: '0' })
   is_use: string;
+  @Column({ type: 'character varying', nullable: true, comment: '是否在首页显示', default: '1' })
+  is_show: string;
+  @Column({ type: 'integer', nullable: true, comment: '显示顺序' })
+  order_num: number;
   @Column({ type: 'character varying', nullable: true, comment: '状态', default: '0' })
   status: string;
 }

+ 4 - 4
src/interface/platform/collection.interface.ts

@@ -10,7 +10,7 @@ export class FVO_collection {
   @ApiProperty({ description: '平台用户id' })
   'user': number = undefined;
   @ApiProperty({ description: '来源id' })
-  'source': string = undefined;
+  'source': number = undefined;
   @ApiProperty({ description: '类型' })
   'type': string = undefined;
   @ApiProperty({ description: '收藏时间' })
@@ -21,7 +21,7 @@ export class QDTO_collection {
   @ApiProperty({ description: '平台用户id' })
   'user': number = undefined;
   @ApiProperty({ description: '来源id' })
-  'source': string = undefined;
+  'source': number = undefined;
   @ApiProperty({ description: '类型' })
   'type': string = undefined;
 }
@@ -38,8 +38,8 @@ export class CDTO_collection {
   @Rule(RuleType['number']().empty(''))
   'user': number = undefined;
   @ApiProperty({ description: '来源id' })
-  @Rule(RuleType['string']().empty(''))
-  'source': string = undefined;
+  @Rule(RuleType['number']().empty(''))
+  'source': number = undefined;
   @ApiProperty({ description: '类型' })
   @Rule(RuleType['string']().empty(''))
   'type': string = undefined;

+ 14 - 0
src/interface/platform/match.interface.ts

@@ -44,6 +44,10 @@ export class FVO_match {
   'match_status': string = undefined;
   @ApiProperty({ description: '是否公开' })
   'is_use': string = undefined;
+  @ApiProperty({ description: '是否在首页显示' })
+  'is_show': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -73,6 +77,10 @@ export class QDTO_match extends SearchBase {
   'match_status': string = undefined;
   @ApiProperty({ description: '是否公开' })
   'is_use': string = undefined;
+  @ApiProperty({ description: '是否在首页显示' })
+  'is_show': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -139,6 +147,12 @@ export class CDTO_match {
   @ApiProperty({ description: '是否公开' })
   @Rule(RuleType['string']().empty(''))
   'is_use': string = undefined;
+  @ApiProperty({ description: '是否在首页显示' })
+  @Rule(RuleType['string']().empty(''))
+  'is_show': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  @Rule(RuleType['number']().empty(''))
+  'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;

+ 14 - 0
src/interface/platform/news.interface.ts

@@ -28,6 +28,10 @@ export class FVO_news {
   'type': string = undefined;
   @ApiProperty({ description: '是否使用' })
   'is_use': string = undefined;
+  @ApiProperty({ description: '是否在首页显示' })
+  'is_show': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -47,6 +51,10 @@ export class QDTO_news extends SearchBase {
   'type': string = undefined;
   @ApiProperty({ description: '是否使用' })
   'is_use': string = undefined;
+  @ApiProperty({ description: '是否在首页显示' })
+  'is_show': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -89,6 +97,12 @@ export class CDTO_news {
   @ApiProperty({ description: '是否使用' })
   @Rule(RuleType['string']().empty(''))
   'is_use': string = undefined;
+  @ApiProperty({ description: '是否在首页显示' })
+  @Rule(RuleType['string']().empty(''))
+  'is_show': string = undefined;
+  @ApiProperty({ description: '显示顺序' })
+  @Rule(RuleType['number']().empty(''))
+  'order_num': number = undefined;
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;

+ 41 - 2
src/service/platform/collection.service.ts

@@ -1,8 +1,18 @@
-import { Provide } from '@midwayjs/core';
+import { Inject, Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
 import { Equal, Repository } from 'typeorm';
 import { Collection } from '../../entity/platform/collection.entity';
 import { BaseServiceV2 } from '../../frame/BaseServiceV2';
+import { MatchService } from '../platform/match.service';
+import { AchievementService } from '../platform/achievement.service';
+import { SupplyService } from '../platform/supply.service';
+import { SupportService } from '../platform/support.service';
+import { ProjectService } from '../platform/project.service';
+import { FootplateService } from '../platform/footplate.service';
+import { NewsService } from '../platform/news.service';
+import { ExpertService } from '../../service/users/expert.service';
+import { DemandService } from '../platform/demand.service';
+import { CompanyService } from '../../service/users/company.service';
 @Provide()
 export class CollectionService extends BaseServiceV2 {
   getQueryColumnsOpera(): object {
@@ -10,11 +20,40 @@ export class CollectionService extends BaseServiceV2 {
   }
   @InjectEntityModel(Collection)
   model: Repository<Collection>;
+
+  @Inject()
+  match: MatchService;
+  @Inject()
+  achievement: AchievementService;
+  @Inject()
+  supply: SupplyService;
+  @Inject()
+  support: SupportService;
+  @Inject()
+  project: ProjectService;
+  @Inject()
+  footplate: FootplateService;
+  @Inject()
+  news: NewsService;
+  @Inject()
+  expert: ExpertService;
+  @Inject()
+  demand: DemandService;
+  @Inject()
+  company: CompanyService;
+
+  // 转化来源数据名称
+  async fillScource(data) {
+    const { type, source } = data;
+    const dataRes = await this[type].fetch({ id: source });
+    if (dataRes) data = { ...data, source_name: dataRes.name || dataRes.title };
+    return data;
+  }
+
   // 取消收藏
   async cancel(data) {
     const { user, source } = data;
     const d = await this.model.findOne({ where: { user: Equal(user), source: Equal(source) } });
-    // await this.model.deleteOne({ user, source });
     await this.model.delete(d.id);
   }
 }