Merge branch 'dev'

This commit is contained in:
wangliwen 2022-11-25 16:25:01 +08:00
commit 5b5bf2f3c7
14 changed files with 191 additions and 14 deletions

View File

@ -0,0 +1,5 @@
ALTER TABLE sys_role_user
ADD COLUMN `del_flag` INT NOT NULL DEFAULT 0 COMMENT '删除标志0正常1删除',
ADD COLUMN `updater` BIGINT NULL COMMENT '修改人',
ADD COLUMN `update_date` datetime(0) NULL COMMENT '修改时间';

View File

@ -237,9 +237,9 @@ public class Oauth2Filter extends AuthenticatingFilter {
Result<Map> result = sysUserTokenService.createToken(sysUserEntity.getId()); Result<Map> result = sysUserTokenService.createToken(sysUserEntity.getId());
Object token = result.getData().get(Constant.TOKEN_HEADER); Object token = result.getData().get(Constant.TOKEN_HEADER);
String currentToken = (String) token; String currentToken = (String) token;
Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken); // Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken);
cookie.setPath("/"); // cookie.setPath("/");
response.addCookie(cookie); // response.addCookie(cookie);
response.addHeader(Constant.TOKEN_HEADER, currentToken); response.addHeader(Constant.TOKEN_HEADER, currentToken);
//回调不涉及其他页面回调先写死回调首页 //回调不涉及其他页面回调先写死回调首页
String removeCreditParame = "http://" + urlBuilder.getHost() + ":" + urlBuilder.getPort() + "/#/home"; String removeCreditParame = "http://" + urlBuilder.getHost() + ":" + urlBuilder.getPort() + "/#/home";
@ -267,9 +267,9 @@ public class Oauth2Filter extends AuthenticatingFilter {
Result<Map> result = sysUserTokenService.createToken(sysUserEntity.getId()); Result<Map> result = sysUserTokenService.createToken(sysUserEntity.getId());
Object token = result.getData().get(Constant.TOKEN_HEADER); Object token = result.getData().get(Constant.TOKEN_HEADER);
String currentToken = (String) token; String currentToken = (String) token;
Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken); // Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken);
cookie.setPath("/"); // cookie.setPath("/");
response.addCookie(cookie); // response.addCookie(cookie);
response.addHeader(Constant.TOKEN_HEADER, currentToken); response.addHeader(Constant.TOKEN_HEADER, currentToken);
//去掉凭证参数 //去掉凭证参数
String removeCreditParame = ssoValidator.removeCreditParame(requestUri); String removeCreditParame = ssoValidator.removeCreditParame(requestUri);

View File

@ -196,4 +196,27 @@ public class SysUserController {
} }
} }
@GetMapping("/getApproverUnconfiguredDepartment")
@ApiOperation("查询未配置部门审核人部门列表")
@LogOperation("查询未配置部门审核人部门列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "当前页码从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "int")
})
public Result getApproverUnconfiguredDepartment(@ApiIgnore @RequestParam Map<String, Object> params) {
return new Result().ok(sysUserService.getApproverUnconfiguredDepartment(params));
}
@GetMapping("/getApproverUnconfiguredRegion")
@ApiOperation("查询未配置区市审核人区市列表")
@LogOperation("查询未配置区市审核人区市列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "当前页码从1开始", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "int")
})
public Result getApproverUnconfiguredRegion(@ApiIgnore @RequestParam Map<String, Object> params) {
return new Result().ok(sysUserService.getApproverUnconfiguredRegion(params));
}
} }

View File

@ -3,6 +3,7 @@ package io.renren.modules.sys.dao;
import io.renren.common.dao.BaseDao; import io.renren.common.dao.BaseDao;
import io.renren.modules.sys.entity.SysRoleUserEntity; import io.renren.modules.sys.entity.SysRoleUserEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -26,7 +27,7 @@ public interface SysRoleUserDao extends BaseDao<SysRoleUserEntity> {
* *
* @param userIds 用户ids * @param userIds 用户ids
*/ */
void deleteByUserIds(Long[] userIds); void deleteByUserIds(@Param("userIds") Long[] userIds, @Param("updater") Long updater);
/** /**
* 角色ID列表 * 角色ID列表

View File

@ -5,6 +5,7 @@ import io.renren.modules.sys.entity.SysUserEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,4 +49,8 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
SysUserEntity getUserByName(@Param("username") String username); SysUserEntity getUserByName(@Param("username") String username);
String getDeptNameByUserId(@Param("id") String id); String getDeptNameByUserId(@Param("id") String id);
List<Map> getApproverUnconfiguredDepartment(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize);
List<Map> getApproverUnconfiguredRegion(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize);
} }

View File

@ -47,4 +47,13 @@ public class SysRoleDTO implements Serializable {
@ApiModelProperty(value = "部门ID列表") @ApiModelProperty(value = "部门ID列表")
private List<Long> deptIdList; private List<Long> deptIdList;
@ApiModelProperty(value = "删除标志")
private Integer delFlag;
@ApiModelProperty(value = "修改时间")
private Date updateDate;
@ApiModelProperty(value = "修改人")
private Long updater;
} }

View File

@ -1,10 +1,15 @@
package io.renren.modules.sys.entity; package io.renren.modules.sys.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.renren.common.entity.BaseEntity; import io.renren.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
/** /**
* 角色用户关系 * 角色用户关系
* *
@ -25,4 +30,12 @@ public class SysRoleUserEntity extends BaseEntity {
*/ */
private Long userId; private Long userId;
private Integer delFlag;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
} }

View File

@ -62,4 +62,7 @@ public interface SysUserService extends BaseService<SysUserEntity> {
int backSysUser(); int backSysUser();
Object getApproverUnconfiguredDepartment(Map<String, Object> params);
Object getApproverUnconfiguredRegion(Map<String, Object> params);
} }

View File

@ -2,10 +2,12 @@ package io.renren.modules.sys.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import io.renren.common.service.impl.BaseServiceImpl; import io.renren.common.service.impl.BaseServiceImpl;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dao.SysRoleUserDao; import io.renren.modules.sys.dao.SysRoleUserDao;
import io.renren.modules.sys.entity.SysRoleUserEntity; import io.renren.modules.sys.entity.SysRoleUserEntity;
import io.renren.modules.sys.service.SysRoleUserService; import io.renren.modules.sys.service.SysRoleUserService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -18,6 +20,7 @@ import java.util.List;
public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysRoleUserEntity> implements SysRoleUserService { public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysRoleUserEntity> implements SysRoleUserService {
@Override @Override
@Transactional
public void saveOrUpdate(Long userId, List<Long> roleIdList) { public void saveOrUpdate(Long userId, List<Long> roleIdList) {
//先删除角色用户关系 //先删除角色用户关系
deleteByUserIds(new Long[]{userId}); deleteByUserIds(new Long[]{userId});
@ -45,7 +48,9 @@ public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysR
@Override @Override
public void deleteByUserIds(Long[] userIds) { public void deleteByUserIds(Long[] userIds) {
baseDao.deleteByUserIds(userIds);
Long updater = SecurityUser.getUserId();
baseDao.deleteByUserIds(userIds, updater);
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package io.renren.modules.sys.service.impl; package io.renren.modules.sys.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -26,6 +27,8 @@ import io.renren.modules.sys.enums.JhDeptsEnum;
import io.renren.modules.sys.enums.SuperAdminEnum; import io.renren.modules.sys.enums.SuperAdminEnum;
import io.renren.modules.sys.service.*; import io.renren.modules.sys.service.*;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.ObjectUtils;
import org.h2.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,7 +40,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
/** /**
* 系统用户 * 系统用户
*/ */
@ -520,4 +522,34 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return result; return result;
} }
} }
@Override
public Object getApproverUnconfiguredDepartment(Map<String, Object> params) {
int pageNum = 1;
int pageSize = 10;
if (params.get("pageNum") != null && StringUtils.isNumber(params.get("pageNum").toString())) {
pageNum = Integer.parseInt(params.get("pageNum").toString());
}
if (params.get("pageSize") != null && StringUtils.isNumber(params.get("pageSize").toString())) {
pageSize = Integer.parseInt(params.get("pageSize").toString());
}
ArrayList<Object> resultList = new ArrayList<>();
resultList.addAll(sysUserDao.getApproverUnconfiguredDepartment(pageNum, pageSize));
return resultList;
}
@Override
public Object getApproverUnconfiguredRegion(Map<String, Object> params) {
int pageNum = 1;
int pageSize = 10;
if (params.get("pageNum") != null && StringUtils.isNumber(params.get("pageNum").toString())) {
pageNum = Integer.parseInt(params.get("pageNum").toString());
}
if (params.get("pageSize") != null && StringUtils.isNumber(params.get("pageSize").toString())) {
pageSize = Integer.parseInt(params.get("pageSize").toString());
}
ArrayList<Object> resultList = new ArrayList<>();
resultList.addAll(sysUserDao.getApproverUnconfiguredRegion(pageNum, pageSize));
return resultList;
}
} }

View File

@ -39,6 +39,7 @@
left join sys_role_menu t2 on t1.role_id = t2.role_id left join sys_role_menu t2 on t1.role_id = t2.role_id
left join sys_menu t3 on t2.menu_id = t3.id left join sys_menu t3 on t2.menu_id = t3.id
where t1.user_id = #{userId} where t1.user_id = #{userId}
AND t1.del_flag = 0
<if test="type != null"> <if test="type != null">
and t3.type = #{type} and t3.type = #{type}
</if> </if>
@ -48,7 +49,7 @@
<select id="getUserPermissionsList" resultType="string"> <select id="getUserPermissionsList" resultType="string">
select t3.permissions from sys_role_user t1 left join sys_role_menu t2 on t1.role_id = t2.role_id select t3.permissions from sys_role_user t1 left join sys_role_menu t2 on t1.role_id = t2.role_id
left join sys_menu t3 on t2.menu_id = t3.id left join sys_menu t3 on t2.menu_id = t3.id
where t1.user_id = #{userId} order by t3.sort asc where t1.user_id = #{userId} AND t1.del_flag = 0 order by t3.sort
</select> </select>
<select id="getPermissionsList" resultType="string"> <select id="getPermissionsList" resultType="string">

View File

@ -9,7 +9,7 @@
<select id="getDataScopeList" resultType="long"> <select id="getDataScopeList" resultType="long">
select t2.dept_id from sys_role_user t1, sys_role_data_scope t2 select t2.dept_id from sys_role_user t1, sys_role_data_scope t2
where t1.user_id = #{value} and t1.role_id = t2.role_id where t1.user_id = #{value} and t1.role_id = t2.role_id AND t1.del_flag = 0
</select> </select>
<delete id="deleteByRoleIds"> <delete id="deleteByRoleIds">

View File

@ -9,6 +9,7 @@
#{roleId} #{roleId}
</foreach> </foreach>
</delete> </delete>
<!--
<delete id="deleteByUserIds"> <delete id="deleteByUserIds">
delete from sys_role_user where user_id in delete from sys_role_user where user_id in
@ -17,12 +18,21 @@
</foreach> </foreach>
</delete> </delete>
-->
<update id="deleteByUserIds">
UPDATE sys_role_user SET del_flag = 0, update_date = NOW(), updater = #{updater}
where user_id in
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
#{userId}
</foreach>
</update>
<select id="getRoleIdList" resultType="long"> <select id="getRoleIdList" resultType="long">
select role_id from sys_role_user where user_id = #{value} select role_id from sys_role_user where user_id = #{value} AND del_flag = 0
</select> </select>
<select id="getUserIdsByRoleId" resultType="java.lang.Long"> <select id="getUserIdsByRoleId" resultType="java.lang.Long">
select user_id from sys_role_user where role_id = #{roleId} select user_id from sys_role_user where role_id = #{roleId} AND del_flag = 0
</select> </select>
</mapper> </mapper>

View File

@ -33,7 +33,7 @@
</if> </if>
<if test="role_id != null"> <if test="role_id != null">
AND EXISTS(SELECT 1 FROM sys_role_user WHERE sys_role_user.user_id = t1.id AND sys_role_user.role_id = AND EXISTS(SELECT 1 FROM sys_role_user WHERE sys_role_user.user_id = t1.id AND sys_role_user.role_id =
#{role_id}) #{role_id}) AND sys_role_user.del_flag = 0
</if> </if>
</select> </select>
@ -71,6 +71,7 @@
AND t1.role_id = #{roleId} AND t1.role_id = #{roleId}
AND t2.dept_id = #{deptId} AND t2.dept_id = #{deptId}
AND t2.status = 1 AND t2.status = 1
AND t1.del_flag = 0
ORDER BY ORDER BY
update_date DESC update_date DESC
LIMIT 1 LIMIT 1
@ -102,4 +103,73 @@
SELECT name FROM sys_dept LEFT JOIN sys_user ON sys_user.dept_id = sys_dept.id WHERE sys_user.id = #{id} SELECT name FROM sys_dept LEFT JOIN sys_user ON sys_user.dept_id = sys_dept.id WHERE sys_user.id = #{id}
</select> </select>
<select id="getApproverUnconfiguredDepartment" resultType="java.util.Map">
SELECT
id,
name,
(CASE type
WHEN 1 THEN
'省'
WHEN 2 THEN
'市'
WHEN 3 THEN
'区'
ELSE
' '
END) AS "type",
sort
FROM
sys_dept sd
WHERE
id NOT IN (
SELECT
sd.id
FROM
sys_user su,
sys_dept sd,
sys_role sr,
sys_role_user sru
WHERE
su.dept_id = sd.id
AND su.id = sru.user_id
AND sru.role_id = sr.id
AND sru.del_flag = 0
AND sr.`name` = '部门审批人'
)
AND sd.type != 4
ORDER BY sd.type, sort
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="getApproverUnconfiguredRegion" resultType="java.util.Map">
SELECT
id,
NAME,
sort
FROM
sys_region srg
WHERE
id NOT IN (
SELECT
srg.id
FROM
sys_user su,
sys_dept sd,
sys_region srg,
sys_role sr,
sys_role_user sru
WHERE
su.dept_id = sd.id
AND su.id = sru.user_id
AND sru.role_id = sr.id
AND sd.district = srg.id
AND sru.del_falg = 0
AND sr.`name` = '区审批人'
)
AND srg.tree_level = 3
AND 9 >= srg.sort
ORDER BY srg.sort
LIMIT ${pageNum}, ${pageSize}
</select>
</mapper> </mapper>