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