|
@@ -182,8 +182,9 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
|
*
|
|
|
* @param perStr
|
|
|
*/
|
|
|
- public void addMenu(String customerTypeStr,String perStr) {
|
|
|
- List<TbCostomer> costomerList = this.findCustomerList(customerTypeStr);
|
|
|
+ public void addMenu(String customerTypeStr, String perStr) {
|
|
|
+ List<Integer> customerTypeList = StrUtil.splitTrim(customerTypeStr, ",").stream().map(Integer::new).collect(Collectors.toList());
|
|
|
+ List<TbCostomer> costomerList = this.findCustomerList(customerTypeList);
|
|
|
List<String> customerIdList = costomerList.stream().map(TbCostomer::getId).collect(Collectors.toList());
|
|
|
List<SpAdmin> spAdminList = spAdminService.findByCustomerIdList(customerIdList);
|
|
|
List<String> roleList = spAdminList.stream().map(SpAdmin::getRoleId).collect(Collectors.toList());
|
|
@@ -204,8 +205,8 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
|
tbInitPermissionService.saveOrUpdateBatch(initPermissions);
|
|
|
});
|
|
|
//增加旧客户的权限
|
|
|
- roleList.forEach(roleId->{
|
|
|
- spRolePermissionMapper.saveRolePer(Long.valueOf(roleId),list);
|
|
|
+ roleList.forEach(roleId -> {
|
|
|
+ spRolePermissionMapper.saveRolePer(Long.valueOf(roleId), list);
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -215,10 +216,40 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<TbCostomer> findCustomerList(String customerTypeStr) {
|
|
|
+ private List<TbCostomer> findCustomerList(List<Integer> list) {
|
|
|
QueryWrapper<TbCostomer> ew = new QueryWrapper<>();
|
|
|
- List<Integer>list= StrUtil.splitTrim(customerTypeStr,",").stream().map(Integer::new).collect(Collectors.toList());
|
|
|
ew.lambda().in(TbCostomer::getType, list);
|
|
|
return list(ew);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除对应客户、合作伙伴的权限
|
|
|
+ *
|
|
|
+ * @param customerTypeStr
|
|
|
+ * @param perStr
|
|
|
+ */
|
|
|
+ public void delCustomerMenu(String customerTypeStr, String perStr) {
|
|
|
+ List<Integer> customerTypeList = StrUtil.splitTrim(customerTypeStr, ",").stream().map(Integer::new).collect(Collectors.toList());
|
|
|
+ List<TbCostomer> costomerList = this.findCustomerList(customerTypeList);
|
|
|
+ List<String> customerIdList = costomerList.stream().map(TbCostomer::getId).collect(Collectors.toList());
|
|
|
+ List<SpAdmin> spAdminList = spAdminService.findByCustomerIdList(customerIdList);
|
|
|
+ List<String> roleList = spAdminList.stream().map(SpAdmin::getRoleId).collect(Collectors.toList());
|
|
|
+ //权限列表
|
|
|
+ List<String> list = StrUtil.splitTrim(perStr, ",");
|
|
|
+ //删除角色-权限表数据
|
|
|
+ spRolePermissionMapper.deleteByRoleAndCode(roleList, list);
|
|
|
+ //删除tb_init_permission
|
|
|
+ List<TbInitPermission> initPermissionList = tbInitPermissionService.findByCode(list);
|
|
|
+ initPermissionList.forEach(tbInitPermission -> {
|
|
|
+ String type = tbInitPermission.getType();
|
|
|
+ List<String> typeList = StrUtil.splitTrim(type, ",");
|
|
|
+ typeList.removeIf(typeStr->customerTypeList.contains(Integer.valueOf(typeStr)));
|
|
|
+ if (typeList.isEmpty()){
|
|
|
+ tbInitPermissionService.removeById(tbInitPermission.getId());
|
|
|
+ }else {
|
|
|
+ tbInitPermission.setType(String.join(",", typeList));
|
|
|
+ tbInitPermissionService.updateById(tbInitPermission);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|