Browse Source

填充名字

lrf 8 months ago
parent
commit
4d2cd46e2a

+ 3 - 1
src/main/java/com/free/controller/TransferApplyController.java

@@ -148,11 +148,13 @@ public class TransferApplyController {
       IPage page = new Page<>(skip, limit);
       IPage pageResult = service.page(page, qw);
       List data = pageResult.getRecords();
+      List newData = service.getUserAndCustomerName(data);
       long total = pageResult.getTotal();
-      map.put("data", data);
+      map.put("data", newData);
       map.put("total", total);
     } else {
       List list = service.list(qw);
+      List newData = service.getUserAndCustomerName(list);
       map.put("data", list);
     }
     return ResponseFormat.success(map);

+ 38 - 0
src/main/java/com/free/service/TransferApplyService.java

@@ -1,12 +1,50 @@
 package com.free.service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.free.entity.TransferApply;
+import com.free.entity.system.Customer;
 import com.free.mapper.TransferApplyMapper;
+import com.free.service.system.CustomerService;
+import com.free.utils.Utils;
 
 @Service
 public class TransferApplyService extends ServiceImpl<TransferApplyMapper, TransferApply> {
+  @Autowired
+  private CustomerService customerService;
+
+  // @Autowired
+  // private UserService userService
+  /**
+   * 将列表中的客服id和用户io的数据取出来
+   * 
+   * @param list
+   * @return
+   */
+  public List<Map> getUserAndCustomerName(List<TransferApply> list) {
+    List<Map> returnData = new ArrayList<>();
+    for (TransferApply i : list) {
+      Map map = Utils.objectToMap(i);
+      Long customer_id = Long.valueOf(String.valueOf(i.getCustomer_id()));
+      Long user_id = Long.valueOf(String.valueOf(i.getUser_id()));
+      if (null != customer_id) {
+        Customer cData = customerService.getById(customer_id);
+        if (null != cData) {
+          map.put("customer_name", cData.getNick_name());
+        }
+      }
+      // TODO:查询用户名称
+      map.put("user_name", "还没有呢");
+
+      returnData.add(map);
 
+    }
+    return returnData;
+  }
 }