前端品牌回显 + 后端大列表修改权限筛选

This commit is contained in:
CD
2022-12-27 16:11:22 +08:00
parent 35f05020c8
commit ca1fb97fc5
7 changed files with 37 additions and 35 deletions
@@ -252,7 +252,7 @@ public class SysUserController {
sysUserService.editUserWithRole(user, roles);
if (ObjectUtils.isNotEmpty(roles)) {
//如果角色包含viewer,设置责任领域权限和品牌权限
//如果角色包含viewer或者品牌管理员,设置责任领域权限和品牌权限
sysUserService.setBrandAndDutyTerritory(roles, dutyTerritories, brands, projectUserBrandList, projectUserDutyTerritoryList, id);
}
result.success("修改成功!");
@@ -11,6 +11,7 @@ public enum ProjectRoleEnum {
MANAGER("领导角色","11","R&H Manager"),
ADMIN("系统管理员","12","admin"),
VIEWER("Viewer","13","Viewer"),
BRAND_ADMINISTRATOR("品牌管理员","14","BrandAdministrator"),
;
String name;
@@ -713,28 +713,33 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
public void setBrandAndDutyTerritory(String roles, String dutyTerritories, String brands, List<ProjectUserBrand> projectUserBrandList, List<ProjectUserDutyTerritory> projectUserDutyTerritoryList, String userId) {
List<String> roleCodes = sysRoleService.listByIds(Arrays.asList(roles.split(","))).stream().map(SysRole::getRoleCode).collect(Collectors.toList());
if (roleCodes.contains(ProjectRoleEnum.VIEWER.getCode())) {
if (roleCodes.contains(ProjectRoleEnum.VIEWER.getCode())||roleCodes.contains(ProjectRoleEnum.BRAND_ADMINISTRATOR.getCode())) {
//viewer设置对应的责任领域
if (roleCodes.contains(ProjectRoleEnum.VIEWER.getCode())) {
//先删后加
QueryWrapper<ProjectUserDutyTerritory> dutyTerritoryDelWrapper = new QueryWrapper<>();
dutyTerritoryDelWrapper.eq("user_id", userId);
projectUserDutyTerritoryService.remove(dutyTerritoryDelWrapper);
if (ObjectUtils.isNotEmpty(dutyTerritories)) {
List<String> dictItemValue = sysDictItemService.selectItemsByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue()).stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
for (String dutyTerritory : dutyTerritories.split(",")) {
//校验责任领域是否合法
if (dictItemValue.contains(dutyTerritory)) {
ProjectUserDutyTerritory projectUserDutyTerritory = new ProjectUserDutyTerritory();
projectUserDutyTerritory.setUserId(userId);
projectUserDutyTerritory.setDutyTerritory(dutyTerritory);
projectUserDutyTerritoryList.add(projectUserDutyTerritory);
}
}
}
}
//先删后加
QueryWrapper<ProjectUserBrand> brandDelWrapper = new QueryWrapper<>();
brandDelWrapper.eq("user_id", userId);
projectUserBrandService.remove(brandDelWrapper);
QueryWrapper<ProjectUserDutyTerritory> dutyTerritoryDelWrapper = new QueryWrapper<>();
dutyTerritoryDelWrapper.eq("user_id", userId);
projectUserDutyTerritoryService.remove(dutyTerritoryDelWrapper);
if (ObjectUtils.isNotEmpty(dutyTerritories)) {
List<String> dictItemValue = sysDictItemService.selectItemsByDictCode(DictCodeEnum.DUTY_TERRITORY.getValue()).stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
for (String dutyTerritory : dutyTerritories.split(",")) {
//校验责任领域是否合法
if (dictItemValue.contains(dutyTerritory)) {
ProjectUserDutyTerritory projectUserDutyTerritory = new ProjectUserDutyTerritory();
projectUserDutyTerritory.setUserId(userId);
projectUserDutyTerritory.setDutyTerritory(dutyTerritory);
projectUserDutyTerritoryList.add(projectUserDutyTerritory);
}
}
}
if (ObjectUtils.isNotEmpty(brands)) {
List<String> dictItemValue = sysDictItemService.selectItemsByDictCode(DictCodeEnum.BRAND.getValue()).stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
for (String brand : brands.split(",")) {