Browse Source

个人信息管理功能开发

zhaoyan 3 years ago
parent
commit
018b26ff75
17 changed files with 275 additions and 15 deletions
  1. 3 0
      api-common/src/main/java/api/common/pojo/param/scene/SystemScenePackageParam.java
  2. 1 0
      api-common/src/main/java/api/common/pojo/po/system/UserPO.java
  3. 1 0
      api-common/src/main/java/api/common/pojo/vo/scene/SystemScenePackageVO.java
  4. 2 0
      api-common/src/main/java/api/common/pojo/vo/system/UserVO.java
  5. 0 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java
  6. 2 11
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserCtrl.java
  7. 155 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserInfoCtrl.java
  8. 2 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java
  9. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java
  10. 6 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/UserMapper.java
  11. 14 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ClusterService.java
  12. 17 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ParameterService.java
  13. 23 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/UserService.java
  14. 8 2
      simulation-resource-server/src/main/resources/mapper/scene/SystemScenePackageMapper.xml
  15. 4 0
      simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml
  16. 6 0
      simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml
  17. 30 1
      simulation-resource-server/src/main/resources/mapper/system/UserMapper.xml

+ 3 - 0
api-common/src/main/java/api/common/pojo/param/scene/SystemScenePackageParam.java

@@ -21,6 +21,9 @@ public class SystemScenePackageParam extends CommonPO   implements Serializable
     private String packageName;        // 场景包名
     private String sceneDescribe;          // 场景包描述
     private String userName;          // 账号名称
+    private String userId;          // 账号id
+
+
 
     public String yearMax;//结束时间
 

+ 1 - 0
api-common/src/main/java/api/common/pojo/po/system/UserPO.java

@@ -10,6 +10,7 @@ public class UserPO extends CommonPO {
     private String username;        // 登录用户名
     private String nickname;        // 用户昵称,用于显示
     private String password;        // 密码(加密)
+    private String newPassword;        // 新密码
     private String phone;           // 联系电话
     private String photo;           // 头像
     private String company;         // 所属公司

+ 1 - 0
api-common/src/main/java/api/common/pojo/vo/scene/SystemScenePackageVO.java

@@ -24,6 +24,7 @@ public class SystemScenePackageVO extends CommonPO implements Serializable {
     private Integer bzCount;            // 标准法规数量
     private Integer jtCount;            // 交通事故数量
     private Integer fhCount;          // 泛化数量
+    private Integer totalCount;          // 总数量
 
     private String userId;
     private String userName;

+ 2 - 0
api-common/src/main/java/api/common/pojo/vo/system/UserVO.java

@@ -15,7 +15,9 @@ public class UserVO {
     private String photo;           // 头像
     private String company;         // 所属公司
     private String roleCode;       // 账户角色类型
+    private String roleCodeName;       // 账户角色类型名称
     private String useType;       // 占用类型
+    private String useTypeName;       // 占用类型名称
     private String visible;         // 是否启用
     public Timestamp createTime;    //创建时间
     public String createUserName;    //创建人

+ 0 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java

@@ -73,5 +73,4 @@ public class ParameterCtrl {
         return response;
     }
 
-
 }

+ 2 - 11
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserCtrl.java

@@ -21,17 +21,6 @@ public class UserCtrl {
     @Autowired
     UserService userService;
 
-    /**
-     * 获取当前登录人详情
-     */
-    @RequestMapping("/getCurrentUserInfo")
-    @ResponseBody
-    public ResponseBodyVO getCurrentUserInfo() {
-        ResponseBodyVO<UserVO> response = new ResponseBodyVO<UserVO>(ResponseBodyVO.Response.SUCCESS);
-        response.setInfo(userService.getCurrentUserInfo());
-        return response;
-    }
-
     /**
      * 获取人员列表
      */
@@ -95,4 +84,6 @@ public class UserCtrl {
         userService.saveVisible(userPO);
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
     }
+
+
 }

+ 155 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserInfoCtrl.java

@@ -0,0 +1,155 @@
+package com.css.simulation.resource.system.ctrl;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.scene.SystemScenePackageParam;
+import api.common.pojo.po.system.UserPO;
+import api.common.pojo.vo.scene.SystemScenePackageVO;
+import api.common.pojo.vo.system.ClusterVO;
+import api.common.pojo.vo.system.ParameterVO;
+import api.common.pojo.vo.system.UserVO;
+import api.common.util.ObjectUtil;
+import com.css.simulation.resource.common.utils.AuthUtil;
+import com.css.simulation.resource.scene.service.SystemScenePackageService;
+import com.css.simulation.resource.system.service.ClusterService;
+import com.css.simulation.resource.system.service.ParameterService;
+import com.css.simulation.resource.system.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.List;
+
+
+@Controller()
+@RequestMapping("/userInfo")
+public class UserInfoCtrl {
+
+
+    @Autowired
+    UserService userService;
+
+    @Autowired
+    ClusterService clusterService;
+
+    @Autowired
+    ParameterService parameterService;
+
+    @Resource
+    SystemScenePackageService systemScenePackageService;
+
+
+    /**
+     * 获取当前登录人详情
+     */
+    @RequestMapping("/getCurrentUserInfo")
+    @ResponseBody
+    public ResponseBodyVO getCurrentUserInfo() {
+        ResponseBodyVO<UserVO> response = new ResponseBodyVO<UserVO>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(userService.getCurrentUserInfo());
+        return response;
+    }
+
+
+    /**
+     * 根据user_id查询参数配置信息
+     */
+    @RequestMapping("/getParameterByUserId")
+    @ResponseBody
+    public ResponseBodyVO<ParameterVO> getParameterByUserId() {
+        ResponseBodyVO<ParameterVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        ParameterVO param = parameterService.getParameterByUserId();
+        response.setInfo(param);
+        return response;
+    }
+
+    /**
+     * 根据user_id查询集群配置信息
+     */
+    @RequestMapping("/getClusterByUserId")
+    @ResponseBody
+    public ResponseBodyVO<ClusterVO> getClusterByUserId() {
+        ResponseBodyVO<ClusterVO> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        ClusterVO clusterVO = clusterService.getClusterByUserId();
+        response.setInfo(clusterVO);
+        return response;
+    }
+
+    /**
+     * 获取当前登录人详情
+     */
+    @RequestMapping("/getSceneResource")
+    @ResponseBody
+    public ResponseBodyVO getSceneResource() {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String userId = AuthUtil.getCurrentUserId();
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
+            return null;
+        }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
+            //查询父账户
+            userId = AuthUtil.getCreateUserId();
+        }
+        SystemScenePackageParam param = new SystemScenePackageParam();
+        param.setUserId(userId);
+        List<SystemScenePackageVO> list = systemScenePackageService.querySystemScenePackageList(param);
+        long zrTotalCount = list.stream().mapToLong(SystemScenePackageVO::getZrCount).sum();
+        long bzTotalCount = list.stream().mapToLong(SystemScenePackageVO::getBzCount).sum();
+        long jtTotalCount = list.stream().mapToLong(SystemScenePackageVO::getJtCount).sum();
+        long fhTotalCount = list.stream().mapToLong(SystemScenePackageVO::getFhCount).sum();
+        long sum = list.stream().mapToLong(SystemScenePackageVO::getTotalCount).sum();
+        HashMap resMap = new HashMap();
+        resMap.put("list", list);
+        resMap.put("zrTotalCount", zrTotalCount);
+        resMap.put("bzTotalCount", bzTotalCount);
+        resMap.put("jtTotalCount", jtTotalCount);
+        resMap.put("fhTotalCount", fhTotalCount);
+        resMap.put("sum", sum);
+
+        ResponseBodyVO<HashMap> response = new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(resMap);
+        return response;
+    }
+
+    /**
+     * 个人信息管理-修改联系方式
+     */
+    @RequestMapping("/savePhone")
+    @ResponseBody
+    public ResponseBodyVO savePhone(@RequestBody UserPO userPO) {
+        if(ObjectUtil.isNull(userPO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        if(ObjectUtil.isNull(userPO.getId()) || ObjectUtil.isNull(userPO.getNickname())|| ObjectUtil.isNull(userPO.getPhone())){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        userService.savePhone(userPO);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+    /**
+     * 个人信息管理-修改密码
+     */
+    @RequestMapping("/savePassword")
+    @ResponseBody
+    public ResponseBodyVO savePassword(@RequestBody UserPO userPO) throws NoSuchAlgorithmException {
+        if(ObjectUtil.isNull(userPO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        if(ObjectUtil.isNull(userPO.getId()) || ObjectUtil.isNull(userPO.getPassword()) || ObjectUtil.isNull(userPO.getNewPassword())){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        UserPO userPORes = userService.savePassword(userPO);
+        if(ObjectUtil.isNull(userPORes)){
+            return new ResponseBodyVO(false, 400, "原密码错误!",null);
+        }
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
+
+
+
+}

+ 2 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java

@@ -25,4 +25,6 @@ public interface ClusterMapper {
     HashMap<String, Integer> getClusterNum(ClusterParam clusterParam);
 
     Integer getLicenseNum(@Param("userId") String userId);
+
+    ClusterVO getClusterByUserId(String userId);
 }

+ 1 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java

@@ -24,4 +24,5 @@ public interface ParameterMapper {
 
     HashMap<String, Integer> getSceneParam(@Param("userId") String userId);
 
+    ParameterVO getParameterByUserId(String userId);
 }

+ 6 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/UserMapper.java

@@ -32,4 +32,10 @@ public interface UserMapper {
     void saveDefaultPassword(UserPO userPO);
 
     void saveVisible(UserPO userPO);
+
+    void savePhone(UserPO userPO);
+
+    List<UserPO> checkPassword(UserPO userPO);
+
+    void savePassword(UserPO userPO);
 }

+ 14 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ClusterService.java

@@ -117,4 +117,18 @@ public class ClusterService {
         }
         return simulationLicenseNum;
     }
+
+    public ClusterVO getClusterByUserId() {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String useType = AuthUtil.getCurrentUseType();
+        String userId = AuthUtil.getCurrentUserId();
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
+            return null;
+        }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode) && DictConstants.USE_TYPE_PUBLIC.equals(useType)){
+            //查询父账户
+            userId = AuthUtil.getCreateUserId();
+        }
+        ClusterVO clusterVO = clusterMapper.getClusterByUserId(userId);
+        return clusterVO;
+    }
 }

+ 17 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ParameterService.java

@@ -73,4 +73,21 @@ public class ParameterService {
         return sceneParam;
     }
 
+    public ParameterVO getParameterByUserId() {
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String userId = AuthUtil.getCurrentUserId();
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){ //管理员账户
+            return null;
+        }else if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
+            //查询父账户
+            userId = AuthUtil.getCreateUserId();
+        }
+        ParameterVO param = parameterMapper.getParameterByUserId(userId);
+        if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){ //普通账户子账户设置可创建子账号数量为0
+            param.setNumCreateUser(0);
+        }
+
+        return param;
+
+    }
 }

+ 23 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/UserService.java

@@ -41,6 +41,10 @@ public class UserService {
     public UserVO getCurrentUserInfo() {
         String userId = AuthUtil.getCurrentUserId();
         UserVO userVO = userMapper.getUserInfo(userId);
+        Map<String, String> useTypeDictMap = dictService.getDictMapByType(DictConstants.USE_TYPE);
+        userVO.setUseTypeName(useTypeDictMap.get(userVO.getUseType()));
+        Map<String, String> roleCodeDictMap = dictService.getDictMapByType(DictConstants.ROLE_CODE);
+        userVO.setRoleCodeName(roleCodeDictMap.get(userVO.getRoleCode()));
         return userVO;
     }
 
@@ -126,4 +130,23 @@ public class UserService {
         }
 
     }
+
+    public void savePhone(UserPO userPO) {
+        PoUtil.initUpdatePo(userPO);
+        userMapper.savePhone(userPO);
+    }
+
+    public UserPO savePassword(UserPO userPO) throws NoSuchAlgorithmException {
+        //确认原密码是否正确
+        userPO.setPassword(EncryptUtil.getLowerMD5(userPO.getPassword()));
+        List<UserPO> list = userMapper.checkPassword(userPO);
+        if(ObjectUtil.isNull(list)){
+            return null;
+        }
+        //修改密码
+        userPO.setPassword(EncryptUtil.getLowerMD5(userPO.getNewPassword()));
+        PoUtil.initUpdatePo(userPO);
+        userMapper.savePassword(userPO);
+        return userPO;
+    }
 }

+ 8 - 2
simulation-resource-server/src/main/resources/mapper/scene/SystemScenePackageMapper.xml

@@ -26,13 +26,19 @@
         SUM(CASE WHEN s.scene_type = '1' THEN 1 ELSE 0 END) as zrCount,
         SUM(CASE WHEN s.scene_type = '2' THEN 1 ELSE 0 END) as bzCount,
         SUM(CASE WHEN s.scene_type = '3' THEN 1 ELSE 0 END) as jtCount,
-        SUM(CASE WHEN s.scene_type = '4' THEN 1 ELSE 0 END) as fhCount
+        SUM(CASE WHEN s.scene_type = '4' THEN 1 ELSE 0 END) as fhCount,
+        SUM(1) as totalCount
         FROM (
         select
         p.*,
         COUNT(u.id) as userCount
         FROM system_scene_package p
-        JOIN system_user_scene u on p.id = u.scene_id and u.is_deleted = '0' and p.is_deleted = '0'
+        JOIN system_user_scene u on p.id = u.package_id and u.is_deleted = '0' and p.is_deleted = '0'
+        <where>
+            <if test="userId != null and userId != ''">
+                and u.user_id = #{userId,jdbcType=VARCHAR}
+            </if>
+        </where>
         GROUP BY p.id
         ) t
         JOIN system_scene_package_sublist s on t.id = s.scene_and_package

+ 4 - 0
simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml

@@ -136,4 +136,8 @@
         select num_simulation_license from system_cluster
         where is_deleted = '0' and DATE(date_simulation_license) >= DATE(NOW()) and user_id = #{userId,jdbcType=VARCHAR}
     </select>
+    <select id="getClusterByUserId" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.ClusterVO">
+        select num_simulation_license, date_simulation_license, num_dynamic_license, date_dynamic_license from system_cluster
+        where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
+    </select>
 </mapper>

+ 6 - 0
simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml

@@ -86,5 +86,11 @@
         where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
     </select>
 
+    <select id="getParameterByUserId" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.ParameterVO">
+        select num_create_user, num_scene_per_package, num_create_scene_package
+        from system_parameter
+        where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
+    </select>
+
 
 </mapper>

+ 30 - 1
simulation-resource-server/src/main/resources/mapper/system/UserMapper.xml

@@ -11,7 +11,8 @@
             photo,
             phone,
             company,
-            role_code
+            role_code,
+            use_type
         FROM system_user WHERE id = #{userId,jdbcType=VARCHAR}
     </select>
 
@@ -95,6 +96,17 @@
         </if>
     </select>
 
+    <select id="checkPassword" resultType="api.common.pojo.po.system.UserPO">
+        select
+        id
+        from system_user
+        where is_deleted = '0'
+        and password = #{password,jdbcType=VARCHAR}
+        <if test="id != null and id != ''">
+            and id = #{id,jdbcType=VARCHAR}
+        </if>
+    </select>
+
     <insert id="insert" parameterType="api.common.pojo.po.system.UserPO">
         INSERT INTO system_user(
             id,
@@ -162,5 +174,22 @@
         where id = #{id,jdbcType=VARCHAR}
     </update>
 
+    <update id="savePhone" parameterType="api.common.pojo.po.system.UserPO">
+        update system_user set
+            nickname = #{nickname,jdbcType=VARCHAR},
+            phone = #{phone,jdbcType=VARCHAR},
+            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
+    <update id="savePassword" parameterType="api.common.pojo.po.system.UserPO">
+        update system_user set
+            password = #{password,jdbcType=VARCHAR},
+            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
 
 </mapper>