前端品牌回显 + 后端大列表修改权限筛选
This commit is contained in:
+1
-1
@@ -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("修改成功!");
|
||||
|
||||
+1
@@ -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;
|
||||
|
||||
+22
-17
@@ -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(",")) {
|
||||
|
||||
+7
-9
@@ -768,14 +768,12 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
Integer isViewer = sysRoleMapper.queryUserRoleByCode(ProjectRoleEnum.VIEWER.getName(), loginUser.getId());
|
||||
Set<String> projectIds = new HashSet<>();
|
||||
if (isViewer == 0) {
|
||||
//如果不是viewer,根据项目用户权限表筛选有权访问的项目
|
||||
Set<String> permissionProjectIds = projectUserPermissionMapper.queryProjectIdsByUserId(loginUser.getId());
|
||||
if (ObjectUtils.isNotEmpty(permissionProjectIds)) {
|
||||
projectIds.addAll(permissionProjectIds);
|
||||
}
|
||||
//根据项目用户权限表筛选有权访问的项目
|
||||
Set<String> permissionProjectIds = projectUserPermissionMapper.queryProjectIdsByUserId(loginUser.getId());
|
||||
if (ObjectUtils.isNotEmpty(permissionProjectIds)) {
|
||||
projectIds.addAll(permissionProjectIds);
|
||||
}
|
||||
if (sysRoleMapper.queryUserRoleByCode(ProjectRoleEnum.VIEWER.getName(), loginUser.getId()) > 0) {
|
||||
if (isViewer > 0) {
|
||||
//如果是Viewer,根据配置的品牌筛选可访问的项目
|
||||
List<String> brandTypes = projectUserBrandService.queryBrandByUserId(loginUser.getId());
|
||||
if (ObjectUtils.isNotEmpty(brandTypes)) {
|
||||
@@ -874,10 +872,10 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
|
||||
|
||||
List<ProjectLibraryBase> resultLast = new ArrayList<>();
|
||||
//权限筛选
|
||||
if (isViewer != 0) {
|
||||
if (sysUserService.isAdministrator()) {
|
||||
//管理员查看全部
|
||||
resultLast = resultNew;
|
||||
} else {
|
||||
|
||||
for (ProjectLibraryBase projectLibraryBase : resultNew) {
|
||||
//判断父项目是否有权限
|
||||
if (!projectIds.contains(projectLibraryBase.getId())) {
|
||||
|
||||
@@ -61,10 +61,8 @@
|
||||
</div>
|
||||
<div class="text-field">
|
||||
<span class="text-field-left" :title="$t('brand')">{{$t('brand')}}</span>
|
||||
<span class="text-field-right text-field-right-color"
|
||||
:title="queryForm.brand"
|
||||
@click="urlClick(queryForm.brand)"
|
||||
>{{queryForm.brand}}</span>
|
||||
<span class="text-field-right" :title="queryForm.brandText"
|
||||
>{{queryForm.brandText}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-text">
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
align: 'center',
|
||||
width: 180,
|
||||
ellipsis: true,
|
||||
dataIndex: 'brand'
|
||||
dataIndex: 'brandText'
|
||||
},
|
||||
{
|
||||
title: this.$t('explain'),
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
<!-- :placeholder="$t('PleaseSelect')+$t('brand')"-->
|
||||
<!-- :type="'select'"-->
|
||||
<!-- :triggerChange="false" :dictCode="'brand'"/>-->
|
||||
<a-select allowClear :placeholder="$t('PleaseSelect')+$t('engineeringInterfacePerson')"
|
||||
<a-select allowClear mode="multiple" :getPopupContainer="triggerNode => triggerNode.parentNode" :placeholder="$t('PleaseSelect')+$t('engineeringInterfacePerson')"
|
||||
v-model="brands">
|
||||
<a-select-option v-for="(item, key) in brandsList" :key="key" :value="item.value">
|
||||
<span style="display: inline-block;width: 100%" :title=" item.text || item.label ">
|
||||
@@ -413,7 +413,7 @@
|
||||
this.dutyTerritories = res.dutyTerritoryList.join(',')
|
||||
}
|
||||
if(res.brandList){
|
||||
this.brands = res.brandList.join(',')
|
||||
this.brands = res.brandList
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -462,7 +462,7 @@
|
||||
ids: this.userId,
|
||||
selectedroles: selectedRole.join(','),
|
||||
dutyTerritories: dutyTerritorie,
|
||||
brands: brand
|
||||
brands: brand.join(',')
|
||||
}
|
||||
postAction('/sys/user/setRole', param).then((res) => {
|
||||
if (res.success) {
|
||||
|
||||
Reference in New Issue
Block a user