rebuildRoleAreaScope
This commit is contained in:
parent
c866ad4f41
commit
77381543b7
|
|
@ -81,6 +81,8 @@ public class SysRole extends BaseEntity
|
|||
|
||||
private String[] areaIds;
|
||||
|
||||
private String[] dataIds;
|
||||
|
||||
/** 角色菜单权限 */
|
||||
private Set<String> permissions;
|
||||
|
||||
|
|
@ -264,6 +266,14 @@ public class SysRole extends BaseEntity
|
|||
this.areaIds = areaIds;
|
||||
}
|
||||
|
||||
public String[] getDataIds() {
|
||||
return dataIds;
|
||||
}
|
||||
|
||||
public void setDataIds(String[] dataIds) {
|
||||
this.dataIds = dataIds;
|
||||
}
|
||||
|
||||
public Set<String> getPermissions()
|
||||
{
|
||||
return permissions;
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@ import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
|||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.bonus.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 角色和食堂等关联 sys_role_canteen
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
public class SysRoleCanteen
|
||||
{
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
/** 区域、食堂、档口ID */
|
||||
private String dataId;
|
||||
|
||||
public Long getRoleId()
|
||||
{
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId)
|
||||
{
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getDataId() {
|
||||
return dataId;
|
||||
}
|
||||
|
||||
public void setDataId(String dataId) {
|
||||
this.dataId = dataId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
.append("dataId", getDataId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.system.mapper;
|
||||
|
||||
import com.bonus.system.domain.SysRoleArea;
|
||||
import com.bonus.system.domain.SysRoleCanteen;
|
||||
import com.bonus.system.domain.SysRoleDept;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -20,6 +21,8 @@ public interface SysRoleAreaMapper
|
|||
*/
|
||||
public int deleteRoleAreaByRoleId(Long roleId);
|
||||
|
||||
public int deleteRoleCanteenByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色区域关联信息
|
||||
*
|
||||
|
|
@ -43,4 +46,6 @@ public interface SysRoleAreaMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int batchRoleArea(List<SysRoleArea> roleAreaList);
|
||||
|
||||
public int batchRoleCanteen(List<SysRoleCanteen> roleCanteenList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.bonus.common.datascope.enums.DataTypeEnum;
|
|||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import com.bonus.system.domain.SysRoleArea;
|
||||
import com.bonus.system.domain.SysRoleCanteen;
|
||||
import com.bonus.system.mapper.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -325,7 +326,13 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
// 删除角色与区域关联
|
||||
roleAreaMapper.deleteRoleAreaByRoleId(role.getRoleId());
|
||||
// 新增角色和区域信息(数据权限)
|
||||
return insertRoleArea(role);
|
||||
int count1 = insertRoleArea(role);
|
||||
// 删除角色与食堂档口关联
|
||||
roleAreaMapper.deleteRoleCanteenByRoleId(role.getRoleId());
|
||||
// 新增角色和食堂档口信息(数据权限)
|
||||
int count2 = insertRoleCanteen(role);
|
||||
|
||||
return count1 + count2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -400,6 +407,30 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色与食堂档口等信息(数据权限)
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleCanteen(SysRole role)
|
||||
{
|
||||
int rows = 1;
|
||||
// 新增角色与食堂档口(数据权限)管理
|
||||
List<SysRoleCanteen> list = new ArrayList<SysRoleCanteen>();
|
||||
for (String dataId : role.getDataIds())
|
||||
{
|
||||
SysRoleCanteen rd = new SysRoleCanteen();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDataId(dataId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
rows = roleAreaMapper.batchRoleCanteen(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
*
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
delete from sys_role_area where role_id=#{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRoleCanteenByRoleId" parameterType="Long">
|
||||
delete from sys_role_canteen where role_id=#{roleId}
|
||||
</delete>
|
||||
|
||||
<select id="selectCountRoleAreaByAreaId" resultType="Integer">
|
||||
select count(1) from sys_role_area where area_id=#{areaId}
|
||||
</select>
|
||||
|
|
@ -31,4 +35,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="batchRoleCanteen">
|
||||
insert into sys_role_canteen(role_id, data_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.roleId},#{item.dataId})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue