Merge branch 'dev'

This commit is contained in:
wangliwen 2022-10-10 13:53:45 +08:00
commit 21ac7f2991
5 changed files with 183 additions and 159 deletions

View File

@ -16,6 +16,7 @@ import io.renren.modules.notice.dto.SysNoticeDTO;
import io.renren.modules.notice.enums.NoticeStatusEnum;
import io.renren.modules.notice.service.SysNoticeService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.service.SysRoleUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -46,6 +47,8 @@ public class BookMeetingRoomController {
private TMeetingroomService tMeetingroomService;
@Resource
private SysNoticeService sysNoticeService;
@Resource
private SysRoleUserService sysRoleUserService;
@GetMapping("list")
@ApiOperation("搜索可以预约的会议室")
@ -104,8 +107,15 @@ public class BookMeetingRoomController {
sysNoticeDTO.setTitle("会议室申请审核通知");
sysNoticeDTO.setContent(content); // 通知内容
sysNoticeDTO.setReceiverType(1);
sysNoticeDTO.setReceiverTypeIds(defaultAssigneeRoleId);
// 根据roleId查询userId
List<Long> useIds = sysRoleUserService.getUserIdListByRoleId(Long.parseLong(defaultAssigneeRoleId));
if (useIds != null && useIds.size() > 0){
String userId = "";
for (Long use : useIds){
userId += use.toString()+",";
}
sysNoticeDTO.setReceiverTypeIds(userId.substring(0,userId.length() -1));
}
sysNoticeDTO.setStatus(NoticeStatusEnum.SEND.value());
sysNoticeDTO.setSenderName("流程系统");
sysNoticeDTO.setSenderDate(new Date());

View File

@ -1,38 +1,41 @@
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 java.util.List;
/**
* 角色用户关系
*
* @since 1.0.0
*/
@Mapper
public interface SysRoleUserDao extends BaseDao<SysRoleUserEntity> {
/**
* 根据角色ids删除角色用户关系
*
* @param roleIds 角色ids
*/
void deleteByRoleIds(Long[] roleIds);
/**
* 根据用户id删除角色用户关系
*
* @param userIds 用户ids
*/
void deleteByUserIds(Long[] userIds);
/**
* 角色ID列表
*
* @param userId 用户ID
* @return
*/
List<Long> getRoleIdList(Long userId);
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 java.util.List;
/**
* 角色用户关系
*
* @since 1.0.0
*/
@Mapper
public interface SysRoleUserDao extends BaseDao<SysRoleUserEntity> {
/**
* 根据角色ids删除角色用户关系
*
* @param roleIds 角色ids
*/
void deleteByRoleIds(Long[] roleIds);
/**
* 根据用户id删除角色用户关系
*
* @param userIds 用户ids
*/
void deleteByUserIds(Long[] userIds);
/**
* 角色ID列表
*
* @param userId 用户ID
* @return
*/
List<Long> getRoleIdList(Long userId);
// 根据roleId查询所有userId
List<Long> getUserIdsByRoleId(Long roleId);
}

View File

@ -1,43 +1,45 @@
package io.renren.modules.sys.service;
import io.renren.common.service.BaseService;
import io.renren.modules.sys.entity.SysRoleUserEntity;
import java.util.List;
/**
* 角色用户关系
*
* @since 1.0.0
*/
public interface SysRoleUserService extends BaseService<SysRoleUserEntity> {
/**
* 保存或修改
*
* @param userId 用户ID
* @param roleIdList 角色ID列表
*/
void saveOrUpdate(Long userId, List<Long> roleIdList);
/**
* 根据角色ids删除角色用户关系
*
* @param roleIds 角色ids
*/
void deleteByRoleIds(Long[] roleIds);
/**
* 根据用户id删除角色用户关系
*
* @param userIds 用户ids
*/
void deleteByUserIds(Long[] userIds);
/**
* 角色ID列表
*
* @param userId 用户ID
*/
List<Long> getRoleIdList(Long userId);
package io.renren.modules.sys.service;
import io.renren.common.service.BaseService;
import io.renren.modules.sys.entity.SysRoleUserEntity;
import java.util.List;
/**
* 角色用户关系
*
* @since 1.0.0
*/
public interface SysRoleUserService extends BaseService<SysRoleUserEntity> {
/**
* 保存或修改
*
* @param userId 用户ID
* @param roleIdList 角色ID列表
*/
void saveOrUpdate(Long userId, List<Long> roleIdList);
/**
* 根据角色ids删除角色用户关系
*
* @param roleIds 角色ids
*/
void deleteByRoleIds(Long[] roleIds);
/**
* 根据用户id删除角色用户关系
*
* @param userIds 用户ids
*/
void deleteByUserIds(Long[] userIds);
/**
* 角色ID列表
*
* @param userId 用户ID
*/
List<Long> getRoleIdList(Long userId);
List<Long> getUserIdListByRoleId(Long roleId);
}

View File

@ -1,56 +1,61 @@
package io.renren.modules.sys.service.impl;
import cn.hutool.core.collection.CollUtil;
import io.renren.common.service.impl.BaseServiceImpl;
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 java.util.List;
/**
* 角色用户关系
*
* @since 1.0.0
*/
@Service
public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysRoleUserEntity> implements SysRoleUserService {
@Override
public void saveOrUpdate(Long userId, List<Long> roleIdList) {
//先删除角色用户关系
deleteByUserIds(new Long[]{userId});
//用户没有一个角色权限的情况
if (CollUtil.isEmpty(roleIdList)) {
return;
}
//保存角色用户关系
for (Long roleId : roleIdList) {
SysRoleUserEntity sysRoleUserEntity = new SysRoleUserEntity();
sysRoleUserEntity.setUserId(userId);
sysRoleUserEntity.setRoleId(roleId);
//保存
insert(sysRoleUserEntity);
}
}
@Override
public void deleteByRoleIds(Long[] roleIds) {
baseDao.deleteByRoleIds(roleIds);
}
@Override
public void deleteByUserIds(Long[] userIds) {
baseDao.deleteByUserIds(userIds);
}
@Override
public List<Long> getRoleIdList(Long userId) {
return baseDao.getRoleIdList(userId);
}
package io.renren.modules.sys.service.impl;
import cn.hutool.core.collection.CollUtil;
import io.renren.common.service.impl.BaseServiceImpl;
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 java.util.List;
/**
* 角色用户关系
*
* @since 1.0.0
*/
@Service
public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysRoleUserEntity> implements SysRoleUserService {
@Override
public void saveOrUpdate(Long userId, List<Long> roleIdList) {
//先删除角色用户关系
deleteByUserIds(new Long[]{userId});
//用户没有一个角色权限的情况
if (CollUtil.isEmpty(roleIdList)) {
return;
}
//保存角色用户关系
for (Long roleId : roleIdList) {
SysRoleUserEntity sysRoleUserEntity = new SysRoleUserEntity();
sysRoleUserEntity.setUserId(userId);
sysRoleUserEntity.setRoleId(roleId);
//保存
insert(sysRoleUserEntity);
}
}
@Override
public void deleteByRoleIds(Long[] roleIds) {
baseDao.deleteByRoleIds(roleIds);
}
@Override
public void deleteByUserIds(Long[] userIds) {
baseDao.deleteByUserIds(userIds);
}
@Override
public List<Long> getRoleIdList(Long userId) {
return baseDao.getRoleIdList(userId);
}
@Override
public List<Long> getUserIdListByRoleId(Long roleId) {
return baseDao.getUserIdsByRoleId(roleId);
}
}

View File

@ -1,24 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.renren.modules.sys.dao.SysRoleUserDao">
<delete id="deleteByRoleIds">
delete from sys_role_user where role_id in
<foreach item="roleId" collection="array" open="(" separator="," close=")">
#{roleId}
</foreach>
</delete>
<delete id="deleteByUserIds">
delete from sys_role_user where user_id in
<foreach item="userId" collection="array" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<select id="getRoleIdList" resultType="long">
select role_id from sys_role_user where user_id = #{value}
</select>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.renren.modules.sys.dao.SysRoleUserDao">
<delete id="deleteByRoleIds">
delete from sys_role_user where role_id in
<foreach item="roleId" collection="array" open="(" separator="," close=")">
#{roleId}
</foreach>
</delete>
<delete id="deleteByUserIds">
delete from sys_role_user where user_id in
<foreach item="userId" collection="array" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<select id="getRoleIdList" resultType="long">
select role_id from sys_role_user where user_id = #{value}
</select>
<select id="getUserIdsByRoleId" resultType="java.lang.Long">
select user_id from sys_role_user where role_id = #{roleId}
</select>
</mapper>