新增角色菜单临时接口
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.cool.store.dto.menu;
|
||||
|
||||
|
||||
import com.cool.store.entity.SysMenuDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.MenuTypeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
@Data
|
||||
public class AddMenuDTO {
|
||||
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("parent_id")
|
||||
@NotNull(message = "父Id不能为空")
|
||||
private Long parentId;
|
||||
|
||||
@NotBlank(message = "地址不能为空")
|
||||
private String path;
|
||||
|
||||
private String component;
|
||||
|
||||
private String target;
|
||||
|
||||
private String icon;
|
||||
|
||||
private String env;
|
||||
|
||||
public static SysMenuDO convertDO(AddMenuDTO param, MenuTypeEnum menuTypeEnum){
|
||||
SysMenuDO menu = new SysMenuDO();
|
||||
SysMenuDO sysMenuDO = new SysMenuDO();
|
||||
sysMenuDO.setParentId(param.getParentId());
|
||||
sysMenuDO.setName(param.getName());
|
||||
sysMenuDO.setCode(param.getName());
|
||||
sysMenuDO.setPath(param.getPath());
|
||||
sysMenuDO.setType(null);
|
||||
sysMenuDO.setSource("menu");
|
||||
sysMenuDO.setAction(1);
|
||||
sysMenuDO.setPlatform("PC");
|
||||
sysMenuDO.setComponent(param.getComponent());
|
||||
sysMenuDO.setTarget(param.getTarget());
|
||||
sysMenuDO.setIcon(param.getIcon());
|
||||
sysMenuDO.setMenuType(menuTypeEnum.getCode());
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.cool.store.dto.role;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: RoleUpdateDTO
|
||||
* @Description:
|
||||
* @date 2023-07-25 15:03
|
||||
*/
|
||||
@Data
|
||||
public class RoleUpdateDTO {
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private String roleId;
|
||||
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("菜单ids")
|
||||
private List<Long> menuIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.cool.store.vo.role;
|
||||
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.entity.SysRoleMenuDO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: RoleAuthInfoVO
|
||||
* @Description:
|
||||
* @date 2023-07-25 15:11
|
||||
*/
|
||||
@Data
|
||||
public class RoleAuthInfoVO {
|
||||
|
||||
@ApiModelProperty("角色id")
|
||||
private String roleId;
|
||||
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("菜单ids")
|
||||
private List<Long> menuIds;
|
||||
|
||||
public static RoleAuthInfoVO convertVO(SysRoleDO role, List<SysRoleMenuDO> roleMenuList){
|
||||
if(Objects.isNull(role)){
|
||||
return null;
|
||||
}
|
||||
RoleAuthInfoVO result = new RoleAuthInfoVO();
|
||||
result.setRoleId(role.getRoleId());
|
||||
result.setRoleName(role.getRoleName());
|
||||
result.setMenuIds(ListUtils.emptyIfNull(roleMenuList).stream().map(SysRoleMenuDO::getMenuId).distinct().collect(Collectors.toList()));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.cool.store.vo.role;
|
||||
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: RolePageVO
|
||||
* @Description:
|
||||
* @date 2023-07-25 15:10
|
||||
*/
|
||||
@Data
|
||||
public class RolePageVO {
|
||||
|
||||
private String roleId;
|
||||
|
||||
private String roleName;
|
||||
|
||||
public static List<RolePageVO> convertList(List<SysRoleDO> roleList){
|
||||
if(CollectionUtils.isEmpty(roleList)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<RolePageVO> resultList = new ArrayList<>();
|
||||
for (SysRoleDO sysRole : roleList) {
|
||||
RolePageVO role = new RolePageVO();
|
||||
role.setRoleId(sysRole.getRoleId());
|
||||
role.setRoleName(role.getRoleName());
|
||||
resultList.add(role);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user