Browse Source

接口对接完成

lrf 2 months ago
parent
commit
a85eef203e

+ 5 - 0
src/config/config.prod.ts

@@ -21,6 +21,11 @@ export default {
     globalPrefix: '/warter/front/v2/api',
     queryParseMode: 'extended',
   },
+  midwayLogger: {
+    default: {
+      level: 'info'
+    }
+  },
   typeorm: {
     dataSource: {
       default: {

+ 2 - 2
src/configuration.ts

@@ -3,7 +3,7 @@ import * as koa from '@midwayjs/koa';
 import * as validate from '@midwayjs/validate';
 import * as info from '@midwayjs/info';
 import { join } from 'path';
-// import { DefaultErrorFilter } from './filter/default.filter';
+import { DefaultErrorFilter } from './filter/Default.filter';
 // import { NotFoundFilter } from './filter/notfound.filter';
 import { ReportMiddleware } from './middleware/report.middleware';
 import { CustomErrorFilter } from './filter/ServiceError.filter';
@@ -30,7 +30,7 @@ export class MainConfiguration {
     // add middleware
     this.app.useMiddleware([ReportMiddleware]);
     // add filter
-    this.app.useFilter([CustomErrorFilter]);
+    this.app.useFilter([CustomErrorFilter, DefaultErrorFilter]);
     // this.app.useFilter([NotFoundFilter, DefaultErrorFilter]);
   }
 }

+ 19 - 3
src/controller/gsxx.controller.ts

@@ -2,11 +2,15 @@ import { Controller, Get, Inject, Param } from "@midwayjs/core";
 import { Page, Query } from "../decorator/page.decorator";
 import { RF } from "../response/CustomerResponse";
 import { PartsService } from "../service/parts.service";
+import { PageViewService } from "../service/v2/pageView.service";
+import { get } from "lodash";
 
 @Controller('/gsxx', { tagName: '供水信息' })
 export class GsxxController { 
   @Inject()
   service: PartsService;
+  @Inject()
+  pageViewService: PageViewService
   @Get('/list/:type', { routerName: '供水信息各列表' })
   async list(@Param('type') type: string, @Query() query: object, @Page() page: object) {
     const configList = [
@@ -24,14 +28,26 @@ export class GsxxController {
     const config = configList.find(f => f.type === type)
     if (!config) return { data: null, total: 0 }
     const { channel_id } = config
-    const data = await this.service.contentList(channel_id, query, page)
-    return RF.success(data);
+    const { data, total } = await this.service.contentList(channel_id, query, page)
+    const newList = []
+    for (const i of data) {
+      const newData = {
+        content_id: get(i, 'content_id'),
+        id: get(i, 'content_id'),
+        title: get(i, 'ext.title'),
+        date: get(i, 'ext.release_date'),
+      }
+      newList.push(newData)
+    }
+    return RF.success({ data: newList, total });
   }
 
   @Get('/detail/:content_id', { routerName: '供水信息各详情' })
   async detail(@Param('content_id') content_id: string) {
     const data = await this.service.contentDetail(content_id)
-    // TODO:增加浏览量,然后将浏览量放到返回数据中
+    // 增加浏览量,然后将浏览量放到返回数据中
+    const views = await this.pageViewService.fetch(content_id)
+    data.views = views;
     return RF.success(data);
   }
 }

+ 1 - 1
src/controller/jtxw.controller.ts

@@ -45,7 +45,7 @@ export class JtxwController {
   @Get('/detail/:content_id', { routerName: '集团新闻详情' })
   async detail(@Param('content_id') content_id: string) {
     const data: any = await this.service.contentDetail(content_id)
-    // TODO:增加浏览量,然后将浏览量放到返回数据中
+    // 增加浏览量,然后将浏览量放到返回数据中
     const views = await this.pageViewService.fetch(content_id)
     data.views = views;
     return RF.success(data);

+ 4 - 1
src/controller/myzj.controller.ts

@@ -51,7 +51,7 @@ export class MyzjController {
     const channel_id = 197
     const { data, total } = await this.service.contentList(channel_id, query, page)
     const newList = []
-    for (const i of newList) {
+    for (const i of data) {
       const newObject: any = {
         content_id: get(i, 'content_id'),
         id: get(i, 'content_id'),
@@ -69,6 +69,9 @@ export class MyzjController {
   @Get('/detail/:content_id', { routerName: '热点回应详情' })
   async detail(@Param('content_id') content_id: string) {
     const data = await this.service.contentDetail(content_id)
+    // 增加浏览量,然后将浏览量放到返回数据中
+    const views = await this.pageViewService.fetch(content_id)
+    data.views = views;
     return RF.success(data);
   }
 }

+ 33 - 0
src/controller/search.controller.ts

@@ -0,0 +1,33 @@
+import { Controller, Get, Inject, Param } from "@midwayjs/core";
+import { RF } from "../response/CustomerResponse";
+import { Page, Query } from "../decorator/page.decorator";
+import { SearchService } from "../service/v2/search.service";
+import { PartsService } from "../service/parts.service";
+import { PageViewService } from "../service/v2/pageView.service";
+
+
+@Controller('/search', { tagName: '全文检索' })
+export class SearchController {
+  @Inject()
+  searchService: SearchService;
+  @Inject()
+  service: PartsService;
+  @Inject()
+  pageViewService: PageViewService;
+
+  @Get('/query', { routerName: '全文检索列表查询' })
+  async query(@Query() query: object, @Page() page: object) {
+    const result = await this.searchService.textSearch(query, page)
+    return RF.success(result);
+  }
+
+  @Get('/:content_id', { routerName: '全文检索详情' })
+  async detail(@Param('content_id') content_id: string) {
+    const data: any = await this.service.contentDetail(content_id)
+    // 增加浏览量,然后将浏览量放到返回数据中
+    const views = await this.pageViewService.fetch(content_id)
+    data.views = views;
+    return RF.success(data);
+  }
+
+}

+ 1 - 1
src/controller/xxgk.controller.ts

@@ -179,7 +179,7 @@ export class XxgkController {
   @Get('/detail/:content_id', { routerName: '信息公开详情' })
   async detail(@Param('content_id') content_id: string) {
     const data: any = await this.service.contentDetail(content_id)
-    // TODO:增加浏览量,然后将浏览量放到返回数据中
+    // 增加浏览量,然后将浏览量放到返回数据中
     const views = await this.pageViewService.fetch(content_id)
     data.views = views;
     return RF.success(data);

+ 11 - 1
src/controller/zjsw.controller.ts

@@ -1,6 +1,7 @@
 import { Controller, Inject, Get, Param } from "@midwayjs/core";
 import { PartsService } from "../service/parts.service";
 import { RF } from "../response/CustomerResponse";
+import { get } from "lodash";
 
 @Controller('/zjsw', { tagName: '资质荣誉' })
 export class ZjswController {
@@ -29,6 +30,15 @@ export class ZjswController {
     if (!config) return { data: null }
     const { channel_id } = config
     const data = await this.service.channelDetail(channel_id)
-    return RF.success(data);
+    let newData = {}
+    if (data) {
+      newData = {
+        channel_id,
+        id: channel_id,
+        title: get(data, 'channel_name'),
+        txt: get(data, 'txt.txt')
+      }
+      return RF.success(newData);
+    }
   }
 }