Bläddra i källkod

修改首页查询统计

zs 7 månader sedan
förälder
incheckning
4801ce3ceb
2 ändrade filer med 22 tillägg och 0 borttagningar
  1. 6 0
      src/controller/util.controller.ts
  2. 16 0
      src/service/util.service.ts

+ 6 - 0
src/controller/util.controller.ts

@@ -17,6 +17,12 @@ export class UtilController {
   @Inject()
   httpService: HttpService;
 
+  @Post('/toTotal')
+  async toTotal() {
+    const result = await this.service.toTotal();
+    return result;
+  }
+
   @Post('/toExport')
   async toExport(@Body() data: object) {
     const result = await this.service.toExport(data);

+ 16 - 0
src/service/util.service.ts

@@ -48,6 +48,22 @@ export class UtilService {
   @Config('PathConfig.path')
   path;
 
+  // 统计总数
+  async toTotal() {
+    const companyTotal = await this.companyModel.count();
+    const supplyTotal = await this.supplyModel.count();
+    const demandTotal = await this.demandModel.count();
+    const projectTotal = await this.projectModel.count();
+    const achievementTotal = await this.achievementModel.count();
+    const data = [
+      { id: '1', name: '企业', num: `${companyTotal}+`, unit: '家' },
+      { id: '2', name: '供给', num: `${supplyTotal}+`, unit: '个' },
+      { id: '3', name: '需求', num: `${demandTotal}+`, unit: '个' },
+      { id: '4', name: '项目', num: `${projectTotal}+`, unit: '个' },
+      { id: '5', name: '成果', num: `${achievementTotal}+`, unit: '个' },
+    ];
+    return data;
+  }
   // 导出
   async toExport(query) {
     const { table, config, user } = query;