Bladeren bron

小程序接口

roose 2 jaren geleden
bovenliggende
commit
a4163b4f76

+ 1 - 1
ruoyi-modules/znyl-resource/src/main/java/com/ruoyi/resource/miniapp/UserAppController.java

@@ -359,7 +359,7 @@ public class UserAppController extends BaseController
                     query.setCode(code);
                 }
             } else {
-                return AjaxResult.success("");
+                return AjaxResult.error("客户信息有误!");
             }
             List<SysDeptJl> list = remoteDeptJlService.getLists(query);
             return AjaxResult.success(list);

+ 23 - 14
ruoyi-modules/znyl-resource/src/main/java/com/ruoyi/resource/service/impl/ZnylKhzhServiceImpl.java

@@ -7,6 +7,7 @@ import java.util.Map;
 import com.ruoyi.common.core.exception.CustomException;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.SecurityUtils;
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.system.api.RemoteDeptJlService;
 import com.ruoyi.system.api.RemoteRoleService;
@@ -50,21 +51,29 @@ public class ZnylKhzhServiceImpl implements IZnylKhzhService
     public ZnylKhzh selectZnylKhzhById(Long id)
     {
         ZnylKhzh khzh = znylKhzhMapper.selectZnylKhzhById(id);
-        StringBuffer codeList = new StringBuffer();
-        SysDeptJl sysDeptJl = remoteDeptJlService.selectSysDeptJlByCode(khzh.getRegioncode());
-        String level = String.valueOf(sysDeptJl.getLevel());
-        if (level.equals("1")) {
-            codeList.append(khzh.getRegioncode());
-        } else if (level.equals("2")) {
-            SysDeptJl deptJl = remoteDeptJlService.selectSysDeptJlById(sysDeptJl.getParentId());
-            codeList.append(deptJl.getCode() + "," +khzh.getRegioncode());
-        } else if (level.equals("3")) {
-            SysDeptJl deptJlLevel2 = remoteDeptJlService.selectSysDeptJlById(sysDeptJl.getParentId());
-            SysDeptJl deptJlLevel1 = remoteDeptJlService.selectSysDeptJlById(deptJlLevel2.getParentId());
-            codeList.append(deptJlLevel1.getCode() + "," +deptJlLevel2.getCode() + "," + khzh.getRegioncode());
+        if (null != khzh) {
+            if (StringUtils.isNotNull(khzh.getRegioncode())) {
+                StringBuffer codeList = new StringBuffer();
+                SysDeptJl sysDeptJl = remoteDeptJlService.selectSysDeptJlByCode(khzh.getRegioncode());
+                String level = String.valueOf(sysDeptJl.getLevel());
+                if (level.equals("1")) {
+                    codeList.append(khzh.getRegioncode());
+                } else if (level.equals("2")) {
+                    SysDeptJl deptJl = remoteDeptJlService.selectSysDeptJlById(sysDeptJl.getParentId());
+                    codeList.append(deptJl.getCode() + "," + khzh.getRegioncode());
+                } else if (level.equals("3")) {
+                    SysDeptJl deptJlLevel2 = remoteDeptJlService.selectSysDeptJlById(sysDeptJl.getParentId());
+                    SysDeptJl deptJlLevel1 = remoteDeptJlService.selectSysDeptJlById(deptJlLevel2.getParentId());
+                    codeList.append(deptJlLevel1.getCode() + "," + deptJlLevel2.getCode() + "," + khzh.getRegioncode());
+                }
+                khzh.setRegioncodes(codeList.toString());
+                return khzh;
+            } else {
+                return khzh;
+            }
+        } else {
+            throw new CustomException("客户信息有误!");
         }
-        khzh.setRegioncodes(codeList.toString());
-        return khzh;
     }
 
     @Override