From 0d3d6f61ecf34a5b5537cc41aff0f109f348e0e5 Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Fri, 25 Nov 2022 14:30:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=8F=8A=E5=8C=BA=E5=B8=82=E6=9C=AA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=AE=A1=E6=A0=B8=E4=BA=BA=E5=91=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=202.=E8=A7=92=E8=89=B2=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=85=B3=E8=81=94=E8=A1=A8=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=BA=E5=8F=8A?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A0=87=E5=BF=97=E5=AD=97=E6=AE=B5=203.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=95=B0=E6=8D=AE=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=97=B6=E8=A7=92=E8=89=B2=E4=BF=A1=E6=81=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=80=BB=E8=BE=91=EF=BC=8C=E5=85=B3=E8=81=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=94=B1=E7=89=A9=E7=90=86=E5=88=A0=E9=99=A4=E5=8F=98?= =?UTF-8?q?=E4=B8=BA=E9=80=BB=E8=BE=91=E5=88=A0=E9=99=A4=204.=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=85=B6=E4=BB=96=E8=AE=BE=E8=AE=A1=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=85=B3=E8=81=94=E8=A1=A8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?sql=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E6=A0=87?= =?UTF-8?q?=E5=BF=97=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db/V7.8__role_user_add_col.sql | 5 ++ .../sys/controller/SysUserController.java | 23 ++++++ .../modules/sys/dao/SysRoleUserDao.java | 3 +- .../io/renren/modules/sys/dao/SysUserDao.java | 5 ++ .../io/renren/modules/sys/dto/SysRoleDTO.java | 9 +++ .../modules/sys/entity/SysRoleUserEntity.java | 13 ++++ .../modules/sys/service/SysUserService.java | 3 + .../service/impl/SysRoleUserServiceImpl.java | 7 +- .../sys/service/impl/SysUserServiceImpl.java | 34 ++++++++- .../main/resources/mapper/sys/SysMenuDao.xml | 3 +- .../mapper/sys/SysRoleDataScopeDao.xml | 2 +- .../resources/mapper/sys/SysRoleUserDao.xml | 14 +++- .../main/resources/mapper/sys/SysUserDao.xml | 72 ++++++++++++++++++- 13 files changed, 185 insertions(+), 8 deletions(-) create mode 100644 config/db/V7.8__role_user_add_col.sql diff --git a/config/db/V7.8__role_user_add_col.sql b/config/db/V7.8__role_user_add_col.sql new file mode 100644 index 00000000..628b0b3c --- /dev/null +++ b/config/db/V7.8__role_user_add_col.sql @@ -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 '修改时间'; + diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java index dfaa4fb5..b104d5fd 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysUserController.java @@ -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 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 params) { + return new Result().ok(sysUserService.getApproverUnconfiguredRegion(params)); + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysRoleUserDao.java b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysRoleUserDao.java index 98884ca7..4e7ee94f 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysRoleUserDao.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysRoleUserDao.java @@ -3,6 +3,7 @@ package io.renren.modules.sys.dao; import io.renren.common.dao.BaseDao; import io.renren.modules.sys.entity.SysRoleUserEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -26,7 +27,7 @@ public interface SysRoleUserDao extends BaseDao { * * @param userIds 用户ids */ - void deleteByUserIds(Long[] userIds); + void deleteByUserIds(@Param("userIds") Long[] userIds, @Param("updater") Long updater); /** * 角色ID列表 diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysUserDao.java b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysUserDao.java index d6ce1e18..5d084954 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dao/SysUserDao.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dao/SysUserDao.java @@ -5,6 +5,7 @@ import io.renren.modules.sys.entity.SysUserEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -48,4 +49,8 @@ public interface SysUserDao extends BaseDao { SysUserEntity getUserByName(@Param("username") String username); String getDeptNameByUserId(@Param("id") String id); + + List getApproverUnconfiguredDepartment(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize); + + List getApproverUnconfiguredRegion(@Param("pageNum") int pageNum, @Param("pageSize") int pageSize); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dto/SysRoleDTO.java b/renren-admin/src/main/java/io/renren/modules/sys/dto/SysRoleDTO.java index 82e9e91d..ab6a2901 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dto/SysRoleDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dto/SysRoleDTO.java @@ -47,4 +47,13 @@ public class SysRoleDTO implements Serializable { @ApiModelProperty(value = "部门ID列表") private List deptIdList; + @ApiModelProperty(value = "删除标志") + private Integer delFlag; + + @ApiModelProperty(value = "修改时间") + private Date updateDate; + + @ApiModelProperty(value = "修改人") + private Long updater; + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/entity/SysRoleUserEntity.java b/renren-admin/src/main/java/io/renren/modules/sys/entity/SysRoleUserEntity.java index 2626bbe7..75a77710 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/entity/SysRoleUserEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/entity/SysRoleUserEntity.java @@ -1,10 +1,15 @@ 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 io.renren.common.entity.BaseEntity; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.Date; + /** * 角色用户关系 * @@ -25,4 +30,12 @@ public class SysRoleUserEntity extends BaseEntity { */ private Long userId; + private Integer delFlag; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java b/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java index 5e0b3357..e155b9fb 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/SysUserService.java @@ -62,4 +62,7 @@ public interface SysUserService extends BaseService { int backSysUser(); + Object getApproverUnconfiguredDepartment(Map params); + + Object getApproverUnconfiguredRegion(Map params); } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java index 12010ebd..52a17c85 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRoleUserServiceImpl.java @@ -2,10 +2,12 @@ package io.renren.modules.sys.service.impl; import cn.hutool.core.collection.CollUtil; 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.entity.SysRoleUserEntity; import io.renren.modules.sys.service.SysRoleUserService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -18,6 +20,7 @@ import java.util.List; public class SysRoleUserServiceImpl extends BaseServiceImpl implements SysRoleUserService { @Override + @Transactional public void saveOrUpdate(Long userId, List roleIdList) { //先删除角色用户关系 deleteByUserIds(new Long[]{userId}); @@ -45,7 +48,9 @@ public class SysRoleUserServiceImpl extends BaseServiceImpl 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 resultList = new ArrayList<>(); + resultList.addAll(sysUserDao.getApproverUnconfiguredDepartment(pageNum, pageSize)); + return resultList; + } + + @Override + public Object getApproverUnconfiguredRegion(Map 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 resultList = new ArrayList<>(); + resultList.addAll(sysUserDao.getApproverUnconfiguredRegion(pageNum, pageSize)); + return resultList; + } } diff --git a/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml b/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml index 8832dd90..d46e66fb 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysMenuDao.xml @@ -39,6 +39,7 @@ left join sys_role_menu t2 on t1.role_id = t2.role_id left join sys_menu t3 on t2.menu_id = t3.id where t1.user_id = #{userId} + AND t1.del_flag = 0 and t3.type = #{type} @@ -48,7 +49,7 @@ 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 diff --git a/renren-admin/src/main/resources/mapper/sys/SysRoleUserDao.xml b/renren-admin/src/main/resources/mapper/sys/SysRoleUserDao.xml index de36800f..42bea077 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysRoleUserDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysRoleUserDao.xml @@ -9,6 +9,7 @@ #{roleId} + + + UPDATE sys_role_user SET del_flag = 0, update_date = NOW(), updater = #{updater} + where user_id in + + #{userId} + + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/sys/SysUserDao.xml b/renren-admin/src/main/resources/mapper/sys/SysUserDao.xml index ebdeb622..6d85b91e 100644 --- a/renren-admin/src/main/resources/mapper/sys/SysUserDao.xml +++ b/renren-admin/src/main/resources/mapper/sys/SysUserDao.xml @@ -33,7 +33,7 @@ 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 @@ -71,6 +71,7 @@ AND t1.role_id = #{roleId} AND t2.dept_id = #{deptId} AND t2.status = 1 + AND t1.del_flag = 0 ORDER BY update_date DESC 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} + + + + \ No newline at end of file From b5cb7d8441af059dd86a6a40aa6965e412aee65d Mon Sep 17 00:00:00 2001 From: huangweixiong Date: Fri, 25 Nov 2022 16:22:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=86=99cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../renren/modules/security/oauth2/Oauth2Filter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java index 7cf3d6be..cc7573ce 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java +++ b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java @@ -237,9 +237,9 @@ public class Oauth2Filter extends AuthenticatingFilter { Result result = sysUserTokenService.createToken(sysUserEntity.getId()); Object token = result.getData().get(Constant.TOKEN_HEADER); String currentToken = (String) token; - Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken); - cookie.setPath("/"); - response.addCookie(cookie); +// Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken); +// cookie.setPath("/"); +// response.addCookie(cookie); response.addHeader(Constant.TOKEN_HEADER, currentToken); //回调不涉及其他页面回调,先写死回调首页 String removeCreditParame = "http://" + urlBuilder.getHost() + ":" + urlBuilder.getPort() + "/#/home"; @@ -267,9 +267,9 @@ public class Oauth2Filter extends AuthenticatingFilter { Result result = sysUserTokenService.createToken(sysUserEntity.getId()); Object token = result.getData().get(Constant.TOKEN_HEADER); String currentToken = (String) token; - Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken); - cookie.setPath("/"); - response.addCookie(cookie); +// Cookie cookie = new Cookie(Constant.TOKEN_HEADER, currentToken); +// cookie.setPath("/"); +// response.addCookie(cookie); response.addHeader(Constant.TOKEN_HEADER, currentToken); //去掉凭证参数 String removeCreditParame = ssoValidator.removeCreditParame(requestUri);