浏览代码

用户管理

WXF 3 年之前
父节点
当前提交
152f0518ef

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

@@ -14,6 +14,7 @@ public class UserPO extends CommonPO {
     private String photo;           // 头像
     private String company;         // 所属公司
     private String roleCode;       // 账户角色类型
+    private String useType;       // 占用类型
     private String visible;         // 是否启用
     private String openid;          // 众工业平台的 openid
 }

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

@@ -2,6 +2,8 @@ package api.common.pojo.vo.system;
 
 import lombok.Data;
 
+import java.sql.Timestamp;
+
 @Data
 public class UserVO {
 
@@ -13,7 +15,10 @@ public class UserVO {
     private String photo;           // 头像
     private String company;         // 所属公司
     private String roleCode;       // 账户角色类型
+    private String useType;       // 占用类型
     private String visible;         // 是否启用
+    public Timestamp createTime;    //创建时间
+    public String createUserName;    //创建人
     //private String openid;          // 众工业平台的 openid
 
 }

+ 23 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/UserCtrl.java

@@ -69,8 +69,30 @@ public class UserCtrl {
      */
     @RequestMapping("/saveDefaultPassword")
     @ResponseBody
-    public ResponseBodyVO<PageInfo<UserVO>> saveDefaultPassword(@RequestBody UserPO userPO) throws Exception {
+    public ResponseBodyVO saveDefaultPassword(@RequestBody UserPO userPO) throws Exception {
+        if(ObjectUtil.isNull(userPO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        if(ObjectUtil.isNull(userPO.getId())){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
         userService.saveDefaultPassword(userPO);
         return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
     }
+
+    /**
+     * 启用/停用账户
+     */
+    @RequestMapping("/saveVisible")
+    @ResponseBody
+    public ResponseBodyVO saveVisible(@RequestBody UserPO userPO) throws Exception {
+        if(ObjectUtil.isNull(userPO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        if(ObjectUtil.isNull(userPO.getId()) || ObjectUtil.isNull(userPO.getVisible())){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        userService.saveVisible(userPO);
+        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+    }
 }

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

@@ -30,4 +30,6 @@ public interface UserMapper {
     void update(UserPO userPO);
 
     void saveDefaultPassword(UserPO userPO);
+
+    void saveVisible(UserPO userPO);
 }

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

@@ -1,6 +1,7 @@
 package com.css.simulation.resource.system.service;
 
 import api.common.pojo.constants.DictConstants;
+import api.common.pojo.constants.LogConstants;
 import api.common.pojo.param.system.UserParam;
 import api.common.pojo.po.system.UserPO;
 import api.common.pojo.vo.system.UserVO;
@@ -11,6 +12,7 @@ import com.css.simulation.resource.common.oauth.OauthParameter;
 import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.common.utils.PoUtil;
+import com.css.simulation.resource.log.service.LogService;
 import com.css.simulation.resource.system.mapper.UserMapper;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,8 @@ public class UserService {
     @Autowired
     OauthParameter oauthParameter;
 
+    @Autowired
+    LogService logService;
 
     public UserVO getCurrentUserInfo() {
         String userId = AuthUtil.getCurrentUserId();
@@ -84,8 +88,10 @@ public class UserService {
             userPO.setPassword(EncryptUtil.getLowerMD5(oauthParameter.getSimulationDefaultPassword()));
             userPO.setVisible("1");
             userMapper.insert(userPO);
+            logService.logUser(LogConstants.SYS_LOG_USER_INSERT,userPO);
         }else{
             userMapper.update(userPO);
+            logService.logUser(LogConstants.SYS_LOG_USER_UPDATE,userPO);
         }
         //密码清空
         userPO.setPassword(null);
@@ -96,5 +102,17 @@ public class UserService {
         userPO.setPassword(EncryptUtil.getLowerMD5(oauthParameter.getSimulationDefaultPassword()));
         PoUtil.initUpdatePo(userPO);
         userMapper.saveDefaultPassword(userPO);
+        logService.logUser(LogConstants.SYS_LOG_USER_RESET,userPO);
+    }
+
+    public void saveVisible(UserPO userPO) {
+        PoUtil.initUpdatePo(userPO);
+        userMapper.saveVisible(userPO);
+        if("1".equals(userPO.getVisible())){
+            logService.logUser(LogConstants.SYS_LOG_USER_START,userPO);
+        }else{
+            logService.logUser(LogConstants.SYS_LOG_USER_STOP,userPO);
+        }
+
     }
 }

+ 45 - 28
simulation-resource-server/src/main/resources/mapper/system/UserMapper.xml

@@ -17,60 +17,66 @@
 
     <!-- 列表查询共用字段-->
     <sql id="pageColumn">
-        id,
-        username,
-        nickname,
-        photo,
-        phone,
-        company,
-        role_code,
-        visible
+        u.id,
+        u.username,
+        u.nickname,
+        u.photo,
+        u.phone,
+        u.company,
+        u.role_code,
+        u.use_type,
+        u.visible,
+        u.create_time,
+        t.username as createUserName
     </sql>
     <!-- 列表查询共用查询条件-->
     <sql id="pageWhere">
         <if test="username != null and username != ''">
-            and username like CONCAT('%',#{username,jdbcType=VARCHAR},'%')
+            and u.username like CONCAT('%',#{username,jdbcType=VARCHAR},'%')
         </if>
         <if test="nickname != null and nickname != ''">
-            and nickname like CONCAT('%',#{nickname,jdbcType=VARCHAR},'%')
+            and u.nickname like CONCAT('%',#{nickname,jdbcType=VARCHAR},'%')
         </if>
         <if test="company != null and company != ''">
-            and company like CONCAT('%',#{company,jdbcType=VARCHAR},'%')
+            and u.company like CONCAT('%',#{company,jdbcType=VARCHAR},'%')
         </if>
         <if test="roleCode != null and roleCode != ''">
-            and role_code = #{roleCode,jdbcType=VARCHAR}
+            and u.role_code = #{roleCode,jdbcType=VARCHAR}
         </if>
         <if test="visible != null and visible != ''">
-            and visible = #{visible,jdbcType=VARCHAR}
+            and u.visible = #{visible,jdbcType=VARCHAR}
         </if>
     </sql>
 
     <select id="getUserPageLista" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
         SELECT
            <include refid="pageColumn"></include>
-        FROM system_user
-        WHERE is_deleted = '0' AND role_code &lt;&gt; '0'
-          <include refid="pageWhere"></include>
-        ORDER BY modify_time DESC
+        FROM system_user u
+        JOIN system_user t ON u.create_user_id = t.id
+        WHERE u.is_deleted = '0' AND u.role_code &lt;&gt; '0' and u.role_code &lt;&gt; '3'
+        <include refid="pageWhere"></include>
+        ORDER BY u.modify_time DESC
     </select>
 
     <select id="getUserPageListb" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
         SELECT
         <include refid="pageColumn"></include>
-        FROM system_user
-        WHERE is_deleted = '0' AND role_code &lt;&gt; '0' and role_code &lt;&gt; '1'
+        FROM system_user u
+        JOIN system_user t ON u.create_user_id = t.id
+        WHERE u.is_deleted = '0' AND u.role_code = '2'
         <include refid="pageWhere"></include>
-        ORDER BY modify_time DESC
+        ORDER BY u.modify_time DESC
     </select>
 
     <select id="getUserPageListc" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
         SELECT
         <include refid="pageColumn"></include>
-        FROM system_user
-        WHERE is_deleted = '0' AND role_code = '3'
+        FROM system_user u
+        JOIN system_user t ON u.create_user_id = t.id
+        WHERE u.is_deleted = '0' AND u.role_code = '3'
         <include refid="pageWhere"></include>
-        and create_user_id = #{createUserId,jdbcType=VARCHAR}
-        ORDER BY modify_time DESC
+        and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
+        ORDER BY u.modify_time DESC
     </select>
 
     <select id="selectCount" resultType="java.lang.Integer">
@@ -99,6 +105,7 @@
             phone,
             company,
             role_code,
+            use_type,
             visible,
             create_time,
             modify_time,
@@ -115,6 +122,7 @@
             #{phone,jdbcType=VARCHAR},
             #{company,jdbcType=VARCHAR},
             #{roleCode,jdbcType=VARCHAR},
+            #{useType,jdbcType=VARCHAR},
             #{visible,jdbcType=VARCHAR},
             #{createTime,jdbcType=TIMESTAMP},
             #{modifyTime,jdbcType=TIMESTAMP},
@@ -128,13 +136,13 @@
         update system_user set
             username = #{username,jdbcType=VARCHAR},
             nickname = #{nickname,jdbcType=VARCHAR},
-            photo = #{photo,jdbcType=VARCHAR},
+            <!--photo = #{photo,jdbcType=VARCHAR},-->
             phone = #{phone,jdbcType=VARCHAR},
             company = #{company,jdbcType=VARCHAR},
-            visible = #{visible,jdbcType=VARCHAR},
+            <!--visible = #{visible,jdbcType=VARCHAR},-->
 
-            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
-            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+        modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
         where id = #{id,jdbcType=VARCHAR}
     </update>
 
@@ -146,4 +154,13 @@
         where id = #{id,jdbcType=VARCHAR}
     </update>
 
+    <update id="saveVisible" parameterType="api.common.pojo.po.system.UserPO">
+        update system_user set
+            visible = #{visible,jdbcType=VARCHAR},
+            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
+
 </mapper>