Commit cc1a6c0d authored by 赵啸非's avatar 赵啸非

删除角色关联删除

parent 1c45ebd0
...@@ -690,7 +690,7 @@ data|object|数据对象 ...@@ -690,7 +690,7 @@ data|object|数据对象
**响应消息样例:** **响应消息样例:**
``` ```
{ {
"msg":"新增模块成功", "msg":"新增成功",
"code":1, "code":1,
"data":{} "data":{}
} }
......
...@@ -8,22 +8,52 @@ ...@@ -8,22 +8,52 @@
package com.mortals.xhx.module.role.service.impl; package com.mortals.xhx.module.role.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.role.dao.RoleDao; import com.mortals.xhx.module.role.dao.RoleDao;
import com.mortals.xhx.module.role.model.RoleEntity; import com.mortals.xhx.module.role.model.*;
import com.mortals.xhx.module.role.service.RoleAuthService;
import com.mortals.xhx.module.role.service.RoleService; import com.mortals.xhx.module.role.service.RoleService;
import com.mortals.xhx.module.role.service.RoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
/** /**
* <p>Title: 角色信息</p> * <p>Title: 角色信息</p>
* <p>Description: RoleServiceImpl service接口 </p> * <p>Description: RoleServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p> * <p>Copyright: Copyright &reg; </p>
* <p>Company: </p> * <p>Company: </p>
*
* @author * @author
* @version 1.0.0 * @version 1.0.0
*/ */
@Service("roleService") @Service("roleService")
public class RoleServiceImpl extends AbstractCRUDServiceImpl<RoleDao, RoleEntity, Long> implements RoleService { public class RoleServiceImpl extends AbstractCRUDServiceImpl<RoleDao, RoleEntity, Long> implements RoleService {
@Autowired
private RoleAuthService roleAuthService;
@Autowired
private RoleUserService roleUserService;
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
RoleAuthQuery roleAuthQuery = new RoleAuthQuery();
roleAuthQuery.setRoleIdList(Arrays.asList(ids));
Long[] roleAuthIds = roleAuthService.find(roleAuthQuery).stream().map(RoleAuthEntity::getId).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(roleAuthIds)) {
roleAuthService.remove(roleAuthIds, context);
}
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setRoleIdList(Arrays.asList(ids));
Long[] roleUserIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getId).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(roleUserIds)) {
roleUserService.remove(roleUserIds, context);
}
super.removeAfter(ids, context, result);
}
} }
\ No newline at end of file
...@@ -56,7 +56,6 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -56,7 +56,6 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
if(!ObjectUtils.isEmpty(collect.get(item.getId()))){ if(!ObjectUtils.isEmpty(collect.get(item.getId()))){
item.setRoleId(collect.get(item.getId()).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(","))); item.setRoleId(collect.get(item.getId()).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(",")));
item.setRoleName(collect.get(item.getId()).stream().map(m->roleMap.get(m.getRoleId())).filter(f->f!=null).collect(Collectors.joining(","))); item.setRoleName(collect.get(item.getId()).stream().map(m->roleMap.get(m.getRoleId())).filter(f->f!=null).collect(Collectors.joining(",")));
} }
}); });
super.findAfter(entity, pageInfo, context, list); super.findAfter(entity, pageInfo, context, list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment