dcs il y a 3 mois
Parent
commit
cda7d6ada2

+ 19 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/controller/MerchantController.java

@@ -3,8 +3,10 @@ package com.bosshand.virgo.api.controller;
 
 import com.bosshand.virgo.api.model.Merchant;
 import com.bosshand.virgo.api.service.MerchantService;
+import com.bosshand.virgo.api.service.ProjectItemTargetRoomService;
 import com.bosshand.virgo.core.config.OperationControllerLog;
 import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.core.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +24,9 @@ public class MerchantController {
     @Autowired
     MerchantService merchantService;
 
+    @Autowired
+    ProjectItemTargetRoomService projectItemTargetRoomService;
+
     @OperationControllerLog(module = "客商管理", operation = "新增")
     @ApiOperation("保存")
     @RequestMapping(value = "", method = RequestMethod.POST)
@@ -42,6 +47,7 @@ public class MerchantController {
     public Response list(@RequestBody Merchant merchant, @PathVariable int currPage, @PathVariable int pageSize) {
         int totalCount = merchantService.getTotalCount(merchant);
         List<Merchant> dataList = merchantService.getLimit(merchant, currPage, pageSize);
+        rooms(dataList);
         Map<String, Object> result = new HashMap<>();
         result.put("dataList", dataList);
         result.put("totalCount", totalCount);
@@ -68,7 +74,19 @@ public class MerchantController {
     @ApiOperation("详情")
     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
     public Response get(@PathVariable long id) {
-        return Response.ok(merchantService.get(id));
+        Merchant merchant = merchantService.get(id);
+        Map<Long, String> rooms = new HashMap();
+        merchant.setRoomMap(projectItemTargetRoomService.getRoomLevel(rooms, merchant.getRoomIds()));
+        return Response.ok(merchant);
+    }
+
+    private void rooms(List<Merchant> list) {
+        for (Merchant mc : list) {
+            Map<Long, String> rooms = new HashMap();
+            if (StringUtil.notBlank(mc.getRoomIds())) {
+                mc.setRoomMap(projectItemTargetRoomService.getRoomLevel(rooms, mc.getRoomIds()));
+            }
+        }
     }
 
 }

+ 12 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/Merchant.java

@@ -1,5 +1,7 @@
 package com.bosshand.virgo.api.model;
 
+import java.util.Map;
+
 /**
  * 客商管理
  */
@@ -102,6 +104,8 @@ public class Merchant {
      */
     private String roomIds;
 
+    private Map<Long, String> roomMap;
+
     /**
      * 入驻时间
      */
@@ -267,6 +271,14 @@ public class Merchant {
         this.roomIds = roomIds;
     }
 
+    public Map<Long, String> getRoomMap() {
+        return roomMap;
+    }
+
+    public void setRoomMap(Map<Long, String> roomMap) {
+        this.roomMap = roomMap;
+    }
+
     public String getEntryTime() {
         return entryTime;
     }