菜单增加前端菜单配置
This commit is contained in:
parent
a2afb0fef6
commit
00687e6718
|
|
@ -14,6 +14,7 @@ import com.multictrl.modules.sys.enums.MenuTypeEnum;
|
|||
import com.multictrl.modules.sys.service.SysMenuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -37,10 +38,11 @@ public class SysMenuController {
|
|||
private final ShiroService shiroService;
|
||||
|
||||
@GetMapping("nav")
|
||||
@Parameter(name = "openWith", description = "打开方式 1内部打开 2外部打开")
|
||||
@Operation(summary = "导航")
|
||||
public Result<List<SysMenuDTO>> nav() {
|
||||
public Result<List<SysMenuDTO>> nav(Integer openWith) {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, MenuTypeEnum.MENU.value());
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, openWith, MenuTypeEnum.MENU.value());
|
||||
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
|
|
@ -56,10 +58,13 @@ public class SysMenuController {
|
|||
|
||||
@GetMapping("list")
|
||||
@Operation(summary = "列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "openWith", description = "打开方式 1内部打开 2外部打开"),
|
||||
@Parameter(name = "type", description = "菜单类型 0:菜单 1:按钮 null:全部")
|
||||
})
|
||||
@RequiresPermissions("sys:menu:list")
|
||||
public Result<List<SysMenuDTO>> list(Integer type) {
|
||||
List<SysMenuDTO> list = sysMenuService.getAllMenuList(type);
|
||||
public Result<List<SysMenuDTO>> list(Integer openWith, Integer type) {
|
||||
List<SysMenuDTO> list = sysMenuService.getAllMenuList(openWith, type);
|
||||
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
|
|
@ -119,11 +124,12 @@ public class SysMenuController {
|
|||
}
|
||||
|
||||
@GetMapping("select")
|
||||
@Parameter(name = "openWith", description = "打开方式 1内部打开 2外部打开")
|
||||
@Operation(summary = "角色菜单权限")
|
||||
@RequiresPermissions("sys:menu:select")
|
||||
public Result<List<SysMenuDTO>> select() {
|
||||
public Result<List<SysMenuDTO>> select(Integer openWith) {
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, null);
|
||||
List<SysMenuDTO> list = sysMenuService.getUserMenuList(user, openWith, null);
|
||||
|
||||
return new Result<List<SysMenuDTO>>().ok(list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
|||
*
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuEntity> getMenuList(@Param("menuType") Integer menuType);
|
||||
List<SysMenuEntity> getMenuList(@Param("openWith") Integer openWith, @Param("menuType") Integer menuType);
|
||||
|
||||
/**
|
||||
* 查询用户菜单列表
|
||||
|
|
@ -30,10 +30,11 @@ public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
|||
* @param userId 用户ID
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuEntity> getUserMenuList(@Param("userId") Long userId, @Param("menuType") Integer menuType);
|
||||
List<SysMenuEntity> getUserMenuList(@Param("userId") Long userId, @Param("openWith") Integer openWith, @Param("menuType") Integer menuType);
|
||||
|
||||
/**
|
||||
* 查询用户权限列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
List<String> getUserPermissionsList(Long userId);
|
||||
|
|
@ -45,6 +46,7 @@ public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
|||
|
||||
/**
|
||||
* 根据父菜单,查询子菜单
|
||||
*
|
||||
* @param pid 父菜单ID
|
||||
*/
|
||||
List<SysMenuEntity> getListPid(Long pid);
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ import com.multictrl.common.validator.group.AddGroup;
|
|||
import com.multictrl.common.validator.group.DefaultGroup;
|
||||
import com.multictrl.common.validator.group.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
|
@ -26,46 +23,52 @@ import java.util.Date;
|
|||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(title = "菜单管理")
|
||||
@Schema(name = "菜单管理")
|
||||
public class SysMenuDTO extends TreeNode<SysMenuDTO> implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(title = "id")
|
||||
@Schema(description = "id")
|
||||
@Null(message = "{id.null}", groups = AddGroup.class)
|
||||
@NotNull(message = "{id.require}", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(title = "上级ID")
|
||||
@Schema(description = "上级ID")
|
||||
@NotNull(message = "{sysmenu.pid.require}", groups = DefaultGroup.class)
|
||||
private Long pid;
|
||||
|
||||
@Schema(title = "菜单名称")
|
||||
@Schema(description = "菜单名称")
|
||||
@NotBlank(message = "sysmenu.name.require", groups = DefaultGroup.class)
|
||||
private String name;
|
||||
|
||||
@Schema(title = "菜单URL")
|
||||
@Schema(description = "菜单URL")
|
||||
private String url;
|
||||
|
||||
@Schema(title = "类型 0:菜单 1:按钮")
|
||||
@Schema(description = "类型 0:菜单 1:按钮")
|
||||
@Range(min = 0, max = 1, message = "{sysmenu.type.range}", groups = DefaultGroup.class)
|
||||
private Integer menuType;
|
||||
|
||||
@Schema(title = "菜单图标")
|
||||
@Schema(description = "菜单图标")
|
||||
private String icon;
|
||||
|
||||
@Schema(title = "授权(多个用逗号分隔,如:sys:user:list,sys:user:save)")
|
||||
@Schema(description = "授权(多个用逗号分隔,如:sys:user:list,sys:user:save)")
|
||||
private String permissions;
|
||||
|
||||
@Schema(title = "排序")
|
||||
@Schema(description = "排序")
|
||||
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
|
||||
@Schema(title = "创建时间")
|
||||
@NotNull(message = "打开方式不能为空", groups = DefaultGroup.class)
|
||||
@Min(value = 1, message = "打开方式参数越界", groups = DefaultGroup.class)
|
||||
@Max(value = 2, message = "打开方式参数越界", groups = DefaultGroup.class)
|
||||
@Schema(description = "打开方式 1内部菜单 2外部菜单")
|
||||
private Integer openWith;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
private Date createDate;
|
||||
|
||||
@Schema(title = "上级菜单名称")
|
||||
@Schema(description = "上级菜单名称")
|
||||
private String parentName;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ public class SysMenuEntity extends BaseEntity {
|
|||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 打开方式 1内部菜单 2外部菜单
|
||||
*/
|
||||
private Integer openWith;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public interface SysMenuService extends BaseService<SysMenuEntity> {
|
|||
*
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuDTO> getAllMenuList(Integer menuType);
|
||||
List<SysMenuDTO> getAllMenuList(Integer openWith, Integer menuType);
|
||||
|
||||
/**
|
||||
* 用户菜单列表
|
||||
|
|
@ -36,10 +36,11 @@ public interface SysMenuService extends BaseService<SysMenuEntity> {
|
|||
* @param user 用户
|
||||
* @param menuType 菜单类型
|
||||
*/
|
||||
List<SysMenuDTO> getUserMenuList(UserDetail user, Integer menuType);
|
||||
List<SysMenuDTO> getUserMenuList(UserDetail user, Integer openWith, Integer menuType);
|
||||
|
||||
/**
|
||||
* 根据父菜单,查询子菜单
|
||||
*
|
||||
* @param pid 父菜单ID
|
||||
*/
|
||||
List<SysMenuDTO> getListPid(Long pid);
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuDTO> getAllMenuList(Integer menuType) {
|
||||
List<SysMenuEntity> menuList = baseDao.getMenuList(menuType);
|
||||
public List<SysMenuDTO> getAllMenuList(Integer openWith, Integer menuType) {
|
||||
List<SysMenuEntity> menuList = baseDao.getMenuList(openWith, menuType);
|
||||
|
||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||
|
||||
|
|
@ -74,14 +74,14 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenuDTO> getUserMenuList(UserDetail user, Integer menuType) {
|
||||
public List<SysMenuDTO> getUserMenuList(UserDetail user, Integer openWith, Integer menuType) {
|
||||
List<SysMenuEntity> menuList;
|
||||
|
||||
//系统管理员,拥有最高权限
|
||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
||||
menuList = baseDao.getMenuList(menuType);
|
||||
menuList = baseDao.getMenuList(openWith, menuType);
|
||||
} else {
|
||||
menuList = baseDao.getUserMenuList(user.getId(), menuType);
|
||||
menuList = baseDao.getUserMenuList(user.getId(), openWith, menuType);
|
||||
}
|
||||
|
||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
<if test="menuType != null">
|
||||
t1.menu_type = #{menuType}
|
||||
</if>
|
||||
<if test="openWith != null">
|
||||
and t1.open_with = #{openWith}
|
||||
</if>
|
||||
</where>
|
||||
order by t1.sort asc
|
||||
</select>
|
||||
|
|
@ -26,6 +29,9 @@
|
|||
<if test="menuType != null">
|
||||
and t3.menu_type = #{menuType}
|
||||
</if>
|
||||
<if test="openWith != null">
|
||||
and t3.open_with = #{openWith}
|
||||
</if>
|
||||
order by t3.sort asc
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -2499,3 +2499,9 @@ COMMENT
|
|||
ON COLUMN public.bus_ai_warning.status IS '状态 0关闭 1开启';
|
||||
COMMENT
|
||||
ON COLUMN public.bus_ai_warning.warning_level IS '预警等级 高 中 低';
|
||||
|
||||
--2026/6/24
|
||||
ALTER TABLE public.sys_menu
|
||||
ADD open_with int2 NULL;
|
||||
COMMENT
|
||||
ON COLUMN public.sys_menu.open_with IS '打开方式 1内部菜单 2外部菜单';
|
||||
Loading…
Reference in New Issue