添加字段
This commit is contained in:
@@ -5,20 +5,19 @@ import com.cczsa.xinghe.codegen.entity.enums.MenuTypeEnum;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 菜单 实体类。
|
||||
*
|
||||
* @author My
|
||||
* @author xiayb
|
||||
* @since 0.0.1
|
||||
*/
|
||||
@Data
|
||||
@@ -68,6 +67,11 @@ public class MenuEntity extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
*/
|
||||
private String pagePath;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
|
||||
@@ -29,4 +29,7 @@ public class FunItemQueryReq implements Serializable {
|
||||
@Schema(description = "功能编码")
|
||||
private String itemCode;
|
||||
|
||||
@Schema(description = "是否租户")
|
||||
private Boolean isTenant;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.cczsa.xinghe.codegen.entity.enums.ClientTypeEnum;
|
||||
import com.cczsa.xinghe.codegen.entity.enums.MenuTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -35,6 +36,10 @@ public class MenuAddReq implements Serializable {
|
||||
@Schema(description = "父菜单ID")
|
||||
private Long parentId = 0L;
|
||||
|
||||
@Pattern(
|
||||
regexp = "^(?:$|/(?:[a-zA-Z0-9_=?#&-]+/)*[a-zA-Z0-9_=?#&-]+)$",
|
||||
message = "路由路径格式不正确:必须以'/'开头,不能以'/'结尾,且只能包含字母、数字、下划线、横杠、等号、问号、井号、与号,以及分隔斜杠(不能连续)"
|
||||
)
|
||||
@Schema(description = "路由路径")
|
||||
private String path;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.cczsa.xinghe.codegen.entity.MenuEntity;
|
||||
/**
|
||||
* 菜单 映射层。
|
||||
*
|
||||
* @author My
|
||||
* @author xiayb
|
||||
* @since 0.0.1
|
||||
*/
|
||||
@Mapper
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.Serial;
|
||||
/**
|
||||
* 菜单 表定义层。
|
||||
*
|
||||
* @author My
|
||||
* @author xiayb
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public class MenuDef extends TableDef {
|
||||
@@ -61,6 +61,11 @@ public class MenuDef extends TableDef {
|
||||
*/
|
||||
public final QueryColumn MENU_TYPE = new QueryColumn(this, "menu_type");
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
*/
|
||||
public final QueryColumn PAGE_PATH = new QueryColumn(this, "page_path");
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
@@ -84,7 +89,7 @@ public class MenuDef extends TableDef {
|
||||
/**
|
||||
* 默认字段,不包含逻辑删除或者 large 等字段。
|
||||
*/
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, CLIENT_TYPE, MENU_NAME, PARENT_ID, FUN_ID, MENU_TYPE, PATH, ICON, IS_TENANT, IS_HIDE, SORT_ORDER};
|
||||
public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, CLIENT_TYPE, MENU_NAME, PARENT_ID, FUN_ID, MENU_TYPE, PATH, PAGE_PATH, ICON, IS_TENANT, IS_HIDE, SORT_ORDER};
|
||||
|
||||
public MenuDef() {
|
||||
super("", "cg_menu");
|
||||
|
||||
@@ -51,6 +51,7 @@ public class FunItemServiceImpl implements FunItemService {
|
||||
.from(funItemDef)
|
||||
.join(funModuleDef).on(funItemDef.MODULE_ID.eq(funModuleDef.ID))
|
||||
.eq(FunItemEntity::getModuleId, req.getModuleId(), ObjectUtil.areNotNull(req.getModuleId()))
|
||||
.eq(FunItemEntity::getIsTenant, req.getIsTenant(), ObjectUtil.areNotNull(req.getIsTenant()))
|
||||
.like(FunItemEntity::getItemName, req.getItemName(), StrUtil.isNotBlank(req.getItemName()))
|
||||
.like(FunItemEntity::getItemCode, req.getItemCode(), StrUtil.isNotBlank(req.getItemCode()))
|
||||
.orderBy(FunItemEntity::getSortOrder, false);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.cczsa.xinghe.codegen.entity.FunOperationEntity;
|
||||
import com.cczsa.xinghe.codegen.entity.MenuEntity;
|
||||
import com.cczsa.xinghe.codegen.entity.RoleEntity;
|
||||
import com.cczsa.xinghe.codegen.entity.RoleFunEntity;
|
||||
import com.cczsa.xinghe.codegen.entity.enums.RoleTypeEnum;
|
||||
import com.cczsa.xinghe.codegen.entity.enums.UsableConfigEnum;
|
||||
import com.cczsa.xinghe.codegen.entity.req.role.RoleAddReq;
|
||||
import com.cczsa.xinghe.codegen.entity.req.role.RoleBindFunReq;
|
||||
@@ -212,6 +213,14 @@ public class RoleServiceImpl implements RoleService {
|
||||
*/
|
||||
@Override
|
||||
public XResult<List<RoleQueryFunRes>> queryRoleFun(RoleQueryFunReq req) {
|
||||
// 获取角色
|
||||
RoleEntity roleEntity = roleMapper.selectOneById(req.getRoleId());
|
||||
if (roleEntity == null) {
|
||||
return XResult.failed("角色不存在");
|
||||
}
|
||||
RoleTypeEnum roleType = roleEntity.getRoleType();
|
||||
boolean isTenant = roleType == RoleTypeEnum.PACKAGE;
|
||||
|
||||
// 获取菜单
|
||||
MenuDef menuDef = MenuDef.MENU_ENTITY;
|
||||
FunOperationDef funOperationDef = FunOperationDef.FUN_OPERATION_ENTITY;
|
||||
@@ -228,6 +237,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
.from(menuDef)
|
||||
.leftJoin(funOperationDef).on(menuDef.FUN_ID.eq(funOperationDef.ID))
|
||||
.eq(MenuEntity::getClientType, req.getClientType())
|
||||
.eq(MenuEntity::getIsTenant, isTenant)
|
||||
.orderBy(MenuEntity::getSortOrder, false);
|
||||
List<RoleQueryFunRes> roleQueryFunList = menuMapper.selectListByQueryAs(queryMenu, RoleQueryFunRes.class);
|
||||
// 获取角色功能权限
|
||||
@@ -239,6 +249,10 @@ public class RoleServiceImpl implements RoleService {
|
||||
.eq(RoleFunEntity::getRoleId, req.getRoleId());
|
||||
List<RoleFunEntity> roleFunEntities = roleFunMapper.selectListByQuery(queryRoleFun);
|
||||
for (RoleQueryFunRes roleQueryFunRes : roleQueryFunList) {
|
||||
if(isTenant){
|
||||
roleQueryFunRes.setUsableConfig(new ArrayList<>());
|
||||
roleQueryFunRes.setFieldConfig(new ArrayList<>());
|
||||
}
|
||||
// 获取菜单功能
|
||||
RoleFunEntity roleFunEntity = roleFunEntities.stream()
|
||||
.filter(entity -> entity.getFunId().equals(roleQueryFunRes.getFunId()))
|
||||
|
||||
Reference in New Issue
Block a user