菜单模块
This commit is contained in:
parent
8f35105360
commit
f2d9c17648
|
|
@ -0,0 +1,14 @@
|
|||
package com.securitycontrol.entity.system;
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-02-27-18:13
|
||||
* @version:1.0
|
||||
* @description:常量
|
||||
*/
|
||||
public class Constant {
|
||||
|
||||
public final static Integer PARENT_ID = 0;
|
||||
|
||||
public final static Integer MENU_TYPE = 3;
|
||||
}
|
||||
|
|
@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
|
@ -27,7 +29,6 @@ public class MenuVo {
|
|||
private String menuName;
|
||||
|
||||
@ApiModelProperty(value = "菜单路径")
|
||||
@NotBlank(message = "菜单路径不能为空")
|
||||
@Length(max = 100,message = "菜单路径字符长度不能超过100个字符")
|
||||
private String menuUrl;
|
||||
|
||||
|
|
@ -42,6 +43,8 @@ public class MenuVo {
|
|||
private Integer parentId;
|
||||
|
||||
@ApiModelProperty(value = "菜单排序")
|
||||
@NotNull(message = "请输入菜单排序")
|
||||
@Range(message = "菜单排序为 {min} 到 {max} 之间", min = 1, max = 1000)
|
||||
private Integer menuSort;
|
||||
|
||||
@ApiModelProperty(value = "图标")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.securitycontrol.system.service;
|
||||
|
||||
import com.securitycontrol.common.core.utils.StringUtils;
|
||||
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
|
||||
import com.securitycontrol.common.core.utils.aes.StringHelper;
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.entity.system.Constant;
|
||||
import com.securitycontrol.entity.system.dto.MenuDto;
|
||||
import com.securitycontrol.entity.system.vo.MenuVo;
|
||||
import com.securitycontrol.system.mapper.IMenuMapper;
|
||||
|
|
@ -32,8 +34,6 @@ public class MenuServiceImpl implements MenuService {
|
|||
@Resource(name = "IMenuMapper")
|
||||
private IMenuMapper mapper;
|
||||
|
||||
private final static Integer PARENT_ID = 0;
|
||||
|
||||
@Override
|
||||
public AjaxResult getMenuList(MenuDto dto) {
|
||||
List<MenuVo> list = new ArrayList<>();
|
||||
|
|
@ -45,7 +45,7 @@ public class MenuServiceImpl implements MenuService {
|
|||
List<MenuVo> allList = new ArrayList<>(list);
|
||||
List<MenuVo> list2 = mapper.getMenuList(null);
|
||||
for (MenuVo vo : list) {
|
||||
if (!Objects.equals(PARENT_ID, vo.getParentId())) {
|
||||
if (!Objects.equals(Constant.PARENT_ID, vo.getParentId())) {
|
||||
getParentMenu(vo.getParentId(), list2, allList);
|
||||
}
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ public class MenuServiceImpl implements MenuService {
|
|||
MenuVo vo = list.stream().filter(org -> Objects.equals(menuId, org.getMenuId())).findFirst().orElse(null);
|
||||
assert vo != null;
|
||||
list2.add(vo);
|
||||
if (!Objects.equals(PARENT_ID, vo.getParentId())) {
|
||||
if (!Objects.equals(Constant.PARENT_ID, vo.getParentId())) {
|
||||
getParentMenu(vo.getParentId(), list, list2);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ public class MenuServiceImpl implements MenuService {
|
|||
}).collect(Collectors.toList());
|
||||
//过滤出最上级的菜单
|
||||
return list.stream()
|
||||
.filter(ele -> Objects.equals(PARENT_ID, ele.getParentId()))
|
||||
.filter(ele -> Objects.equals(Constant.PARENT_ID, ele.getParentId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
|
@ -114,6 +114,11 @@ public class MenuServiceImpl implements MenuService {
|
|||
vo.setParentId(0);
|
||||
}
|
||||
int result = mapper.isMenuName(vo);
|
||||
if(!Objects.equals(vo.getMenuType(),Constant.MENU_TYPE)){
|
||||
if(StringUtils.isBlank(vo.getMenuUrl())){
|
||||
return AjaxResult.error("菜单地址不能为空");
|
||||
}
|
||||
}
|
||||
if (vo.getMenuId() == null) {
|
||||
vo.setType(1);
|
||||
vo.setCreateTime(DateTimeHelper.getNowTime());
|
||||
|
|
|
|||
Loading…
Reference in New Issue