This commit is contained in:
sxu 2025-03-13 14:41:48 +08:00
parent fc2a4265f7
commit 6ad9216f3b
4 changed files with 26 additions and 5 deletions

View File

@ -76,8 +76,7 @@ public class SysRole extends BaseEntity
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long companyId;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long areaId;
private String areaId;
private String[] areaIds;
@ -250,11 +249,11 @@ public class SysRole extends BaseEntity
this.companyId = companyId;
}
public Long getAreaId() {
public String getAreaId() {
return areaId;
}
public void setAreaId(Long areaId) {
public void setAreaId(String areaId) {
this.areaId = areaId;
}

View File

@ -104,4 +104,8 @@ public interface SysRoleMapper
* @return 结果
*/
public int deleteRoleByIds(Long[] roleIds);
public List<String> getAreaIdsByRoleId(Long roleId);
public List<String> getDataIdsByRoleId(Long roleId);
}

View File

@ -81,7 +81,14 @@ public class SysRoleServiceImpl implements ISysRoleService
role.setRoleKey(str);
}
role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
return roleMapper.selectRoleList(role);
List<SysRole> roles = roleMapper.selectRoleList(role);
for (SysRole r : roles) {
List<String> areaIds = roleMapper.getAreaIdsByRoleId(r.getRoleId());
List<String> dataIds = roleMapper.getDataIdsByRoleId(r.getRoleId());
r.setAreaIds(areaIds.toArray(new String[areaIds.size()]));
r.setDataIds(dataIds.toArray(new String[dataIds.size()]));
}
return roles;
}
/**

View File

@ -176,4 +176,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="getAreaIdsByRoleId" resultType="String">
select area_id
from sys_role_area
where role_id = #{roleId}
</select>
<select id="getDataIdsByRoleId" resultType="String">
select data_id
from sys_role_canteen
where role_id = #{roleId}
</select>
</mapper>