refactor: 重构系统路由设计

This commit is contained in:
2024-03-24 21:42:46 +08:00
parent c021feb48d
commit 8a41b96687
10 changed files with 272 additions and 267 deletions

View File

@@ -1,74 +0,0 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.continew.admin.auth.model.resp;
import java.io.Serial;
import java.io.Serializable;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* 元数据信息
*
* @author Charles7c
* @since 2023/2/26 22:51
*/
@Data
@Schema(description = "元数据信息")
public class MetaResp implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 菜单标题
*/
@Schema(description = "菜单标题", example = "用户管理")
private String locale;
/**
* 菜单图标
*/
@Schema(description = "菜单图标", example = "user")
private String icon;
/**
* 排序
*/
@Schema(description = "排序", example = "1")
private Integer order;
/**
* 是否隐藏
*/
@Schema(description = "是否隐藏", example = "false")
private Boolean hideInMenu;
/**
* 是否缓存
*/
@Schema(description = "是否缓存", example = "false")
private Boolean ignoreCache;
/**
* 是否需要登录才能访问
*/
@Schema(description = "是否需要登录才能访问", example = "false")
private Boolean requiresAuth = true;
}

View File

@@ -16,16 +16,14 @@
package top.charles7c.continew.admin.auth.model.resp;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonInclude;
/**
* 路由信息
*
@@ -40,6 +38,18 @@ public class RouteResp implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 标题
*/
@Schema(description = "标题", example = "用户管理")
private String title;
/**
* 类型
*/
@Schema(description = "类型", example = "2")
private Integer type;
/**
* 路由地址
*/
@@ -59,10 +69,46 @@ public class RouteResp implements Serializable {
private String component;
/**
* 元数据
* 重定向地址
*/
@Schema(description = "元数据")
private MetaResp meta;
@Schema(description = "重定向地址")
private String redirect;
/**
* 图标
*/
@Schema(description = "图标", example = "user")
private String icon;
/**
* 是否外链
*/
@Schema(description = "是否外链", example = "false")
private Boolean isExternal;
/**
* 是否缓存
*/
@Schema(description = "是否缓存", example = "false")
private Boolean isCache;
/**
* 是否隐藏
*/
@Schema(description = "是否隐藏", example = "false")
private Boolean isHidden;
/**
* 权限标识
*/
@Schema(description = "权限标识", example = "system:user:list")
private String permission;
/**
* 排序
*/
@Schema(description = "排序", example = "1")
private Integer sort;
/**
* 子路由列表

View File

@@ -29,7 +29,6 @@ import lombok.RequiredArgsConstructor;
import me.zhyd.oauth.model.AuthUser;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import top.charles7c.continew.admin.auth.model.resp.MetaResp;
import top.charles7c.continew.admin.auth.model.resp.RouteResp;
import top.charles7c.continew.admin.auth.service.LoginService;
import top.charles7c.continew.admin.auth.service.PermissionService;
@@ -166,16 +165,16 @@ public class LoginServiceImpl implements LoginService {
tree.setParentId(m.getParentId());
tree.setName(m.getTitle());
tree.setWeight(m.getSort());
tree.putExtra("type", m.getType().getValue());
tree.putExtra("path", m.getPath());
tree.putExtra("name", m.getName());
tree.putExtra("component", m.getComponent());
MetaResp metaResp = new MetaResp();
metaResp.setLocale(m.getTitle());
metaResp.setIcon(m.getIcon());
metaResp.setIgnoreCache(Boolean.FALSE.equals(m.getIsCache()));
metaResp.setHideInMenu(m.getIsHidden());
metaResp.setOrder(m.getSort());
tree.putExtra("meta", metaResp);
tree.putExtra("redirect", m.getRedirect());
tree.putExtra("icon", m.getIcon());
tree.putExtra("isExternal", m.getIsExternal());
tree.putExtra("isCache", m.getIsCache());
tree.putExtra("isHidden", m.getIsHidden());
tree.putExtra("permission", m.getPermission());
});
return BeanUtil.copyToList(treeList, RouteResp.class);
}

View File

@@ -16,16 +16,14 @@
package top.charles7c.continew.admin.system.model.entity;
import java.io.Serial;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
import top.charles7c.continew.admin.common.enums.MenuTypeEnum;
import top.charles7c.continew.starter.extension.crud.model.entity.BaseDO;
import java.io.Serial;
/**
* 菜单实体
*
@@ -69,6 +67,11 @@ public class MenuDO extends BaseDO {
*/
private String component;
/**
* 重定向地址
*/
private String redirect;
/**
* 图标
*/

View File

@@ -16,21 +16,18 @@
package top.charles7c.continew.admin.system.model.resp;
import java.io.Serial;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
import top.charles7c.continew.admin.common.enums.MenuTypeEnum;
import top.charles7c.continew.starter.extension.crud.annotation.TreeField;
import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter;
import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp;
import java.io.Serial;
/**
* 菜单信息
*
@@ -54,25 +51,31 @@ public class MenuResp extends BaseResp {
private String title;
/**
* 图标
* 上级菜单 ID
*/
@Schema(description = "图标", example = "user")
@ExcelProperty(value = "图标")
private String icon;
@Schema(description = "上级菜单 ID", example = "1000")
private Long parentId;
/**
* 排序
* 类型
*/
@Schema(description = "排序", example = "1")
@ExcelProperty(value = "排序")
private Integer sort;
@Schema(description = "类型1目录2菜单3按钮", type = "Integer", allowableValues = {"1", "2", "3"}, example = "2")
@ExcelProperty(value = "类型", converter = ExcelBaseEnumConverter.class)
private MenuTypeEnum type;
/**
* 权限标识
* 路由地址
*/
@Schema(description = "权限标识", example = "system:user:list")
@ExcelProperty(value = "权限标识")
private String permission;
@Schema(description = "路由地址", example = "/system/user")
@ExcelProperty(value = "路由地址")
private String path;
/**
* 组件名称
*/
@Schema(description = "组件名称", example = "User")
@ExcelProperty(value = "组件名称")
private String name;
/**
* 组件路径
@@ -82,11 +85,18 @@ public class MenuResp extends BaseResp {
private String component;
/**
* 状态
* 重定向地址
*/
@Schema(description = "状态1启用2禁用", type = "Integer", allowableValues = {"1", "2"}, example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
private DisEnableStatusEnum status;
@Schema(description = "重定向地址")
@ExcelProperty(value = "重定向地址")
private String redirect;
/**
* 图标
*/
@Schema(description = "图标", example = "user")
@ExcelProperty(value = "图标")
private String icon;
/**
* 是否外链
@@ -110,29 +120,23 @@ public class MenuResp extends BaseResp {
private Boolean isHidden;
/**
* 路由地址
* 权限标识
*/
@Schema(description = "路由地址", example = "/system/user")
@ExcelProperty(value = "路由地址")
private String path;
@Schema(description = "权限标识", example = "system:user:list")
@ExcelProperty(value = "权限标识")
private String permission;
/**
* 组件名称
* 排序
*/
@Schema(description = "组件名称", example = "User")
@ExcelProperty(value = "组件名称")
private String name;
@Schema(description = "排序", example = "1")
@ExcelProperty(value = "排序")
private Integer sort;
/**
* 类型
* 状态
*/
@Schema(description = "类型1目录2菜单3按钮", type = "Integer", allowableValues = {"1", "2", "3"}, example = "2")
@ExcelProperty(value = "类型", converter = ExcelBaseEnumConverter.class)
private MenuTypeEnum type;
/**
* 上级菜单 ID
*/
@Schema(description = "上级菜单 ID", example = "1000")
private Long parentId;
@Schema(description = "状态1启用2禁用", type = "Integer", allowableValues = {"1", "2"}, example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
private DisEnableStatusEnum status;
}