菜单增加前端菜单配置
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 com.multictrl.modules.sys.service.SysMenuService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
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.enums.ParameterIn;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
@ -37,10 +38,11 @@ public class SysMenuController {
|
||||||
private final ShiroService shiroService;
|
private final ShiroService shiroService;
|
||||||
|
|
||||||
@GetMapping("nav")
|
@GetMapping("nav")
|
||||||
|
@Parameter(name = "openWith", description = "打开方式 1内部打开 2外部打开")
|
||||||
@Operation(summary = "导航")
|
@Operation(summary = "导航")
|
||||||
public Result<List<SysMenuDTO>> nav() {
|
public Result<List<SysMenuDTO>> nav(Integer openWith) {
|
||||||
UserDetail user = SecurityUser.getUser();
|
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);
|
return new Result<List<SysMenuDTO>>().ok(list);
|
||||||
}
|
}
|
||||||
|
|
@ -56,10 +58,13 @@ public class SysMenuController {
|
||||||
|
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@Operation(summary = "列表")
|
@Operation(summary = "列表")
|
||||||
@Parameter(name = "type", description = "菜单类型 0:菜单 1:按钮 null:全部")
|
@Parameters({
|
||||||
|
@Parameter(name = "openWith", description = "打开方式 1内部打开 2外部打开"),
|
||||||
|
@Parameter(name = "type", description = "菜单类型 0:菜单 1:按钮 null:全部")
|
||||||
|
})
|
||||||
@RequiresPermissions("sys:menu:list")
|
@RequiresPermissions("sys:menu:list")
|
||||||
public Result<List<SysMenuDTO>> list(Integer type) {
|
public Result<List<SysMenuDTO>> list(Integer openWith, Integer type) {
|
||||||
List<SysMenuDTO> list = sysMenuService.getAllMenuList(type);
|
List<SysMenuDTO> list = sysMenuService.getAllMenuList(openWith, type);
|
||||||
|
|
||||||
return new Result<List<SysMenuDTO>>().ok(list);
|
return new Result<List<SysMenuDTO>>().ok(list);
|
||||||
}
|
}
|
||||||
|
|
@ -119,11 +124,12 @@ public class SysMenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("select")
|
@GetMapping("select")
|
||||||
|
@Parameter(name = "openWith", description = "打开方式 1内部打开 2外部打开")
|
||||||
@Operation(summary = "角色菜单权限")
|
@Operation(summary = "角色菜单权限")
|
||||||
@RequiresPermissions("sys:menu:select")
|
@RequiresPermissions("sys:menu:select")
|
||||||
public Result<List<SysMenuDTO>> select() {
|
public Result<List<SysMenuDTO>> select(Integer openWith) {
|
||||||
UserDetail user = SecurityUser.getUser();
|
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);
|
return new Result<List<SysMenuDTO>>().ok(list);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,44 +9,46 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单管理
|
* 菜单管理
|
||||||
*
|
*
|
||||||
* @author Sdy
|
* @author Sdy
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
public interface SysMenuDao extends BaseDao<SysMenuEntity> {
|
||||||
|
|
||||||
SysMenuEntity getById(@Param("id") Long id);
|
SysMenuEntity getById(@Param("id") Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有菜单列表
|
* 查询所有菜单列表
|
||||||
*
|
*
|
||||||
* @param menuType 菜单类型
|
* @param menuType 菜单类型
|
||||||
*/
|
*/
|
||||||
List<SysMenuEntity> getMenuList(@Param("menuType") Integer menuType);
|
List<SysMenuEntity> getMenuList(@Param("openWith") Integer openWith, @Param("menuType") Integer menuType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户菜单列表
|
* 查询用户菜单列表
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param menuType 菜单类型
|
* @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
|
*
|
||||||
*/
|
* @param userId 用户ID
|
||||||
List<String> getUserPermissionsList(Long userId);
|
*/
|
||||||
|
List<String> getUserPermissionsList(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有权限列表
|
* 查询所有权限列表
|
||||||
*/
|
*/
|
||||||
List<String> getPermissionsList();
|
List<String> getPermissionsList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据父菜单,查询子菜单
|
* 根据父菜单,查询子菜单
|
||||||
* @param pid 父菜单ID
|
*
|
||||||
*/
|
* @param pid 父菜单ID
|
||||||
List<SysMenuEntity> getListPid(Long pid);
|
*/
|
||||||
|
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.DefaultGroup;
|
||||||
import com.multictrl.common.validator.group.UpdateGroup;
|
import com.multictrl.common.validator.group.UpdateGroup;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.*;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import jakarta.validation.constraints.Null;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.hibernate.validator.constraints.Range;
|
import org.hibernate.validator.constraints.Range;
|
||||||
|
|
@ -26,66 +23,72 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Schema(title = "菜单管理")
|
@Schema(name = "菜单管理")
|
||||||
public class SysMenuDTO extends TreeNode<SysMenuDTO> implements Serializable {
|
public class SysMenuDTO extends TreeNode<SysMenuDTO> implements Serializable {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(title = "id")
|
@Schema(description = "id")
|
||||||
@Null(message="{id.null}", groups = AddGroup.class)
|
@Null(message = "{id.null}", groups = AddGroup.class)
|
||||||
@NotNull(message="{id.require}", groups = UpdateGroup.class)
|
@NotNull(message = "{id.require}", groups = UpdateGroup.class)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(title = "上级ID")
|
@Schema(description = "上级ID")
|
||||||
@NotNull(message="{sysmenu.pid.require}", groups = DefaultGroup.class)
|
@NotNull(message = "{sysmenu.pid.require}", groups = DefaultGroup.class)
|
||||||
private Long pid;
|
private Long pid;
|
||||||
|
|
||||||
@Schema(title = "菜单名称")
|
@Schema(description = "菜单名称")
|
||||||
@NotBlank(message="sysmenu.name.require", groups = DefaultGroup.class)
|
@NotBlank(message = "sysmenu.name.require", groups = DefaultGroup.class)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(title = "菜单URL")
|
@Schema(description = "菜单URL")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Schema(title = "类型 0:菜单 1:按钮")
|
@Schema(description = "类型 0:菜单 1:按钮")
|
||||||
@Range(min=0, max=1, message = "{sysmenu.type.range}", groups = DefaultGroup.class)
|
@Range(min = 0, max = 1, message = "{sysmenu.type.range}", groups = DefaultGroup.class)
|
||||||
private Integer menuType;
|
private Integer menuType;
|
||||||
|
|
||||||
@Schema(title = "菜单图标")
|
@Schema(description = "菜单图标")
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
@Schema(title = "授权(多个用逗号分隔,如:sys:user:list,sys:user:save)")
|
@Schema(description = "授权(多个用逗号分隔,如:sys:user:list,sys:user:save)")
|
||||||
private String permissions;
|
private String permissions;
|
||||||
|
|
||||||
@Schema(title = "排序")
|
@Schema(description = "排序")
|
||||||
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
@Schema(title = "创建时间")
|
@NotNull(message = "打开方式不能为空", groups = DefaultGroup.class)
|
||||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
@Min(value = 1, message = "打开方式参数越界", groups = DefaultGroup.class)
|
||||||
private Date createDate;
|
@Max(value = 2, message = "打开方式参数越界", groups = DefaultGroup.class)
|
||||||
|
@Schema(description = "打开方式 1内部菜单 2外部菜单")
|
||||||
|
private Integer openWith;
|
||||||
|
|
||||||
@Schema(title = "上级菜单名称")
|
@Schema(description = "创建时间")
|
||||||
private String parentName;
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
@Override
|
@Schema(description = "上级菜单名称")
|
||||||
public Long getId() {
|
private String parentName;
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setId(Long id) {
|
public Long getId() {
|
||||||
this.id = id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getPid() {
|
public void setId(Long id) {
|
||||||
return pid;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPid(Long pid) {
|
public Long getPid() {
|
||||||
this.pid = pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPid(Long pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,54 +16,58 @@ import java.util.Date;
|
||||||
* @author Sdy
|
* @author Sdy
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper=false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("sys_menu")
|
@TableName("sys_menu")
|
||||||
public class SysMenuEntity extends BaseEntity {
|
public class SysMenuEntity extends BaseEntity {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父菜单ID,一级菜单为0
|
* 父菜单ID,一级菜单为0
|
||||||
*/
|
*/
|
||||||
private Long pid;
|
private Long pid;
|
||||||
/**
|
/**
|
||||||
* 菜单名称
|
* 菜单名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
/**
|
/**
|
||||||
* 菜单URL
|
* 菜单URL
|
||||||
*/
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
/**
|
/**
|
||||||
* 授权(多个用逗号分隔,如:sys:user:list,sys:user:save)
|
* 授权(多个用逗号分隔,如:sys:user:list,sys:user:save)
|
||||||
*/
|
*/
|
||||||
private String permissions;
|
private String permissions;
|
||||||
/**
|
/**
|
||||||
* 类型 0:菜单 1:按钮
|
* 类型 0:菜单 1:按钮
|
||||||
*/
|
*/
|
||||||
private Integer menuType;
|
private Integer menuType;
|
||||||
/**
|
/**
|
||||||
* 菜单图标
|
* 菜单图标
|
||||||
*/
|
*/
|
||||||
private String icon;
|
private String icon;
|
||||||
/**
|
/**
|
||||||
* 排序
|
* 排序
|
||||||
*/
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
/**
|
/**
|
||||||
* 更新者
|
* 打开方式 1内部菜单 2外部菜单
|
||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
private Integer openWith;
|
||||||
private Long updater;
|
/**
|
||||||
/**
|
* 更新者
|
||||||
* 更新时间
|
*/
|
||||||
*/
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
private Long updater;
|
||||||
private Date updateDate;
|
/**
|
||||||
/**
|
* 更新时间
|
||||||
* 上级菜单名称
|
*/
|
||||||
*/
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
@TableField(exist = false)
|
private Date updateDate;
|
||||||
private String parentName;
|
/**
|
||||||
|
* 上级菜单名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String parentName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,37 +10,38 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单管理
|
* 菜单管理
|
||||||
*
|
*
|
||||||
* @author Sdy
|
* @author Sdy
|
||||||
*/
|
*/
|
||||||
public interface SysMenuService extends BaseService<SysMenuEntity> {
|
public interface SysMenuService extends BaseService<SysMenuEntity> {
|
||||||
|
|
||||||
SysMenuDTO get(Long id);
|
SysMenuDTO get(Long id);
|
||||||
|
|
||||||
void save(SysMenuDTO dto);
|
void save(SysMenuDTO dto);
|
||||||
|
|
||||||
void update(SysMenuDTO dto);
|
void update(SysMenuDTO dto);
|
||||||
|
|
||||||
void delete(Long id);
|
void delete(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单列表
|
* 菜单列表
|
||||||
*
|
*
|
||||||
* @param menuType 菜单类型
|
* @param menuType 菜单类型
|
||||||
*/
|
*/
|
||||||
List<SysMenuDTO> getAllMenuList(Integer menuType);
|
List<SysMenuDTO> getAllMenuList(Integer openWith, Integer menuType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户菜单列表
|
* 用户菜单列表
|
||||||
*
|
*
|
||||||
* @param user 用户
|
* @param user 用户
|
||||||
* @param menuType 菜单类型
|
* @param menuType 菜单类型
|
||||||
*/
|
*/
|
||||||
List<SysMenuDTO> getUserMenuList(UserDetail user, Integer menuType);
|
List<SysMenuDTO> getUserMenuList(UserDetail user, Integer openWith, Integer menuType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据父菜单,查询子菜单
|
* 根据父菜单,查询子菜单
|
||||||
* @param pid 父菜单ID
|
*
|
||||||
*/
|
* @param pid 父菜单ID
|
||||||
List<SysMenuDTO> getListPid(Long pid);
|
*/
|
||||||
|
List<SysMenuDTO> getListPid(Long pid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDTO> getAllMenuList(Integer menuType) {
|
public List<SysMenuDTO> getAllMenuList(Integer openWith, Integer menuType) {
|
||||||
List<SysMenuEntity> menuList = baseDao.getMenuList(menuType);
|
List<SysMenuEntity> menuList = baseDao.getMenuList(openWith, menuType);
|
||||||
|
|
||||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||||
|
|
||||||
|
|
@ -74,14 +74,14 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuDao, SysMenuEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysMenuDTO> getUserMenuList(UserDetail user, Integer menuType) {
|
public List<SysMenuDTO> getUserMenuList(UserDetail user, Integer openWith, Integer menuType) {
|
||||||
List<SysMenuEntity> menuList;
|
List<SysMenuEntity> menuList;
|
||||||
|
|
||||||
//系统管理员,拥有最高权限
|
//系统管理员,拥有最高权限
|
||||||
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
if (user.getSuperAdmin() == SuperAdminEnum.YES.value()) {
|
||||||
menuList = baseDao.getMenuList(menuType);
|
menuList = baseDao.getMenuList(openWith, menuType);
|
||||||
} else {
|
} else {
|
||||||
menuList = baseDao.getUserMenuList(user.getId(), menuType);
|
menuList = baseDao.getUserMenuList(user.getId(), openWith, menuType);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
List<SysMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, SysMenuDTO.class);
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,17 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getMenuList" resultType="com.multictrl.modules.sys.entity.SysMenuEntity">
|
<select id="getMenuList" resultType="com.multictrl.modules.sys.entity.SysMenuEntity">
|
||||||
select t1.* from sys_menu t1
|
select t1.* from sys_menu t1
|
||||||
<where>
|
<where>
|
||||||
<if test="menuType != null">
|
<if test="menuType != null">
|
||||||
t1.menu_type = #{menuType}
|
t1.menu_type = #{menuType}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
<if test="openWith != null">
|
||||||
order by t1.sort asc
|
and t1.open_with = #{openWith}
|
||||||
</select>
|
</if>
|
||||||
|
</where>
|
||||||
|
order by t1.sort asc
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getUserMenuList" resultType="com.multictrl.modules.sys.entity.SysMenuEntity">
|
<select id="getUserMenuList" resultType="com.multictrl.modules.sys.entity.SysMenuEntity">
|
||||||
select t3.* from sys_role_user t1
|
select t3.* from sys_role_user t1
|
||||||
|
|
@ -26,6 +29,9 @@
|
||||||
<if test="menuType != null">
|
<if test="menuType != null">
|
||||||
and t3.menu_type = #{menuType}
|
and t3.menu_type = #{menuType}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="openWith != null">
|
||||||
|
and t3.open_with = #{openWith}
|
||||||
|
</if>
|
||||||
order by t3.sort asc
|
order by t3.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2498,4 +2498,10 @@ ON COLUMN public.bus_ai_warning.rule_name IS '规则名称';
|
||||||
COMMENT
|
COMMENT
|
||||||
ON COLUMN public.bus_ai_warning.status IS '状态 0关闭 1开启';
|
ON COLUMN public.bus_ai_warning.status IS '状态 0关闭 1开启';
|
||||||
COMMENT
|
COMMENT
|
||||||
ON COLUMN public.bus_ai_warning.warning_level IS '预警等级 高 中 低';
|
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