ソースを参照

供应商分配保存相关优化调整

hejq 7 年 前
コミット
e64a567c61

+ 2 - 2
src/main/java/com/uas/platform/b2b/controller/VendorDistributeController.java

@@ -41,7 +41,7 @@ public class VendorDistributeController {
      */
     @RequestMapping(value = "/bindVendor/{id}", method = RequestMethod.POST)
     public ResultMap bindVendor(@PathVariable("id") Long id, @RequestBody String json) {
-        List<User> users = FlexJsonUtils.fromJsonArray(json, User.class);
+        List<UserBaseInfo> users = FlexJsonUtils.fromJsonArray(json, UserBaseInfo.class);
         boolean result = vendorService.bindVendorToUser(id, users);
         String resultInfo = result ? "成功" : "失败";
         LOGGER.log("供应商权限", "分配供应商", "结果: 分配" + resultInfo, "", id);
@@ -57,7 +57,7 @@ public class VendorDistributeController {
      */
     @RequestMapping(value = "/bindUserToVendor/{id}", method = RequestMethod.POST)
     public ResultMap bindUserToVendor(@PathVariable("id") Long id, @RequestBody String json) throws IllegalAccessException {
-        List<User> users = FlexJsonUtils.fromJsonArray(json, User.class);
+        List<UserBaseInfo> users = FlexJsonUtils.fromJsonArray(json, UserBaseInfo.class);
         boolean result = vendorService.transferVendorToUser(id, users);
         String resultInfo = result ? "成功" : "失败";
         LOGGER.log("供应商权限", "转移权限", "结果: 绑定" + resultInfo, "", id);

+ 3 - 2
src/main/java/com/uas/platform/b2b/service/VendorService.java

@@ -174,7 +174,7 @@ public interface VendorService {
      * @param userList 供应商客户
      * @return 分配结果 成功或失败
      */
-    boolean bindVendorToUser(Long id, List<User> userList);
+    boolean bindVendorToUser(Long id, List<UserBaseInfo> userList);
 
     /**
      * 供应商权限转移
@@ -182,8 +182,9 @@ public interface VendorService {
      * @param id 供应商关系id
      * @param users 前端选择用户信息
      * @return 转移结果
+     * @throws IllegalAccessException 没有权限抛出异常
      */
-    boolean transferVendorToUser(Long id, List<User> users) throws IllegalAccessException;
+    boolean transferVendorToUser(Long id, List<UserBaseInfo> users) throws IllegalAccessException;
 
     /**
      * 设置联系人

+ 6 - 30
src/main/java/com/uas/platform/b2b/service/impl/VendorsServiceImpl.java

@@ -521,14 +521,14 @@ public class VendorsServiceImpl implements VendorService {
      * @return 分配结果 成功或失败
      */
     @Override
-    public boolean bindVendorToUser(Long id, List<User> userList) {
+    public boolean bindVendorToUser(Long id, List<UserBaseInfo> userList) {
         if (!CollectionUtils.isEmpty(userList)) {
             List<VendorDistribute> needSaveOrUpdateList = new ArrayList<>();
             List<VendorDistribute> needDeleteList = new ArrayList<>();
-            for (User user : userList) {
+            for (UserBaseInfo user : userList) {
                 Long userUU = user.getUserUU();
                 VendorDistribute distribute = new VendorDistribute();
-                if (user.getDistribute()) {
+                if (user.isDistribute()) {
                     List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(userUU, id);
                     if (CollectionUtils.isEmpty(distributes)) {
                         distribute.setUserUU(userUU);
@@ -577,15 +577,15 @@ public class VendorsServiceImpl implements VendorService {
      * @return 转移结果
      */
     @Override
-    public boolean transferVendorToUser(Long id, List<User> users) throws IllegalAccessException {
+    public boolean transferVendorToUser(Long id, List<UserBaseInfo> users) throws IllegalAccessException {
         Vendor vendor = vendorDao.findOne(id);
         if (!CollectionUtils.isEmpty(users)) {
             List<VendorDistribute> saveList = new ArrayList<>();
-            for (User u : users) {
+            for (UserBaseInfo u : users) {
                 if (null != u.getUserUU()) {
                     VendorDistribute distribute = new VendorDistribute();
                     List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(u.getUserUU(), vendor.getId());
-                    if (u.getTransfer()) {
+                    if (u.isTransfer()) {
                         if (CollectionUtils.isEmpty(distributes)) {
                             distribute.setUserUU(u.getUserUU());
                             distribute.setVendorId(vendor.getId());
@@ -653,30 +653,6 @@ public class VendorsServiceImpl implements VendorService {
         }
     }
 
-    /**
-     * 删除用户的所有关联节点
-     * @param vendorId 供应商关系id
-     * @param userUU  用户UU
-     * @param deleteList 删除idList
-     * @return
-     */
-    private List<VendorDistribute> deleteChildrenDistributes(Long vendorId, Long userUU, List<VendorDistribute> deleteList) {
-        // 删除时,同时删除被其分配权限的其他用户
-        List<VendorDistribute> distributes = vendorDistributeDao.findByVendorIdAndLeaderUU(vendorId, userUU);
-        List<VendorDistribute> vendorDistributes = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(distributes)) {
-            deleteList.addAll(distributes);
-            // 被删除用户拥有转移权限时,继续删除其子节点
-            for (VendorDistribute distribute : distributes) {
-                if (null != distribute.getIsTransfer() && 1 == distribute.getIsTransfer()) {
-                    distribute.setIsTransfer(Constant.NO);
-                    vendorDistributes.add(distribute);
-                }
-            }
-        }
-        return deleteList;
-    }
-
     /**
      * 通过供应商UU查询供应商分配信息
      *