Sfoglia il codice sorgente

用户模块修改

anderx 2 anni fa
parent
commit
340f5c2d08

+ 20 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -119,12 +119,32 @@ public class SysUser extends BaseEntity
     /** 角色ID */
     private Long roleId;
 
+    /**公司id*/
+    private Long companyId;
+    private Long postId;
+
     public SysUser()
     {
 
     }
 
 
+    public Long getPostId() {
+        return postId;
+    }
+
+    public void setPostId(Long postId) {
+        this.postId = postId;
+    }
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
     public String getOpenId() {
         return openId;
     }

+ 1 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java

@@ -217,6 +217,7 @@ public class TokenService
     private String getToken(HttpServletRequest request)
     {
         String token = request.getHeader(header);
+        if (token == null)token = request.getParameter("token");
         if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX))
         {
             token = token.replace(Constants.TOKEN_PREFIX, "");

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java

@@ -122,5 +122,5 @@ public interface ISysDeptService
      */
     public int deleteDeptById(Long deptId);
 
-
+    public Long selectCompanyByDeptId(Long deptId);
 }

+ 26 - 17
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.service.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -23,7 +24,7 @@ import com.ruoyi.system.service.ISysDeptService;
 
 /**
  * 部门管理 服务实现
- * 
+ *
  * @author ruoyi
  */
 @Service
@@ -37,7 +38,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 查询部门管理数据
-     * 
+     *
      * @param dept 部门信息
      * @return 部门信息集合
      */
@@ -50,7 +51,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 查询部门树结构信息
-     * 
+     *
      * @param dept 部门信息
      * @return 部门树信息集合
      */
@@ -63,7 +64,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 构建前端所需要树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 树结构列表
      */
@@ -90,7 +91,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 构建前端所需要下拉树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 下拉树结构列表
      */
@@ -103,7 +104,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 根据角色ID查询部门树信息
-     * 
+     *
      * @param roleId 角色ID
      * @return 选中部门列表
      */
@@ -116,7 +117,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 根据部门ID查询信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门信息
      */
@@ -128,7 +129,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 根据ID查询所有子部门(正常状态)
-     * 
+     *
      * @param deptId 部门ID
      * @return 子部门数
      */
@@ -140,7 +141,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 是否存在子节点
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -153,7 +154,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 查询部门是否存在用户
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果 true 存在 false 不存在
      */
@@ -166,7 +167,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 校验部门名称是否唯一
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -184,7 +185,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 校验部门是否有数据权限
-     * 
+     *
      * @param deptId 部门id
      */
     @Override
@@ -204,7 +205,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 新增保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -223,7 +224,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 修改保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -251,7 +252,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 修改该部门的父级部门状态
-     * 
+     *
      * @param dept 当前部门
      */
     private void updateParentDeptStatusNormal(SysDept dept)
@@ -263,7 +264,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 修改子元素关系
-     * 
+     *
      * @param deptId 被修改的部门ID
      * @param newAncestors 新的父ID集合
      * @param oldAncestors 旧的父ID集合
@@ -283,7 +284,7 @@ public class SysDeptServiceImpl implements ISysDeptService
 
     /**
      * 删除部门管理信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -293,6 +294,14 @@ public class SysDeptServiceImpl implements ISysDeptService
         return deptMapper.deleteDeptById(deptId);
     }
 
+    @Override
+    public Long selectCompanyByDeptId(Long deptId) {
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
+        String[] split = sysDept.getAncestors().split(",");
+        if (split.length<3)return null;
+        return Long.valueOf(split[2]);
+    }
+
     /**
      * 递归列表
      */

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -71,8 +71,8 @@ public class SysUserServiceImpl implements ISysUserService
     @DataScope(deptAlias = "d", userAlias = "u")
     public List<SysUser> selectUserList(SysUser user)
     {
-        user.setDeptId(SecurityUtils.getDeptId());
-//        deptService.selectDeptByAncestorsOrderNum();
+        Long companyId = deptService.selectCompanyByDeptId(SecurityUtils.getDeptId());
+        if (companyId!=null)user.setCompanyId(companyId);
         return userMapper.selectUserList(user);
     }
 

+ 4 - 4
ruoyi-system/src/main/java/com/ruoyi/weChat/service/WeChatService.java

@@ -33,7 +33,7 @@ public class WeChatService {
 	private String wxState;
 
 	@Autowired
-	private RedisTemplate<String, String> redisTemplate;
+	private RedisCache redisCache;
 	@Autowired
 	private SysUserMapper sysUserMapper;
 
@@ -83,7 +83,7 @@ public class WeChatService {
 
 	public String getAccessToken() {
 		Date date = new Date();
-		String  access_token = redisTemplate.opsForValue().get("access_token");
+		String  access_token = redisCache.getCacheObject("access_token");
 		if (access_token!=null) {
 			log.debug("缓存读取access_token="+access_token);
 			return access_token;
@@ -102,13 +102,13 @@ public class WeChatService {
 				appSecret);
 		JSONObject js= HttpUtils.sendGetToJson(url);
 		String errcode =js.getString("errcode");
-		Long expires_in = js.getLong("expires_in");
+		Integer expires_in = js.getInteger("expires_in");
 		String access_token=null;
 		if (errcode!=null) {
 			log.error("获取AccessToken失败!");
 		}else {
 			access_token = js.getString("access_token");
-			redisTemplate.opsForValue().set("access_token", access_token,expires_in, TimeUnit.SECONDS);
+			redisCache.setCacheObject("access_token", access_token,expires_in, TimeUnit.SECONDS);
 			log.debug("获取并存入AccessToken成功,accesstoken="+access_token);
 		}
 		return access_token;

+ 18 - 1
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -61,12 +61,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		    left join sys_role r on r.role_id = ur.role_id
     </sql>
 
-    <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
+    <select id="selectUserList" parameterType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult">
 		select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag,
 		       u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader,u.open_id,u.superior_id,
 		       u.project_quantity,u.job_number,u.full_job
 		from sys_user u
 		left join sys_dept d on u.dept_id = d.dept_id
+		left join sys_user_post sup on u.user_id = sup.user_id
 		where u.del_flag = '0'
 		<if test="userId != null and userId != 0">
 			AND u.user_id = #{userId}
@@ -74,6 +75,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="userName != null and userName != ''">
 			AND u.user_name like concat('%', #{userName}, '%')
 		</if>
+		<if test="jobNumber != null and jobNumber != ''">
+			AND u.job_number like concat('%', #{jobNumber}, '%')
+		</if>
+		<if test="fullJob != null and fullJob != ''">
+			AND u.full_job = #{fullJob}
+		</if>
+		<if test="fullJob != null and fullJob != ''">
+			AND u.full_job = #{fullJob}
+		</if>
+		<if test="postId != null and postId != ''">
+			AND sup.post_id = #{postId}
+		</if>
 		<if test="status != null and status != ''">
 			AND u.status = #{status}
 		</if>
@@ -89,6 +102,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="deptId != null and deptId != 0">
 			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
 		</if>
+		<if test="companyId !=null and companyId != 0">
+			AND (u.dept_id = #{companyId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{companyId}, ancestors) ))
+		</if>
+
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
 	</select>