zs 1 年之前
父节点
当前提交
1090aee78a
共有 2 个文件被更改,包括 25 次插入0 次删除
  1. 6 0
      src/controller/OrderDetail.controller.ts
  2. 19 0
      src/service/OrderDetail.service.ts

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

@@ -62,6 +62,12 @@ export class OrderDetailController extends BaseController {
     return { data, total };
   }
 
+  @Get('detail/:id')
+  async detail(@Param('id') id: string) {
+    const data = await this.service.detail(id);
+    return data;
+  }
+
   @Get('/:id')
   @ApiResponse({ type: FVO_OrderDetail })
   async fetch(@Param('id') id: string) {

+ 19 - 0
src/service/OrderDetail.service.ts

@@ -6,6 +6,7 @@ import { OrderDetail } from '../entity/OrderDetail.entity';
 import { Good } from '../entity/Good.entity';
 import { Specs } from '../entity/Specs.entity';
 import { User } from '../entity/User.entity';
+import _ = require('lodash');
 type modelType = ReturnModelType<typeof OrderDetail>;
 @Provide()
 export class OrderDetailService extends BaseService<modelType> {
@@ -54,4 +55,22 @@ export class OrderDetailService extends BaseService<modelType> {
     }
     return { list, total };
   }
+  // 详情
+  async detail(id) {
+    const res = await this.model.findById(id).lean();
+    let arr;
+    const info: any = {};
+    arr = await this.goodModel.findById(res.good).lean();
+    info.good_name = arr.name;
+    info.good_file = info.file[0];
+    arr = await this.specModel.findById(res.spec).lean();
+    info.spec_name = arr.name;
+    info.spec_file = arr.file[0];
+    arr = await this.userModel.findById(res.user).lean();
+    info.user_name = arr.name;
+    arr = await this.userModel.findById(res.supplier).lean();
+    info.supplier_name = arr.name;
+    const result = _.assign(info, res);
+    return result;
+  }
 }