Переглянути джерело

c端 注册 添加 省市 的select

zhangc 6 місяців тому
батько
коміт
2d0a36ee27

+ 3 - 2
src/main/java/com/inkasso/factoring/system/department/controller/DepartmentController.java

@@ -6,6 +6,7 @@ import com.inkasso.factoring.system.department.service.IDepartmentService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -24,7 +25,7 @@ public class DepartmentController {
      * 查找省市区行政区划
      */
     @GetMapping("/findAll")
-    public Object doFindAll() {
-        return ResponseData.success(departmentService.findAll());
+    public Object doFindAll(@RequestParam(required = false) Boolean flag) {
+        return ResponseData.success(departmentService.findAll(flag));
     }
 }

+ 1 - 1
src/main/java/com/inkasso/factoring/system/department/service/IDepartmentService.java

@@ -16,5 +16,5 @@ public interface IDepartmentService extends IService<Department> {
     /**
      * 省市区行政区划查询
      */
-    List<DepartmentVo> findAll();
+    List<DepartmentVo> findAll(Boolean flag);
 }

+ 12 - 3
src/main/java/com/inkasso/factoring/system/department/service/impl/DepartmentServiceImpl.java

@@ -22,8 +22,14 @@ import java.util.stream.Collectors;
 @Service
 public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
 
+
+    /**
+     * 是排除区县级
+     * @param flag
+     * @return
+     */
     @Override
-    public List<DepartmentVo> findAll() {
+    public List<DepartmentVo> findAll(Boolean flag) {
         //查询省
         List<Department> provinceList = list(new QueryWrapper<Department>().eq("parent_id", 1L));
 
@@ -33,10 +39,13 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                 DepartmentVo vo = new DepartmentVo(province);
                 List<Department> cityList = list(new QueryWrapper<Department>().eq("parent_id", province.getId()));
                 List<DepartmentVo> childrenList = cityList.stream().map(city -> new DepartmentVo(city)).collect(Collectors.toList());
+
                 childrenList.stream().forEach(city -> {
                     List<Department> districtList = list(new QueryWrapper<Department>().eq("parent_id", city.getId()));
-                    List<DepartmentVo> childrenList1 = districtList.stream().map(district -> new DepartmentVo(district)).collect(Collectors.toList());
-                    city.setChildren(childrenList1);
+                    if(!(flag!=null && flag)){
+                        List<DepartmentVo> childrenList1 = districtList.stream().map(district -> new DepartmentVo(district)).collect(Collectors.toList());
+                        city.setChildren(childrenList1);
+                    }
                 });
                 vo.setChildren(childrenList);
                 result.add(vo);

+ 34 - 0
src/main/java/com/inkasso/factoring/system/user/entity/UserDO.java

@@ -6,6 +6,7 @@ import com.inkasso.factoring.common.entity.BaseEntity;
 
 import javax.validation.constraints.NotEmpty;
 import java.util.Date;
+import java.util.List;
 
 
 /**
@@ -72,6 +73,12 @@ public class UserDO extends BaseEntity {
     @TableField("head_img_url")
     private String headImgUrl;
 
+    @TableField("province_id")
+    private Long provinceId;
+
+    @TableField("city_id")
+    private Long cityId;
+
     /**
      * 企业地址
      */
@@ -108,6 +115,9 @@ public class UserDO extends BaseEntity {
     @TableField(exist = false)
     private String name;
 
+    @TableField(exist = false)
+    private List<Long> provinceCityIds;
+
     public Long getProjectManager() {
         return projectManager;
     }
@@ -211,4 +221,28 @@ public class UserDO extends BaseEntity {
     public void setName(String name) {
         this.name = name;
     }
+
+    public List<Long> getProvinceCityIds() {
+        return provinceCityIds;
+    }
+
+    public void setProvinceCityIds(List<Long> provinceCityIds) {
+        this.provinceCityIds = provinceCityIds;
+    }
+
+    public Long getProvinceId() {
+        return provinceId;
+    }
+
+    public void setProvinceId(Long provinceId) {
+        this.provinceId = provinceId;
+    }
+
+    public Long getCityId() {
+        return cityId;
+    }
+
+    public void setCityId(Long cityId) {
+        this.cityId = cityId;
+    }
 }

+ 7 - 0
src/main/java/com/inkasso/factoring/system/user/service/impl/UserServiceImpl.java

@@ -338,6 +338,13 @@ public class UserServiceImpl extends ServiceImpl<UserDAO, UserDO> implements Use
         } catch (Exception e) {
             e.printStackTrace();
         }
+        List<Long> provinceCityIds = userDO.getProvinceCityIds();
+        if(CollectionUtil.isNotEmpty(provinceCityIds)){
+            userDO.setProvinceId(provinceCityIds.get(0));
+            if(provinceCityIds.size()>1){
+                userDO.setCityId(provinceCityIds.get(1));
+            }
+        }
         userDO.setUserName(userDO.getLoginName());
         userDO.setRegisterDate(new Date());
         if (userDO.getReferralCode() != null) {