From 8a66f76e0b0af13ccdba14f1d38eed91139ca124 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 23 三月 2023 11:41:43 +0800
Subject: [PATCH] 处理TODO,导出部分修改

---
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java |   80 +++++++++++++++++++++++++++++++--------
 1 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
index 55f20e3..170c2b7 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
@@ -7,12 +7,14 @@
 import com.stylefeng.guns.core.shiro.ShiroKit;
 import com.stylefeng.guns.modular.system.controller.resp.TBranchOfficeResp;
 import com.stylefeng.guns.modular.system.controller.resp.TDriverResp;
+import com.stylefeng.guns.modular.system.enums.StatusEnum;
 import com.stylefeng.guns.modular.system.model.*;
 import com.stylefeng.guns.modular.system.service.ITRegionService;
 import com.stylefeng.guns.modular.system.service.ITSystemConfigService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -115,22 +117,13 @@
      * 跳转区域页面新增
      */
     @RequestMapping("/areaPageAdd")
-    public String areaPageAdd(Model model) {
-        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
-        model.addAttribute("provinceList",tRegions);
-        return PREFIX + "tBranchOfficeAreaAdd.html";
-    }
-
-    /**
-     * 跳转区域页面编辑
-     */
-    @RequestMapping("/areaPageUpdate")
-    public String areaPageUpdate(String area,String areaId,Model model) {
+    public String areaPageAdd(String area,String areaId,Model model) {
+        String[] split1 = areaId.split("/");
         List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
         model.addAttribute("provinceList",tRegions);
         List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
         // 查询市
-        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", provinceIds));
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0]));
         model.addAttribute("cityList",tRegions1);
 
         // 查询区
@@ -148,7 +141,6 @@
                 model.addAttribute("districtName","");
             }
 
-            String[] split1 = areaId.split("/");
             model.addAttribute("provinceId",split1[0]);
             model.addAttribute("cityId",split1[1]);
             if(split1.length>2) {
@@ -156,7 +148,55 @@
             }else {
                 model.addAttribute("districtId", "");
             }
+        }else {
+            model.addAttribute("provinceName","");
+            model.addAttribute("cityName","split[1]");
+            model.addAttribute("districtName","");
+
+            model.addAttribute("provinceId","");
+            model.addAttribute("cityId","split1[1]");
+            model.addAttribute("districtId", "");
         }
+        return PREFIX + "tBranchOfficeAreaAdd.html";
+    }
+
+    /**
+     * 跳转区域页面编辑
+     */
+    @RequestMapping("/areaPageUpdate")
+    public String areaPageUpdate(String area,String areaId,Model model) {
+
+        String[] split = area.split("/");
+        model.addAttribute("provinceName",split[0]);
+        model.addAttribute("cityName",split[1]);
+        if(split.length>2){
+            model.addAttribute("districtName",split[2]);
+        }else {
+            model.addAttribute("districtName","");
+        }
+
+        String[] split1 = areaId.split("/");
+        String provinceId = split1[0];
+        model.addAttribute("provinceId",split1[0]);
+        model.addAttribute("cityId",split1[1]);
+        if(split1.length>2) {
+            model.addAttribute("districtId", split1[2]);
+        }else {
+            model.addAttribute("districtId", "");
+        }
+
+        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
+        model.addAttribute("provinceList",tRegions);
+//        List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
+        // 查询市
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", provinceId));
+        model.addAttribute("cityList",tRegions1);
+
+        // 查询区
+        List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList());
+        List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds));
+        model.addAttribute("districtList",tRegions2);
+
         return PREFIX + "tBranchOfficeAreaUpdate.html";
     }
 
@@ -177,6 +217,10 @@
     @ResponseBody
     public Object areaCity(Integer parentId,Model model) {
         List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId));
+        /*if(CollectionUtils.isEmpty(tRegions) && StringUtils.hasLength(parentName)){
+            TRegion parent = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("name", parentName));
+            tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId));
+        }*/
         model.addAttribute("list",tRegions);
         return tRegions;
     }
@@ -188,7 +232,7 @@
     @ResponseBody
     public Object start(Integer id) {
         TBranchOffice tBranchOffice = tBranchOfficeService.selectById(id);
-        tBranchOffice.setStatus(1);
+        tBranchOffice.setStatus(StatusEnum.NORMAL.getCode());
         tBranchOfficeService.updateById(tBranchOffice);
         return SUCCESS_TIP;
     }
@@ -200,7 +244,7 @@
     @ResponseBody
     public Object updateStatus(Integer id) {
         TBranchOffice tBranchOffice = tBranchOfficeService.selectById(id);
-        tBranchOffice.setStatus(2);
+        tBranchOffice.setStatus(StatusEnum.FREEZE.getCode());
         tBranchOfficeService.updateById(tBranchOffice);
         return SUCCESS_TIP;
     }
@@ -229,7 +273,7 @@
         if(Objects.nonNull(o)){
             return o;
         }
-        tBranchOffice.setStatus(1);
+        tBranchOffice.setStatus(StatusEnum.NORMAL.getCode());
 
         tBranchOfficeService.insert(tBranchOffice);
         return SUCCESS_TIP;
@@ -241,7 +285,9 @@
     @RequestMapping(value = "/delete")
     @ResponseBody
     public Object delete(@RequestParam Integer tBranchOfficeId) {
-        tBranchOfficeService.deleteById(tBranchOfficeId);
+        TBranchOffice tBranchOffice = tBranchOfficeService.selectById(tBranchOfficeId);
+        tBranchOffice.setStatus(StatusEnum.DELETE.getCode());
+        tBranchOfficeService.updateById(tBranchOffice);
         return SUCCESS_TIP;
     }
 

--
Gitblit v1.7.1