gsxx.controller.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { Controller, Get, Inject, Param } from "@midwayjs/core";
  2. import { Page, Query } from "../decorator/page.decorator";
  3. import { RF } from "../response/CustomerResponse";
  4. import { PartsService } from "../service/parts.service";
  5. @Controller('/gsxx', { tagName: '供水信息' })
  6. export class GsxxController {
  7. @Inject()
  8. service: PartsService;
  9. @Get('/list/:type', { routerName: '供水信息各列表' })
  10. async list(@Param('type') type: string, @Query() query: object, @Page() page: object) {
  11. const configList = [
  12. // 水务公告
  13. { channel_id: 156, type: 'swggz' },
  14. // 水质报告
  15. { channel_id: 157, type: 'szbgz' },
  16. // 停水信息
  17. { channel_id: 158, type: 'tsxxz' },
  18. // 管网压力
  19. { channel_id: 159, type: 'gwylz' },
  20. // 采购价格信息发布
  21. { channel_id: 163, type: 'cgjgxxgbz' },
  22. ]
  23. const config = configList.find(f => f.type === type)
  24. if (!config) return { data: null, total: 0 }
  25. const { channel_id } = config
  26. const data = await this.service.contentList(channel_id, query, page)
  27. return RF.success(data);
  28. }
  29. @Get('/detail/:content_id', { routerName: '供水信息各详情' })
  30. async detail(@Param('content_id') content_id: string) {
  31. const data = await this.service.contentDetail(content_id)
  32. return RF.success(data);
  33. }
  34. }