1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { Controller, Inject, Get, Param, Body, Post } from "@midwayjs/core";
- import { Page, Query } from "../decorator/page.decorator";
- import { PartsService } from "../service/parts.service";
- import { RF } from "../response/CustomerResponse";
- import { QuestionService } from "../service/v2/question.service";
- import { get } from "lodash";
- import { PageViewService } from "../service/v2/pageView.service";
- @Controller('/myzj', { tagName: '民意征集' })
- export class MyzjController {
- @Inject()
- service: PartsService;
- @Inject()
- questionService: QuestionService;
- @Inject()
- pageViewService: PageViewService
- @Get('/question', { routerName: '投诉与建议-查询' })
- async queryQuestion(@Query() query: object, @Page() page: object) {
- let where = {}
- if (Object.keys(query).length > 0) {
- where = { where: query }
- }
- const result = await this.questionService.query(where, { ...page })
- return RF.success(result)
- }
- @Get('/question/:id', { routerName: '投诉与建议-单查询' })
- async fetchQuestion(@Param('id') id: number) {
- let where = { id }
- const result = await this.questionService.fetch(where)
- return RF.success(result)
- }
- @Post('/question', { routerName: '投诉与建议-创建' })
- async createQuestion(@Body() body: object) {
- const result = await this.questionService.create(body)
- return RF.success(result)
- }
- @Post('/question/:id', { routerName: '投诉与建议-修改' })
- async updateQuestion(@Param('id') id: number, @Body() body: object) {
- const result = await this.questionService.update({ where: { id } }, body)
- return RF.success(result)
- }
- @Get('/list/rdhy', { routerName: '热点回应列表' })
- async list(@Query() query: object, @Page() page: object) {
- const channel_id = 197
- const { data, total } = await this.service.contentList(channel_id, query, page)
- const newList = []
- for (const i of newList) {
- const newObject: any = {
- content_id: get(i, 'content_id'),
- id: get(i, 'content_id'),
- title: get(i, 'ext.title'),
- release_date: get(i, 'ext.release_date'),
- url: get(i, 'ext.type_img')
- }
- const views = await this.pageViewService.fetch(newObject.content_id, true)
- newObject.views = views
- newList.push(newObject)
- }
- 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)
- return RF.success(data);
- }
- }
|