Commit d1861701 by 李小龙

合并查看角色和菜单接口

parent 75dd95d9
...@@ -35,4 +35,7 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable { ...@@ -35,4 +35,7 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
@ApiModelProperty(value = "菜单集合id") @ApiModelProperty(value = "菜单集合id")
private List<String> menuIdList; private List<String> menuIdList;
@ApiModelProperty(value = "菜单集合")
private List<PlatMenuDTOVO> menuList;
} }
...@@ -56,5 +56,8 @@ public class SaasRoleDTOVO extends BaseIdDTO implements Serializable { ...@@ -56,5 +56,8 @@ public class SaasRoleDTOVO extends BaseIdDTO implements Serializable {
@ApiModelProperty(value = "菜单id集合") @ApiModelProperty(value = "菜单id集合")
private List<String> menuIdList; private List<String> menuIdList;
@ApiModelProperty(value = "菜单集合")
private List<SaasMenuDTOVO> menuDTOVOList;
} }
package com.makeit.module.admin.vo.plat;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.dto.BaseTenantDTO;
import lombok.Data;
/**
* 租户端角色菜单关联表
* @TableName plat_role_menu
*/
@TableName(value ="plat_role_menu")
@Data
public class PlatRoleMenuVO extends BaseTenantDTO {
/**
* 角色id
*/
private String roleId;
/**
* 菜单id
*/
private String menuId;
@TableField(exist = false)
private String menuName;
}
\ No newline at end of file
...@@ -56,6 +56,8 @@ public class PlatAlarmRecord extends BaseBusEntity { ...@@ -56,6 +56,8 @@ public class PlatAlarmRecord extends BaseBusEntity {
private String orgId; private String orgId;
private String deviceId;
} }
package com.makeit.entity.platform.auth; package com.makeit.entity.platform.auth;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.makeit.common.entity.BaseBusEntity; import com.makeit.common.entity.BaseBusEntity;
import lombok.Data; import lombok.Data;
...@@ -13,11 +12,6 @@ import lombok.Data; ...@@ -13,11 +12,6 @@ import lombok.Data;
@TableName(value ="plat_role_menu") @TableName(value ="plat_role_menu")
@Data @Data
public class PlatRoleMenu extends BaseBusEntity { public class PlatRoleMenu extends BaseBusEntity {
/**
* id
*/
@TableId
private String id;
/** /**
* 租户id * 租户id
......
...@@ -7,6 +7,7 @@ import com.makeit.common.entity.BaseEntity; ...@@ -7,6 +7,7 @@ import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO; import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper; import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper;
...@@ -93,5 +94,11 @@ implements PlatAlarmRecordService{ ...@@ -93,5 +94,11 @@ implements PlatAlarmRecordService{
@Transactional @Transactional
public void notice(String recordId) { public void notice(String recordId) {
//todo //todo
PlatAlarmRecord platAlarmRecord = this.getById(recordId);
PlatAlarmConfig platAlarmConfig = platAlarmConfigService.getById(platAlarmRecord.getAlarmId());
String deviceId = platAlarmRecord.getDeviceId();
} }
} }
...@@ -12,6 +12,7 @@ import com.makeit.dto.platform.auth.PlatUserRoleDTO; ...@@ -12,6 +12,7 @@ import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatRole; import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleMenu; import com.makeit.entity.platform.auth.PlatRoleMenu;
import com.makeit.entity.platform.auth.PlatRoleOrg; import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.module.admin.dto.plat.PlatMenuDTOVO;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO; import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import java.util.List; import java.util.List;
...@@ -46,6 +47,8 @@ public interface PlatRoleService extends IService<PlatRole> { ...@@ -46,6 +47,8 @@ public interface PlatRoleService extends IService<PlatRole> {
void assignDeptList(PlatRoleDeptDTOVO tntRoleDeptDTO); void assignDeptList(PlatRoleDeptDTOVO tntRoleDeptDTO);
List<PlatMenuDTOVO> getAssignMenuDTO(String id);
List<PlatRoleOrg> getDeptListByRoleId(String roleId); List<PlatRoleOrg> getDeptListByRoleId(String roleId);
......
...@@ -21,9 +21,11 @@ import com.makeit.entity.saas.PlatMenu; ...@@ -21,9 +21,11 @@ import com.makeit.entity.saas.PlatMenu;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.enums.IsTenantAccountEnum; import com.makeit.enums.IsTenantAccountEnum;
import com.makeit.enums.id.TreeConst;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdUtil; import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.mapper.platform.auth.PlatRoleMapper; import com.makeit.mapper.platform.auth.PlatRoleMapper;
import com.makeit.module.admin.dto.plat.PlatMenuDTOVO;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO; import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatRoleMenuService; import com.makeit.service.platform.auth.PlatRoleMenuService;
...@@ -184,9 +186,32 @@ implements PlatRoleService { ...@@ -184,9 +186,32 @@ implements PlatRoleService {
JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> r.setDeptName(e.getName())); JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> r.setDeptName(e.getName()));
List<PlatMenuDTOVO> assignMenuDTO = getAssignMenuDTO(id);
List<PlatMenuDTOVO> tree = tree(assignMenuDTO);
vo.setMenuList(tree);
return vo; return vo;
} }
public List<PlatMenuDTOVO> tree(List<PlatMenuDTOVO> platMenuList) {
Map<String, PlatMenuDTOVO> map = StreamUtil.toMap(platMenuList, PlatMenuDTOVO::getId);
List<PlatMenuDTOVO> topList = StreamUtil.filter(platMenuList, e -> TreeConst.TOP_LEVEL.equals(e.getParentId()));
platMenuList.forEach(e -> {
PlatMenuDTOVO parent = map.get(e.getParentId());
if (parent != null) {
List<PlatMenuDTOVO> children = parent.getChildren();
if (children == null) {
children = new ArrayList<>(10);
parent.setChildren(children);
}
children.add(e);
}
});
return topList;
}
@Transactional @Transactional
@Override @Override
public void del(String id) { public void del(String id) {
...@@ -287,6 +312,27 @@ implements PlatRoleService { ...@@ -287,6 +312,27 @@ implements PlatRoleService {
return newList; return newList;
} }
@Override
public List<PlatMenuDTOVO> getAssignMenuDTO(String id) {
List<String> menuIdList = new ArrayList<>(10);
menuIdList.add(-1 + "");
if (StringUtils.isNotBlank(id)) {
List<PlatRoleMenu> platRoleList = platRoleMenuService.list(new QueryWrapper<PlatRoleMenu>().lambda()
.in(PlatRoleMenu::getRoleId, id));
menuIdList.addAll(StreamUtil.map(platRoleList, PlatRoleMenu::getMenuId));
}
List<PlatMenu> platMenuList = platMenuService.list(new QueryWrapper<PlatMenu>().lambda()
.in(StringUtils.isNotBlank(id), PlatMenu::getId, menuIdList)
//.orderByAsc(PlatMenu::getParentId)
.orderByAsc(PlatMenu::getSort)
.orderByAsc(PlatMenu::getCreateDate)
);
return BeanDtoVoUtils.listVo(platMenuList, PlatMenuDTOVO.class);
}
@Transactional @Transactional
@Override @Override
public void assignDeptList(PlatRoleDeptDTOVO tntRoleDeptDTO) { public void assignDeptList(PlatRoleDeptDTOVO tntRoleDeptDTO) {
......
...@@ -49,7 +49,7 @@ import java.util.stream.Collectors; ...@@ -49,7 +49,7 @@ import java.util.stream.Collectors;
public class SaasMenuServiceImpl extends ServiceImpl<SaasMenuMapper, SaasMenu> implements SaasMenuService { public class SaasMenuServiceImpl extends ServiceImpl<SaasMenuMapper, SaasMenu> implements SaasMenuService {
@Autowired @Autowired
private SaasRoleMenuService platRoleMenuService; private SaasRoleMenuService saasRoleMenuService;
private static final Logger logger = LoggerFactory.getLogger(SaasMenuServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(SaasMenuServiceImpl.class);
...@@ -73,7 +73,7 @@ public class SaasMenuServiceImpl extends ServiceImpl<SaasMenuMapper, SaasMenu> i ...@@ -73,7 +73,7 @@ public class SaasMenuServiceImpl extends ServiceImpl<SaasMenuMapper, SaasMenu> i
List<String> menuIdList = new ArrayList<>(10); List<String> menuIdList = new ArrayList<>(10);
menuIdList.add(-1 + ""); menuIdList.add(-1 + "");
if (StringUtils.isNotBlank(dto.getRoleId())) { if (StringUtils.isNotBlank(dto.getRoleId())) {
List<SaasRoleMenu> platRoleList = platRoleMenuService.list(new QueryWrapper<SaasRoleMenu>().lambda() List<SaasRoleMenu> platRoleList = saasRoleMenuService.list(new QueryWrapper<SaasRoleMenu>().lambda()
.in(SaasRoleMenu::getRoleId, dto.getRoleId())); .in(SaasRoleMenu::getRoleId, dto.getRoleId()));
menuIdList.addAll(StreamUtil.map(platRoleList, SaasRoleMenu::getMenuId)); menuIdList.addAll(StreamUtil.map(platRoleList, SaasRoleMenu::getMenuId));
} }
......
...@@ -14,9 +14,12 @@ import com.makeit.enums.CodeMessageEnum; ...@@ -14,9 +14,12 @@ import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.mapper.saas.SaasRoleMapper; import com.makeit.mapper.saas.SaasRoleMapper;
import com.makeit.module.admin.dto.saas.SaasMenuDTOVO;
import com.makeit.module.admin.dto.saas.SaasMenuQueryDTO;
import com.makeit.module.admin.dto.saas.SaasRoleDTOVO; import com.makeit.module.admin.dto.saas.SaasRoleDTOVO;
import com.makeit.module.admin.dto.saas.SaasRoleMenuDTO; import com.makeit.module.admin.dto.saas.SaasRoleMenuDTO;
import com.makeit.module.admin.dto.saas.SaasUserRoleDTO; import com.makeit.module.admin.dto.saas.SaasUserRoleDTO;
import com.makeit.service.saas.SaasMenuService;
import com.makeit.service.saas.SaasRoleMenuService; import com.makeit.service.saas.SaasRoleMenuService;
import com.makeit.service.saas.SaasRoleService; import com.makeit.service.saas.SaasRoleService;
import com.makeit.service.saas.SaasUserRoleService; import com.makeit.service.saas.SaasUserRoleService;
...@@ -48,6 +51,9 @@ implements SaasRoleService{ ...@@ -48,6 +51,9 @@ implements SaasRoleService{
@Autowired @Autowired
private SaasRoleMenuService saasRoleMenuService; private SaasRoleMenuService saasRoleMenuService;
@Autowired
private SaasMenuService saasMenuService;
@Override @Override
public List<SaasRoleDTOVO> list(SaasRoleDTOVO dto) { public List<SaasRoleDTOVO> list(SaasRoleDTOVO dto) {
List<SaasRole> platRoleList = list(getQueryWrapper(dto) List<SaasRole> platRoleList = list(getQueryWrapper(dto)
...@@ -113,7 +119,12 @@ implements SaasRoleService{ ...@@ -113,7 +119,12 @@ implements SaasRoleService{
@Override @Override
public SaasRoleDTOVO view(String id) { public SaasRoleDTOVO view(String id) {
return BeanDtoVoUtils.convert(getById(id), SaasRoleDTOVO.class); SaasRoleDTOVO saasRoleDTOVO = BeanDtoVoUtils.convert(getById(id), SaasRoleDTOVO.class);
SaasMenuQueryDTO saasMenuQueryDTO = new SaasMenuQueryDTO();
saasMenuQueryDTO.setRoleId(id);
List<SaasMenuDTOVO> tree = saasMenuService.tree(saasMenuQueryDTO);
saasRoleDTOVO.setMenuDTOVOList(tree);
return saasRoleDTOVO;
} }
@Transactional @Transactional
......
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 sign in to comment