lifuquan %!s(int64=2) %!d(string=hai) anos
pai
achega
61a7e3a9f4
Modificáronse 32 ficheiros con 243 adicións e 419 borrados
  1. 1 1
      acl提供给黑点库的接口.md
  2. 9 4
      src/main/java/com/nokia/controller/CityController.java
  3. 10 3
      src/main/java/com/nokia/controller/FlowApiController.java
  4. 0 34
      src/main/java/com/nokia/controller/UserController.java
  5. 6 1
      src/main/java/com/nokia/dao/CityDao.java
  6. 17 17
      src/main/java/com/nokia/dao/UserDao.java
  7. 4 0
      src/main/java/com/nokia/dao/UserRoleDao.java
  8. 21 0
      src/main/java/com/nokia/pojo/Area.java
  9. 1 0
      src/main/java/com/nokia/pojo/City.java
  10. 1 0
      src/main/java/com/nokia/pojo/District.java
  11. 1 1
      src/main/java/com/nokia/pojo/Role.java
  12. 10 3
      src/main/java/com/nokia/pojo/User.java
  13. 1 0
      src/main/java/com/nokia/pojo/UserRole.java
  14. 4 0
      src/main/java/com/nokia/service/CityService.java
  15. 21 1
      src/main/java/com/nokia/service/FlowService.java
  16. 10 128
      src/main/java/com/nokia/service/UserService.java
  17. 2 2
      src/main/java/com/nokia/vo/DapingUserVo.java
  18. 1 1
      src/main/java/com/nokia/vo/FenxiUserVo.java
  19. 2 2
      src/main/java/com/nokia/vo/HeidiankuUserVo.java
  20. 2 2
      src/main/java/com/nokia/vo/YuceUserVo.java
  21. 1 1
      src/main/java/com/nokia/vo/flow/FlowOrgVo.java
  22. 4 4
      src/main/java/com/nokia/vo/flow/FlowRoleCityVo.java
  23. 1 1
      src/main/java/com/nokia/vo/flow/FlowRoleVo.java
  24. 6 4
      src/main/java/com/nokia/vo/flow/FlowUserVo.java
  25. 12 0
      src/main/java/com/nokia/vo/flow/UserTreeReq.java
  26. 21 19
      src/main/resources/application.properties
  27. 46 22
      src/main/resources/mapper/UserMapper.xml
  28. 0 95
      src/test/java/com/nokia/UserModifyTest.java
  29. 0 29
      src/test/java/com/nokia/dao/CityDaoTest.java
  30. 28 13
      src/test/java/com/nokia/dao/UserDaoTest.java
  31. 0 19
      src/test/java/com/nokia/dao/UserRoleDaoTest.java
  32. 0 12
      src/test/java/com/nokia/service/UserServiceTest.java

+ 1 - 1
acl提供给黑点库的接口.md

@@ -95,4 +95,4 @@ Connection: close
   }
 }
 
-```
+```

+ 9 - 4
src/main/java/com/nokia/controller/CityController.java

@@ -1,15 +1,20 @@
 package com.nokia.controller;
-import com.nokia.common.R;
-import com.nokia.pojo.City;
-import com.nokia.service.CityService;
+import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
-import java.util.List;
 
+import com.nokia.common.R;
+import com.nokia.pojo.City;
+import com.nokia.service.CityService;
+
+/*
+ * 已弃用代码
+ */
+@Deprecated
 @RestController
 @RequestMapping("rest/api/city")
 public class CityController {

+ 10 - 3
src/main/java/com/nokia/controller/FlowApiController.java

@@ -4,9 +4,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.nokia.common.R;
 import com.nokia.pojo.Role;
 import com.nokia.service.FlowService;
-import com.nokia.vo.FlowRoleCityVo;
-import com.nokia.vo.FlowRoleVo;
-import com.nokia.vo.FlowUserVo;
+import com.nokia.vo.flow.FlowRoleCityVo;
+import com.nokia.vo.flow.FlowRoleVo;
+import com.nokia.vo.flow.FlowUserVo;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -27,6 +28,12 @@ public class FlowApiController {
         this.flowService = flowService;
     }
 
+    @PostMapping("flow/api/userTree")
+    public R getUserTree(@RequestBody JSONObject jsonObject) {
+        
+        return null;
+    }
+
     @PostMapping("flow/api")
     @ResponseBody
     public R flowApi(@RequestBody JSONObject jsonObject) {

+ 0 - 34
src/main/java/com/nokia/controller/UserController.java

@@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
-import java.util.Map;
 
 @RestController
 @RequestMapping("rest/api/user")
@@ -40,37 +39,4 @@ public class UserController {
             return R.error().message(msg);
         }
     }
-
-    @PostMapping("/delete/id/{userId}")
-    public R delete(@PathVariable Integer userId) {
-        if (null == userId) {
-            return R.error().message("userId 不能为空");
-        }
-        String delete = userServiceImpl.delete(userId);
-        if (delete.equals("ok")) {
-            return R.ok().message("删除成功");
-        } else {
-            return R.error().message(delete);
-        }
-    }
-
-    @PostMapping("/update/id/{userId}")
-    public R update(@PathVariable Integer userId, @RequestBody User userEntity) {
-        if (null == userEntity) {
-            return R.error().message("userEntity 为空");
-        }
-        userEntity.setUserId(userId);
-        boolean update = userServiceImpl.update(userEntity);
-        if (update) {
-            return R.ok().message("修改成功");
-        } else {
-            return R.error().message("修改失败");
-        }
-    }
-
-    @PostMapping("/select/id/{userId}")
-    public Map<String, Object> select(@PathVariable Integer userId) {
-
-        return userServiceImpl.select(userId);
-    }
 }

+ 6 - 1
src/main/java/com/nokia/dao/CityDao.java

@@ -2,10 +2,15 @@ package com.nokia.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.nokia.pojo.City;
-import com.nokia.vo.FlowOrgVo;
+import com.nokia.vo.flow.FlowOrgVo;
+
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 
+/*
+ * 已弃用代码
+ */
+@Deprecated
 @Mapper
 public interface CityDao extends BaseMapper<City> {
     @Select("select * from sqmdb_rpt.acl_city where city_id = #{cityId}")

+ 17 - 17
src/main/java/com/nokia/dao/UserDao.java

@@ -3,8 +3,9 @@ package com.nokia.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.nokia.pojo.Role;
 import com.nokia.pojo.User;
-import com.nokia.vo.FlowRoleVo;
-import com.nokia.vo.FlowUserVo;
+import com.nokia.vo.flow.FlowRoleVo;
+import com.nokia.vo.flow.FlowUserVo;
+
 import org.apache.ibatis.annotations.*;
 import java.util.List;
 
@@ -32,9 +33,9 @@ public interface UserDao extends BaseMapper<User> {
                         @Result(column = "org_name", property = "org.orgName"),
         })
         @Select("select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
-                        + " a.city_id as org_id, c.city_name_zh as org_name, a.district as area"
-                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c"
-                        + " where a.city_id = c.city_id")
+                        + " a.city_id as org_id, c1.area_name as org_name, a.area_id as area"
+                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_area c1"
+                        + " where a.city_id = c1.area_id")
         List<FlowUserVo> findToPage();
 
         /**
@@ -45,9 +46,9 @@ public interface UserDao extends BaseMapper<User> {
                         @Result(column = "org_name", property = "org.orgName"),
         })
         @Select("select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
-                        + " a.city_id as org_id, c.city_name_zh as org_name, a.district as area"
-                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c"
-                        + " where a.city_id = c.city_id and login_name=#{loginId}")
+                        + " a.city_id as org_id, c.area_name as org_name, a.area_id as area"
+                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_area c"
+                        + " where a.city_id = c.area_id and a.login_name=#{loginId}")
         FlowUserVo getFlowUserVoByLoginId(String loginId);
 
         /**
@@ -58,9 +59,9 @@ public interface UserDao extends BaseMapper<User> {
                         @Result(column = "org_name", property = "org.orgName"),
         })
         @Select("select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
-                        + " a.city_id as org_id, c.city_name_zh as org_name, a.district as area"
-                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c"
-                        + " where a.city_id = c.city_id and user_id=#{userId}")
+                        + " a.city_id as org_id, c.area_name as org_name, a.area_id as area"
+                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_area c"
+                        + " where a.city_id = c.area_id and user_id=#{userId}")
         FlowUserVo getFlowUserVoByUserId(Integer userId);
 
         @Select("select r.role_id from  sqmdb_rpt.acl_role r,  sqmdb_rpt.acl_user_role_city ur where r.role_id = ur.role_id and r.system='flow' and ur.user_id=#{userId}")
@@ -69,18 +70,15 @@ public interface UserDao extends BaseMapper<User> {
         @Select("select u.user_id from sqmdb_rpt.acl_user u,  sqmdb_rpt.acl_user_role_city ur where u.user_id = ur.user_id and ur.role_id=#{roleId}")
         List<Integer> findUserIdByRoleId(Integer roleId);
 
-        /**
-         * 
-         */
         @Results({
                         @Result(column = "org_id", property = "org.orgId"),
                         @Result(column = "org_name", property = "org.orgName"),
         })
         @Select("<script>"
                         + "select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
-                        + " a.city_id as org_id, c.city_name_zh as org_name, a.district as area"
-                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c, sqmdb_rpt.acl_user_role_city ur "
-                        + " where a.user_id = ur.user_id and a.city_id = c.city_id"
+                        + " a.city_id as org_id, c.area_name as org_name, a.area_id as area"
+                        + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_area c, sqmdb_rpt.acl_user_role_city ur "
+                        + " where a.user_id = ur.user_id and a.city_id = c.area_id"
                         + "<if test=\"loginId != null and loginId !=''\">"
                         + " and a.login_name=#{loginId} "
                         + "</if>"
@@ -99,4 +97,6 @@ public interface UserDao extends BaseMapper<User> {
 
         @Select("select user_id from sqmdb_rpt.acl_user au where au.login_name = #{loginName}")
         Integer hasLoginName(String loginName);
+
+        List<User> getByRoleIds(List<Integer> roleIds, List<Integer> cityIds);
 }

+ 4 - 0
src/main/java/com/nokia/dao/UserRoleDao.java

@@ -5,6 +5,10 @@ import com.nokia.pojo.UserRole;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 
+/*
+ * 已弃用代码
+ */
+@Deprecated
 @Mapper
 public interface UserRoleDao extends BaseMapper<UserRole> {
 

+ 21 - 0
src/main/java/com/nokia/pojo/Area.java

@@ -0,0 +1,21 @@
+package com.nokia.pojo;
+
+import lombok.Data;
+
+/*
+ * 行政区划
+ */
+@Data
+public class Area {
+    // 每个区域会有1个唯一Id
+    private Integer areaId;
+    // 行政区中文名
+    private String areaName;
+    // 省 province 1 地市 city 2 区县 area 3
+    private String areaType;
+    private Integer typeCode;
+    // 上一级行政区的id
+    private Integer parentId;
+    // 上一级行政区
+    private Area parent;
+}

+ 1 - 0
src/main/java/com/nokia/pojo/City.java

@@ -10,6 +10,7 @@ import java.io.Serializable;
 /**
  * 城市
  */
+@Deprecated
 @Data
 @TableName("sqmdb_rpt.acl_city")
 public class City implements Serializable {

+ 1 - 0
src/main/java/com/nokia/pojo/District.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 
 import lombok.Data;
 
+@Deprecated
 @Data
 @TableName("sqmdb_rpt.acl_district")
 public class District {

+ 1 - 1
src/main/java/com/nokia/pojo/Role.java

@@ -17,5 +17,5 @@ public class Role implements Serializable {
     private String roleName;
     private String system;
     @TableField(exist = false)
-    private List<City> cities;
+    private List<Area> cities;
 }

+ 10 - 3
src/main/java/com/nokia/pojo/User.java

@@ -16,12 +16,19 @@ public class User implements Serializable {
     private String userName;
     private String phone;
     private String email;
+    // 所属省
+    private Integer provinceId;
+    @TableField(exist = false)
+    private Area province;
+    // 所处地市
     private Integer cityId;
-    // 需要从city表中对应
     @TableField(exist = false)
-    private City city;
+    private Area city;
     // 所属区县 为空表示不归属区县 归属于地市
-    private String district;
+    private Integer areaId;
+    @TableField(exist = false)
+    private Area area;
+
     @TableField(exist = false)
     private Set<Role> roles;
 }

+ 1 - 0
src/main/java/com/nokia/pojo/UserRole.java

@@ -5,6 +5,7 @@ import lombok.Data;
 
 import java.util.Date;
 
+@Deprecated
 @Data
 @TableName("sqmdb_rpt.acl_user_role")
 public class UserRole {

+ 4 - 0
src/main/java/com/nokia/service/CityService.java

@@ -5,6 +5,10 @@ import com.nokia.dao.CityDao;
 import com.nokia.pojo.City;
 import org.springframework.stereotype.Service;
 
+/*
+ * 已弃用代码
+ */
+@Deprecated
 @Service
 public class CityService extends ServiceImpl<CityDao, City> {
 

+ 21 - 1
src/main/java/com/nokia/service/FlowService.java

@@ -2,11 +2,18 @@ package com.nokia.service;
 
 import com.nokia.dao.UserDao;
 import com.nokia.pojo.Role;
-import com.nokia.vo.*;
+import com.nokia.pojo.User;
+import com.nokia.vo.flow.FlowRoleVo;
+import com.nokia.vo.flow.FlowUserVo;
+import com.nokia.vo.flow.UserTreeReq;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class FlowService {
@@ -53,4 +60,17 @@ public class FlowService {
     public List<Role> getRoleCityByUserId(Integer userId) {
         return userDao.getRoleCityByUserId(userId);
     }
+
+    public Map<String, Object> getUserTree(UserTreeReq userTreeReq) {
+        List<Integer> cityIds = new ArrayList<>();
+        if (userTreeReq.getCity() == -1) {
+            cityIds = null;
+        } else {
+            cityIds.add(-1);
+            cityIds.add(userTreeReq.getCity());
+        }
+        List<User> users = userDao.getByRoleIds(userTreeReq.getRole(), cityIds);
+        Map<String, Object> result = new HashMap<>();
+        return result;
+    }
 }

+ 10 - 128
src/main/java/com/nokia/service/UserService.java

@@ -1,40 +1,29 @@
 package com.nokia.service;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.nokia.dao.CityDao;
 import com.nokia.dao.UserDao;
 import com.nokia.dao.UserRoleCityDao;
-import com.nokia.dao.UserRoleDao;
-import com.nokia.pojo.City;
+import com.nokia.pojo.Area;
 import com.nokia.pojo.Role;
 import com.nokia.pojo.User;
-import com.nokia.pojo.UserRole;
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
 @Service
 public class UserService extends ServiceImpl<UserDao, User> {
 
     private final UserDao userDao;
-    private final UserRoleDao userRoleDao;
     private final UserRoleCityDao userRoleCityDao;
-    private final CityDao cityDao;
 
     @Autowired
-    public UserService(UserDao userDao, UserRoleDao userRoleDao, CityDao cityDao, UserRoleCityDao userRoleCityDao) {
+    public UserService(UserDao userDao, UserRoleCityDao userRoleCityDao) {
         this.userDao = userDao;
-        this.userRoleDao = userRoleDao;
-        this.cityDao = cityDao;
         this.userRoleCityDao = userRoleCityDao;
     }
 
@@ -72,37 +61,8 @@ public class UserService extends ServiceImpl<UserDao, User> {
      * @param city
      * @return
      */
-    public boolean hasRoleCity(User user, Role role, City city) {
-        return null != userRoleCityDao.hasRoleCity(user.getUserId(), role.getRoleId(), city.getCityId());
-    }
-
-    /**
-     * 给用户添加权限
-     * 
-     * @param user
-     * @param role
-     * @return
-     */
-    public String addRole(User user, Role role, City city) {
-        if (!hasRole(user, role)) {
-            // 检查用户,确认当前无此权限
-            UserRole userRoleEntity = new UserRole();
-            userRoleEntity.setUserId(user.getUserId());
-            userRoleEntity.setRoleId(role.getRoleId());
-            userRoleDao.insert(userRoleEntity);
-        }
-        return "ok";
-    }
-
-    /**
-     * 判断用户是否有有某个角色
-     * 
-     * @param user
-     * @param role
-     * @return boolean
-     */
-    public boolean hasRole(User user, Role role) {
-        return null != userRoleDao.hasRole(user.getUserId(), role.getRoleId());
+    public boolean hasRoleCity(User user, Role role, Area city) {
+        return null != userRoleCityDao.hasRoleCity(user.getUserId(), role.getRoleId(), city.getAreaId());
     }
 
     /**
@@ -119,64 +79,12 @@ public class UserService extends ServiceImpl<UserDao, User> {
         if (one != null) {
             return "loginName: " + user.getLoginName() + " 已存在";
         } else {
-            user.setCityId(user.getCity().getCityId());
+            user.setCityId(user.getCity().getAreaId());
             baseMapper.insert(user);
-            // Set<Role> roles = user.getRoles();
-            // UserRoleCity userRoleCity;
-            // for (Role role : roles) {
-            // for (Integer cityId : role.getCities()) {
-            // userRoleCity = new UserRoleCity();
-            // userRoleCity.setRoleId(role.getRoleId());
-            // userRoleCity.setUserId(user.getUserId());
-            // userRoleCity.setCityId(cityId);
-            // userRoleCityDao.insert(userRoleCity);
-            // }
-            // }
-        }
-        return "ok";
-    }
-
-    @Transactional
-    public String delete(Integer userId) {
-        // UserEntity userEntity = baseMapper.selectById(userId);
-        /* cityDao.deleteById(userEntity.getCityId()); */
-        QueryWrapper<UserRole> objectQueryWrapper = new QueryWrapper<>();
-        objectQueryWrapper.eq("user_id", userId);
-        List<UserRole> userRoleEntities = userRoleDao.selectList(objectQueryWrapper);
-        for (UserRole userRoleEntity : userRoleEntities) {
-            Integer id = userRoleEntity.getId();
-            userRoleDao.deleteById(id);
         }
-        baseMapper.deleteById(userId);
         return "ok";
     }
 
-    /**
-     * 更新用户
-     * 
-     * @param user
-     * @return
-     */
-    @Transactional
-    public boolean update(User user) {
-        // 更新user表
-        baseMapper.updateById(user);
-        // 更新user_role 分为2步
-        Integer userId = user.getUserId();
-        QueryWrapper<UserRole> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("user_id", userId);
-        // 1. 删除原user_role
-        userRoleDao.delete(queryWrapper);
-        // 2. 添加新的user_role
-        for (Role role : user.getRoles()) {
-            UserRole userRoleEntity = new UserRole();
-            userRoleEntity.setUserId(user.getUserId());
-            userRoleEntity.setRoleId(role.getRoleId());
-            userRoleDao.insert(userRoleEntity);
-        }
-        return true;
-    }
-
     /**
      * 通过用户的登录名获取用户完整信息
      * 
@@ -187,30 +95,4 @@ public class UserService extends ServiceImpl<UserDao, User> {
         return userDao.getByLoginName(loginName);
     }
 
-    public Map<String, Object> select(Integer userId) {
-        Map<String, Object> hashMap = new HashMap<>();
-        if (userId == null) {
-            hashMap.put("userId", "为空");
-            return hashMap;
-        }
-        User userEntity = baseMapper.selectById(userId);
-        QueryWrapper<User> userEntityQueryWrapper = new QueryWrapper<>();
-        userEntityQueryWrapper.eq("user_id", userId);
-        User one = baseMapper.selectOne(userEntityQueryWrapper);
-        if (one == null) {
-            hashMap.put("userId", "不正确");
-            return hashMap;
-        }
-        Integer cityId = userEntity.getCityId();
-        City cityEntity = cityDao.selectById(cityId);
-        // 他有两个角色 对 我知道 用for遍历来查 不需要for遍历查
-        QueryWrapper<UserRole> objectQueryWrapper = new QueryWrapper<>();
-        objectQueryWrapper.eq("user_id", userId);
-        List<UserRole> userRoleEntities = userRoleDao.selectList(objectQueryWrapper);
-        hashMap.put("userEntity", userEntity);
-        hashMap.put("cityEntity", cityEntity);
-        hashMap.put("userRoleEntities", userRoleEntities);
-        return hashMap;
-    }
-
 }

+ 2 - 2
src/main/java/com/nokia/vo/DapingUserVo.java

@@ -29,12 +29,12 @@ public class DapingUserVo {
     public DapingUserVo(User user) {
         this.userId = user.getUserId();
         this.userName = user.getUserName();
-        this.province = user.getCity().getProvince();
+        this.province = user.getProvince().getAreaName();
         // this.belongCity = user.getCity().getCityNameZh();
         // 根据权限进行city赋权
         for (Role role : user.getRoles()) {
             if ("daping".equals(role.getSystem())) {
-                this.city = role.getCities().get(0).getCityNameZh();
+                this.city = role.getCities().get(0).getAreaName();
             }
         }
     }

+ 1 - 1
src/main/java/com/nokia/vo/FenxiUserVo.java

@@ -32,7 +32,7 @@ public class FenxiUserVo {
         // 根据角色进行city赋权
         for (Role role : user.getRoles()) {
             if ("fenxi".equals(role.getSystem())) {
-                this.city = role.getCities().get(0).getCityNameZh();
+                this.city = role.getCities().get(0).getAreaName();
             }
         }
     }

+ 2 - 2
src/main/java/com/nokia/vo/HeidiankuUserVo.java

@@ -28,13 +28,13 @@ public class HeidiankuUserVo {
     public HeidiankuUserVo(User userEntity) {
         this.loginName = userEntity.getLoginName();
         this.userName = userEntity.getUserName();
-        this.province = userEntity.getCity().getProvince();
+        this.province = userEntity.getProvince().getAreaName();
         // this.belongCity = userEntity.getCity().getCityNameZh();
         List<String> roles = new ArrayList<>();
         userEntity.getRoles().forEach(role -> {
             if ("heidianku".equals(role.getSystem())) {
                 roles.add(role.getRoleName());
-                this.city = role.getCities().get(0).getCityNameZh();
+                this.city = role.getCities().get(0).getAreaName();
             }
         });
         this.roles = roles;

+ 2 - 2
src/main/java/com/nokia/vo/YuceUserVo.java

@@ -20,11 +20,11 @@ public class YuceUserVo {
     public YuceUserVo(User user) {
         this.userId = user.getUserId();
         this.userName = user.getUserName();
-        this.province = user.getCity().getProvince();
+        this.province = user.getCity().getParent().getAreaName();
         // this.belongCity = user.getCity().getCityNameZh();
         for (Role role : user.getRoles()) {
             if ("yuce".equals(role.getSystem())) {
-                this.city = role.getCities().get(0).getCityId();
+                this.city = role.getCities().get(0).getAreaId();
             }
         }
     }

+ 1 - 1
src/main/java/com/nokia/vo/FlowOrgVo.java → src/main/java/com/nokia/vo/flow/FlowOrgVo.java

@@ -1,4 +1,4 @@
-package com.nokia.vo;
+package com.nokia.vo.flow;
 
 import lombok.Data;
 

+ 4 - 4
src/main/java/com/nokia/vo/FlowRoleCityVo.java → src/main/java/com/nokia/vo/flow/FlowRoleCityVo.java

@@ -1,9 +1,9 @@
-package com.nokia.vo;
+package com.nokia.vo.flow;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import com.nokia.pojo.City;
+import com.nokia.pojo.Area;
 import com.nokia.pojo.Role;
 
 import lombok.Data;
@@ -21,8 +21,8 @@ public class FlowRoleCityVo {
         this.roleId = role.getRoleId();
         this.roleName = role.getRoleName();
         this.cities = new ArrayList<>();
-        for (City city : role.getCities()) {
-            this.cities.add(city.getCityId());
+        for (Area city : role.getCities()) {
+            this.cities.add(city.getAreaId());
         }
     }
 }

+ 1 - 1
src/main/java/com/nokia/vo/FlowRoleVo.java → src/main/java/com/nokia/vo/flow/FlowRoleVo.java

@@ -1,4 +1,4 @@
-package com.nokia.vo;
+package com.nokia.vo.flow;
 
 import lombok.Data;
 

+ 6 - 4
src/main/java/com/nokia/vo/FlowUserVo.java → src/main/java/com/nokia/vo/flow/FlowUserVo.java

@@ -1,7 +1,10 @@
-package com.nokia.vo;
+package com.nokia.vo.flow;
 
 import lombok.Data;
 
+/*
+ * 返回给流程的单用户信息
+ */
 @Data
 public class FlowUserVo {
     private Integer userId;
@@ -9,8 +12,7 @@ public class FlowUserVo {
     private String userName;
     private String mobile;
     private String email;
-    // private Integer state;
     private FlowOrgVo org;
-    // 区县 对应 UserEntity 的 district
-    private String area;
+    // 区县Id 对应 User 的 districtId
+    private Integer area;
 }

+ 12 - 0
src/main/java/com/nokia/vo/flow/UserTreeReq.java

@@ -0,0 +1,12 @@
+package com.nokia.vo.flow;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data
+public class UserTreeReq {
+    private Integer city;
+    private List<Integer> role;
+    private List<Integer> user;
+}

+ 21 - 19
src/main/resources/application.properties

@@ -1,34 +1,36 @@
 # web服务端口号
 server.port=12128
-# 数据源
-#spring.datasource.driver-class-name=org.postgresql.Driver
-#spring.datasource.url=jdbc:postgresql://localhost:5432/login
-#spring.datasource.username=postgres
-#spring.datasource.password=postgres
-# log
+
 # log配置
 logging.level.root=info
 logging.level.com.nokia=debug
-logging.file.name=log/acl.log
-
-
-#spring.redis.host=localhost
-#spring.redis.port=6379
-#spring.redis.database=0
+# logging.file.name=log/acl.log
 
-# 正式环境数据源GP数据库配置
+# 测试环境数据库配置
 spring.datasource.driver-class-name=org.postgresql.Driver
-spring.datasource.url=jdbc:postgresql://192.168.70.109:5432/sqmmt
-spring.datasource.username=sqmdb
-spring.datasource.password=sqmdb_1QAZ
+spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
+spring.datasource.username=postgres
+spring.datasource.password=fantuan1985
 
-# 正式环境Redis配置
-spring.redis.host=192.168.70.125
+# 测试环境redis配置
+spring.redis.host=localhost
 spring.redis.port=6379
 spring.redis.database=0
-spring.redis.password=Richr00t
 redis.timeoutSeconds=600
 
+# 正式环境数据源GP数据库配置
+# spring.datasource.driver-class-name=org.postgresql.Driver
+# spring.datasource.url=jdbc:postgresql://192.168.70.109:5432/sqmmt
+# spring.datasource.username=sqmdb
+# spring.datasource.password=sqmdb_1QAZ
+
+# 正式环境Redis配置
+# spring.redis.host=192.168.70.125
+# spring.redis.port=6379
+# spring.redis.database=0
+# spring.redis.password=Richr00t
+# redis.timeoutSeconds=600
+
 top.url=http://10.17.180.3/prod-api/verifySystem
 dop.url=http://10.17.180.5:8089/prod-api/verifySystem
 top.api.fromSystem=dh

+ 46 - 22
src/main/resources/mapper/UserMapper.xml

@@ -7,14 +7,20 @@
         <result column="user_name" property="userName" />
         <result column="phone" property="phone" />
         <result column="email" property="email" />
+        <result column="province_id" property="provinceId" />
         <result column="city_id" property="cityId" />
-        <result column="district" property="district" />
-        <association property="city" column="city_id">
-            <id column="city_id" property="cityId"></id>
-            <result column="city_name_zh" property="cityNameZh" />
-            <result column="city_name_en" property="cityNameEn" />
-            <result column="ord" property="ord" />
-            <result column="province" property="province" />
+        <result column="area_id" property="areaId" />
+        <association column="province_id" property="province">
+            <id column="province_id" property="areaId"></id>
+            <result column="province_Name" property="areaName" />
+        </association>
+        <association column="city_id" property="city">
+            <id column="city_id" property="areaId"></id>
+            <result column="city_name" property="areaName" />
+        </association>
+        <association column="area_id" property="area">
+            <id column="area_id" property="areaId"></id>
+            <result column="area_name" property="areaName" />
         </association>
         <collection property="roles" resultMap="RoleResultMap" />
     </resultMap>
@@ -23,27 +29,45 @@
         <id column="role_id" property="roleId"></id>
         <result column="role_name" property="roleName" />
         <result column="system" property="system" />
-        <collection property="cities" ofType="com.nokia.pojo.City">
-            <result column="role_city_id" property="cityId" />
-            <result column="role_city_name_zh" property="cityNameZh" />
-            <result column="role_city_name_en" property="cityNameEn" />
-            <result column="role_ord" property="ord" />
-            <result column="role_province" property="province" />
+        <collection property="cities" ofType="com.nokia.pojo.Area">
+            <result column="role_city_id" property="areaId" />
+            <result column="role_area_name" property="areaName" />
         </collection>
     </resultMap>
 
     <select id="getRoleCityByUserId" resultMap="RoleResultMap">
-        select ar.role_id, ar.role_name, ar."system", aurc.city_id as role_city_id, ac.city_name_zh as role_city_name_zh,
-          ac.city_name_en as role_city_name_en, ac.ord as role_ord, ac.province as role_province
-          from sqmdb_rpt.acl_role ar, sqmdb_rpt.acl_user_role_city aurc,  sqmdb_rpt.acl_city ac
-          where ar.role_id = aurc.role_id and aurc.city_id = ac.city_id  and aurc.user_id = #{userId}
+        select ar.role_id, ar.role_name, ar."system", aurc.city_id as role_city_id, ac.area_name as role_area_name 
+            from sqmdb_rpt.acl_role ar, sqmdb_rpt.acl_user_role_city aurc,  sqmdb_rpt.acl_area ac
+            where ar.role_id = aurc.role_id and aurc.city_id = ac.area_id  and aurc.user_id = #{userId}
     </select>
 
     <select id="getByLoginName" resultMap="UserResultMap">
-        select au.user_id, au.login_name, au.user_name, au.phone, au.email, au.city_id, ac.city_name_zh, ac.city_name_en, ac.ord, ac.province,
-          au.district, ar.role_id, ar.role_name, ar."system", aurc.city_id as role_city_id, ac2.city_name_zh as role_city_name_zh,
-          ac2.city_name_en as role_city_name_en, ac2.ord as role_ord, ac2.province as role_province
-          from sqmdb_rpt.acl_user au, sqmdb_rpt.acl_role ar, sqmdb_rpt.acl_user_role_city aurc, sqmdb_rpt.acl_city ac,  sqmdb_rpt.acl_city ac2
-          where au.user_id = aurc.user_id and ar.role_id = aurc.role_id and au.city_id = ac.city_id and aurc.city_id = ac2.city_id and au.login_name = #{loginName}
+        select au.user_id, au.login_name, au.user_name, au.phone, au.email, au.province_id, ac.area_name as province_name, 
+            au.city_id, ac2.area_name as city_name, au.area_id, ar.role_id, ar.role_name, ar."system", aurc.city_id as role_city_id, 
+            ac3.area_name as role_area_name 
+        from sqmdb_rpt.acl_user au, sqmdb_rpt.acl_role ar, sqmdb_rpt.acl_user_role_city aurc, sqmdb_rpt.acl_area ac,  sqmdb_rpt.acl_area ac2, sqmdb_rpt.acl_area ac3 
+        where au.user_id = aurc.user_id and ar.role_id = aurc.role_id and au.province_id = ac.area_id 
+            and au.city_id = ac2.area_id and aurc.city_id = ac3.area_id and au.login_name = #{loginName}
+    </select>
+
+    <select id="getByRoleIds" resultMap="UserResultMap">
+        select au.user_id, au.login_name, au.user_name, au.phone, au.email, au.province_id, ac.area_name as province_name, 
+            au.city_id, ac2.area_name as city_name, au.area_id, ar.role_id, ar.role_name, ar."system", aurc.city_id as role_city_id, 
+            ac3.area_name as role_area_name 
+        from sqmdb_rpt.acl_user au, sqmdb_rpt.acl_role ar, sqmdb_rpt.acl_user_role_city aurc, sqmdb_rpt.acl_area ac,  sqmdb_rpt.acl_area ac2, sqmdb_rpt.acl_area ac3 
+        where au.user_id = aurc.user_id and ar.role_id = aurc.role_id and au.province_id = ac.area_id 
+            and au.city_id = ac2.area_id and aurc.city_id = ac3.area_id
+        <if test="roleIds != null">
+            and aurc.role_id in
+            <foreach collection="roleIds" item="item" open="(" separator="," close=")" index="index">
+                #{item}
+            </foreach>
+        </if>
+        <if test="cityIds != null">
+            and aurc.city_id in
+            <foreach collection="cityIds" item="item" open="(" separator="," close=")" index="index">
+                #{item}
+            </foreach>
+        </if>
     </select>
 </mapper>

+ 0 - 95
src/test/java/com/nokia/UserModifyTest.java

@@ -1,95 +0,0 @@
-package com.nokia;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.data.redis.core.RedisTemplate;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.nokia.dao.UserDao;
-import com.nokia.dao.UserRoleCityDao;
-import com.nokia.pojo.Role;
-import com.nokia.pojo.User;
-import com.nokia.pojo.UserRoleCity;
-import com.nokia.service.RoleService;
-import com.nokia.service.UserService;
-
-/**
- * 操作数据库中的用户信息
- */
-@SpringBootTest
-public class UserModifyTest {
-
-    @Autowired
-    private RedisTemplate<String, Object> redisTemplate;
-
-    @Autowired
-    private UserService userService;
-
-    @Autowired
-    private RoleService roleService;
-
-    @Autowired
-    private UserDao userDao;
-
-    @Autowired
-    private UserRoleCityDao userRoleCityDao;
-
-    // 清除redis
-    @Test
-    void test() {
-        Boolean delete = redisTemplate.delete("test_token_abc");
-        System.out.println(delete);
-    }
-
-    // 修改用户--增加黑点库权限
-    @Test
-    void test1() {
-        User user = userService.getByLoginName("test_shijiazhuang");
-        // RoleEntity role = new RoleEntity();
-        // role.setRoleName("黑点库管理");
-        // role = roleService.getOne(Wrappers.query(role));
-        // user.getRoles().add(role);
-        Role role2 = new Role();
-        role2.setRoleName("黑点库查询");
-        role2 = roleService.getOne(Wrappers.query(role2));
-        user.getRoles().add(role2);
-        userService.update(user);
-    }
-
-    @Test
-    void test2() {
-        String str = "{\"no\": \"aaa\"}";
-        JSONObject jsonObject = JSON.parseObject(str);
-        System.out.println(jsonObject);
-        Integer integer = jsonObject.getInteger("no");
-        System.out.println(integer);
-    }
-
-    // 给12个地市的主管加权限
-    @Test
-    void test3() {
-        // int[] ids = new int[] { 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 };
-        // for (int id : ids) {
-        // User user = userDao.selectById(id);
-        // System.out.println(user);
-        // UserRoleCity userRoleCity = new UserRoleCity();
-        // userRoleCity.setUserId(id);
-        // userRoleCity.setRoleId(18);
-        // userRoleCity.setCityId(user.getCityId());
-        // userRoleCityDao.insert(userRoleCity);
-        // }
-
-        int[] roleIds = new int[] { 3, 4, 5, 6, 7, 8, 12, 13};
-        User user = userDao.selectById(24);
-        for (int roleId : roleIds) {
-            UserRoleCity userRoleCity = new UserRoleCity();
-            userRoleCity.setUserId(user.getUserId());
-            userRoleCity.setRoleId(roleId);
-            userRoleCity.setCityId(user.getCityId());
-            userRoleCityDao.insert(userRoleCity);
-        }
-    }
-}

+ 0 - 29
src/test/java/com/nokia/dao/CityDaoTest.java

@@ -1,29 +0,0 @@
-package com.nokia.dao;
-
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.nokia.pojo.City;
-import com.nokia.vo.FlowOrgVo;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-
-import java.util.List;
-
-@SpringBootTest
-public class CityDaoTest {
-
-    @Autowired
-    private CityDao cityDao;
-
-    @Test
-    public void test() {
-        List<City> cities = cityDao.selectList(Wrappers.query());
-        System.out.println(cities);
-    }
-
-    @Test
-    public void testFindOrgByCityId() {
-        FlowOrgVo vo = cityDao.findOrgByCityId(130100);
-        System.out.println(vo);
-    }
-}

+ 28 - 13
src/test/java/com/nokia/dao/UserDaoTest.java

@@ -2,9 +2,10 @@ package com.nokia.dao;
 
 import com.nokia.pojo.Role;
 import com.nokia.pojo.User;
-import com.nokia.vo.FlowRoleVo;
-import com.nokia.vo.FlowUserVo;
+import com.nokia.vo.flow.FlowRoleVo;
+import com.nokia.vo.flow.FlowUserVo;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.junit.jupiter.api.Test;
@@ -17,12 +18,6 @@ public class UserDaoTest {
     @Autowired
     UserDao userDao;
 
-    @Test
-    void testGetFlowUserVoByUserId() {
-        FlowUserVo flowUserVo = userDao.getFlowUserVoByUserId(3);
-        System.out.println(flowUserVo);
-    }
-
     @Test
     void testFindRoleList() {
         List<FlowRoleVo> flowRoleVos = userDao.findRoleList("测试用户_全省");
@@ -43,7 +38,13 @@ public class UserDaoTest {
 
     @Test
     void testGetFlowUserVoByLoginId() {
-        FlowUserVo flowUserVo = userDao.getFlowUserVoByLoginId("test_hebei");
+        FlowUserVo flowUserVo = userDao.getFlowUserVoByLoginId("test_hengshui");
+        System.out.println(flowUserVo);
+    }
+
+    @Test
+    void testGetFlowUserVoByUserId() {
+        FlowUserVo flowUserVo = userDao.getFlowUserVoByUserId(3);
         System.out.println(flowUserVo);
     }
 
@@ -66,14 +67,28 @@ public class UserDaoTest {
     }
 
     @Test
-    void testGetByLoginName2() {
+    void testGetRoleCityByUserId() {
+        List<Role> roles = userDao.getRoleCityByUserId(4);
+        System.out.println(roles);
+    }
+
+    @Test
+    void testGetByLoginName() {
         User user = userDao.getByLoginName("test_hengshui");
         System.out.println(user);
     }
 
     @Test
-    void testGetRoleCityByUserId() {
-        List<Role> roles = userDao.getRoleCityByUserId(4);
-        System.out.println(roles);
+    void testGetByRoleIds() {
+        List<Integer> roleIds = new ArrayList<>();
+        roleIds.add(4);
+        roleIds.add(3);
+
+        List<Integer> cityIds = new ArrayList<>();
+        cityIds.add(-1);
+        cityIds.add(130100);
+
+        List<User> users = userDao.getByRoleIds(roleIds, cityIds);
+        System.out.println(users);
     }
 }

+ 0 - 19
src/test/java/com/nokia/dao/UserRoleDaoTest.java

@@ -1,19 +0,0 @@
-package com.nokia.dao;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-public class UserRoleDaoTest {
-
-    @Autowired
-    private UserRoleDao userRoleDao;
-
-    @Test
-    public void testHasRole() {
-        Integer role_id = userRoleDao.hasRole(2, 4);
-        System.out.println(role_id);
-    }
-
-}

+ 0 - 12
src/test/java/com/nokia/service/UserServiceTest.java

@@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import com.nokia.pojo.Role;
 import com.nokia.pojo.User;
 
 @SpringBootTest
@@ -13,9 +12,6 @@ public class UserServiceTest {
     @Autowired
     private UserService userService;
 
-    @Autowired
-    private RoleService roleService;
-
     @Test
     void testAdd() {
         User userEntity = new User();
@@ -34,14 +30,6 @@ public class UserServiceTest {
         System.out.println(user);
     }
 
-    @Test
-    void testHasRole() {
-        User user = userService.getByLoginName("test_123");
-        Role role = roleService.getByRoleName("投诉大屏");
-        boolean hasRole = userService.hasRole(user, role);
-        System.out.println(hasRole);
-    }
-
     @Test
     void testAddRole() {
         // User user = userService.getByLoginName("test_123");