|
@@ -11,7 +11,9 @@ import com.gree.mall.manager.exception.RemoteServiceException;
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
import com.gree.mall.manager.plus.entity.AdminRole;
|
|
import com.gree.mall.manager.plus.entity.AdminRole;
|
|
import com.gree.mall.manager.plus.entity.AdminUser;
|
|
import com.gree.mall.manager.plus.entity.AdminUser;
|
|
|
|
+import com.gree.mall.manager.plus.entity.AdminUserModuleRela;
|
|
import com.gree.mall.manager.plus.service.AdminRoleService;
|
|
import com.gree.mall.manager.plus.service.AdminRoleService;
|
|
|
|
+import com.gree.mall.manager.plus.service.AdminUserModuleRelaService;
|
|
import com.gree.mall.manager.plus.service.AdminUserService;
|
|
import com.gree.mall.manager.plus.service.AdminUserService;
|
|
import com.gree.mall.manager.plus.service.AdminWebsitService;
|
|
import com.gree.mall.manager.plus.service.AdminWebsitService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,12 +36,14 @@ public class AdminRoleLogic {
|
|
AdminWebsitService adminWebsitService;
|
|
AdminWebsitService adminWebsitService;
|
|
@Autowired
|
|
@Autowired
|
|
CommonLogic commonLogic;
|
|
CommonLogic commonLogic;
|
|
|
|
+ @Autowired
|
|
|
|
+ AdminUserModuleRelaService adminUserModuleRelaService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 角色列表
|
|
* 角色列表
|
|
*/
|
|
*/
|
|
- public IPage<AdminRole> listPage(HttpServletRequest request ,String companyWechatName, Integer pageNo, Integer pageSize) {
|
|
|
|
|
|
+ public IPage<AdminRole> listPage(HttpServletRequest request, String parentRoleName, String companyWechatName, Integer pageNo, Integer pageSize) {
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
@@ -55,6 +59,7 @@ public class AdminRoleLogic {
|
|
|
|
|
|
Page<AdminRole> rolePage = adminRoleService.lambdaQuery()
|
|
Page<AdminRole> rolePage = adminRoleService.lambdaQuery()
|
|
.like(StringUtils.isNotBlank(companyWechatName), AdminRole::getCompanyName, companyWechatName)
|
|
.like(StringUtils.isNotBlank(companyWechatName), AdminRole::getCompanyName, companyWechatName)
|
|
|
|
+ .like(StringUtils.isNotBlank(parentRoleName), AdminRole::getParentRoleName, parentRoleName)
|
|
.le(AdminRole::getType, type)
|
|
.le(AdminRole::getType, type)
|
|
.in(CollectionUtils.isNotEmpty(companyWechatIds), AdminRole::getCompanyWechatId, companyWechatIds)
|
|
.in(CollectionUtils.isNotEmpty(companyWechatIds), AdminRole::getCompanyWechatId, companyWechatIds)
|
|
.in(CollectionUtils.isNotEmpty(levelList), AdminRole::getLevel, levelList)
|
|
.in(CollectionUtils.isNotEmpty(levelList), AdminRole::getLevel, levelList)
|
|
@@ -92,6 +97,11 @@ public class AdminRoleLogic {
|
|
|
|
|
|
adminRole.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
adminRole.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
adminRole.setCompanyName(adminUser.getCompanyName());
|
|
adminRole.setCompanyName(adminUser.getCompanyName());
|
|
|
|
+ // 父级角色id不为空查询父级角色名填充
|
|
|
|
+ if (StringUtils.isNotBlank(adminRole.getParentRoleId())) {
|
|
|
|
+ final AdminRole parentRole = adminRoleService.getById(adminRole.getParentRoleId());
|
|
|
|
+ adminRole.setParentRoleName(parentRole.getName());
|
|
|
|
+ }
|
|
adminRoleService.save(adminRole);
|
|
adminRoleService.save(adminRole);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -119,13 +129,38 @@ public class AdminRoleLogic {
|
|
if (Objects.nonNull(adminRole.getType()) && adminRole.getType() == 0 && adminRole.getLevel() == 0) {
|
|
if (Objects.nonNull(adminRole.getType()) && adminRole.getType() == 0 && adminRole.getLevel() == 0) {
|
|
throw new RemoteServiceException("网点需要选级别");
|
|
throw new RemoteServiceException("网点需要选级别");
|
|
}
|
|
}
|
|
|
|
+
|
|
adminRole.setCompanyWechatId(oldData.getCompanyWechatId())
|
|
adminRole.setCompanyWechatId(oldData.getCompanyWechatId())
|
|
.setCompanyName(oldData.getCompanyName());
|
|
.setCompanyName(oldData.getCompanyName());
|
|
- adminRoleService.updateById(adminRole);
|
|
|
|
|
|
+
|
|
|
|
+ // 父级角色id不为空查询父级角色名填充
|
|
|
|
+ if (StringUtils.isNotBlank(adminRole.getParentRoleId())) {
|
|
|
|
+ final AdminRole parentRole = adminRoleService.getById(adminRole.getParentRoleId());
|
|
|
|
+ adminRole.setParentRoleName(parentRole.getName());
|
|
|
|
+ }
|
|
|
|
|
|
if (adminRole.getName() != null) {
|
|
if (adminRole.getName() != null) {
|
|
- adminUserService.lambdaUpdate().set(AdminUser::getRoleName, adminRole.getName())
|
|
|
|
- .eq(AdminUser::getRoleId, adminRole.getAdminRoleId()).update();
|
|
|
|
|
|
+ // 更新账号使用对应的角色名
|
|
|
|
+ adminUserService.lambdaUpdate()
|
|
|
|
+ .set(AdminUser::getRoleName, adminRole.getName())
|
|
|
|
+ .eq(AdminUser::getRoleId, adminRole.getAdminRoleId())
|
|
|
|
+ .update();
|
|
|
|
+
|
|
|
|
+ // 更新所有子级的父级角色名
|
|
|
|
+ adminRoleService.lambdaUpdate()
|
|
|
|
+ .set(AdminRole::getParentRoleName, adminRole.getName())
|
|
|
|
+ .eq(AdminRole::getParentRoleId, adminRole.getAdminRoleId())
|
|
|
|
+ .update();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ adminRoleService.updateById(adminRole);
|
|
|
|
+
|
|
|
|
+ // 本次编辑与历史父级不一致
|
|
|
|
+ if (!adminRole.getParentRoleId().equals(oldData.getParentRoleId())) {
|
|
|
|
+ // 清空角色已选权限
|
|
|
|
+ adminUserModuleRelaService.lambdaUpdate()
|
|
|
|
+ .eq(AdminUserModuleRela::getAdminRoleId, oldData.getAdminRoleId())
|
|
|
|
+ .remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|