Merge remote-tracking branch 'base-version/test' into dev
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.zt.plat.module.system.enums.permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 数据规则条件枚举
|
||||
*
|
||||
* 用于菜单数据规则的条件类型
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DataRuleConditionEnum {
|
||||
|
||||
EQ("=", "等于"),
|
||||
NE("!=", "不等于"),
|
||||
GT(">", "大于"),
|
||||
GE(">=", "大于等于"),
|
||||
LT("<", "小于"),
|
||||
LE("<=", "小于等于"),
|
||||
IN("IN", "包含"),
|
||||
NOT_IN("NOT_IN", "不包含"),
|
||||
LIKE("LIKE", "模糊匹配"),
|
||||
LEFT_LIKE("LEFT_LIKE", "左模糊"),
|
||||
RIGHT_LIKE("RIGHT_LIKE", "右模糊"),
|
||||
NOT_LIKE("NOT_LIKE", "不匹配"),
|
||||
IS_NULL("IS_NULL", "为空"),
|
||||
IS_NOT_NULL("IS_NOT_NULL", "不为空"),
|
||||
SQL_RULE("SQL_RULE", "自定义SQL");
|
||||
|
||||
/**
|
||||
* 条件符号
|
||||
*/
|
||||
private final String condition;
|
||||
|
||||
/**
|
||||
* 条件描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* 根据条件符号查找枚举
|
||||
*
|
||||
* @param condition 条件符号
|
||||
* @return 枚举值
|
||||
*/
|
||||
public static DataRuleConditionEnum findByCondition(String condition) {
|
||||
if (condition == null) {
|
||||
return null;
|
||||
}
|
||||
for (DataRuleConditionEnum value : values()) {
|
||||
if (value.condition.equals(condition)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zt.plat.module.system.enums.permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 数据规则变量枚举
|
||||
*
|
||||
* 用于菜单数据规则的变量替换
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DataRuleVariableEnum {
|
||||
|
||||
USER_ID("#{userId}", "当前用户ID"),
|
||||
USERNAME("#{username}", "当前用户名"),
|
||||
DEPT_ID("#{deptId}", "当前用户部门ID"),
|
||||
DEPT_IDS("#{deptIds}", "当前用户所有部门ID"),
|
||||
ORG_CODE("#{orgCode}", "当前用户组织编码"),
|
||||
TENANT_ID("#{tenantId}", "当前租户ID"),
|
||||
CURRENT_DATE("#{currentDate}", "当前日期"),
|
||||
CURRENT_TIME("#{currentTime}", "当前时间");
|
||||
|
||||
/**
|
||||
* 变量名
|
||||
*/
|
||||
private final String variable;
|
||||
|
||||
/**
|
||||
* 变量描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* 根据变量名查找枚举
|
||||
*
|
||||
* @param variable 变量名
|
||||
* @return 枚举值
|
||||
*/
|
||||
public static DataRuleVariableEnum findByVariable(String variable) {
|
||||
if (variable == null) {
|
||||
return null;
|
||||
}
|
||||
for (DataRuleVariableEnum value : values()) {
|
||||
if (value.variable.equals(variable)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.zt.plat.module.system.enums.social.SocialTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -22,8 +21,8 @@ public class AuthLoginReqVO extends CaptchaVerificationReqVO {
|
||||
|
||||
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "ztyuanma")
|
||||
@NotEmpty(message = "登录账号不能为空")
|
||||
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
@Length(min = 1, max = 16, message = "账号长度为 1-16 位")
|
||||
// @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.zt.plat.module.system.controller.admin.auth.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -19,7 +18,7 @@ public class AuthTestLoginReqVO {
|
||||
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "ztyuanma")
|
||||
@NotEmpty(message = "登录账号不能为空")
|
||||
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
// @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.zt.plat.module.system.controller.admin.permission;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.system.controller.admin.permission.vo.menudatarule.MenuDataRuleRespVO;
|
||||
import com.zt.plat.module.system.controller.admin.permission.vo.menudatarule.MenuDataRuleSaveReqVO;
|
||||
import com.zt.plat.module.system.convert.permission.MenuDataRuleConvert;
|
||||
import com.zt.plat.module.system.dal.dataobject.permission.MenuDataRuleDO;
|
||||
import com.zt.plat.module.system.service.permission.MenuDataRuleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 菜单数据规则 Controller
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Tag(name = "管理后台 - 菜单数据规则")
|
||||
@RestController
|
||||
@RequestMapping("/system/menu-data-rule")
|
||||
@Validated
|
||||
public class MenuDataRuleController {
|
||||
|
||||
@Resource
|
||||
private MenuDataRuleService menuDataRuleService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建菜单数据规则")
|
||||
@PreAuthorize("@ss.hasPermission('system:menu:update')")
|
||||
public CommonResult<Long> createMenuDataRule(@Valid @RequestBody MenuDataRuleSaveReqVO createReqVO) {
|
||||
return success(menuDataRuleService.createMenuDataRule(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新菜单数据规则")
|
||||
@PreAuthorize("@ss.hasPermission('system:menu:update')")
|
||||
public CommonResult<Boolean> updateMenuDataRule(@Valid @RequestBody MenuDataRuleSaveReqVO updateReqVO) {
|
||||
menuDataRuleService.updateMenuDataRule(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除菜单数据规则")
|
||||
@Parameter(name = "id", description = "规则ID", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:menu:update')")
|
||||
public CommonResult<Boolean> deleteMenuDataRule(@RequestParam("id") Long id) {
|
||||
menuDataRuleService.deleteMenuDataRule(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得菜单数据规则")
|
||||
@Parameter(name = "id", description = "规则ID", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:menu:query')")
|
||||
public CommonResult<MenuDataRuleRespVO> getMenuDataRule(@RequestParam("id") Long id) {
|
||||
MenuDataRuleDO rule = menuDataRuleService.getMenuDataRule(id);
|
||||
return success(MenuDataRuleConvert.INSTANCE.convert(rule));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得菜单的所有数据规则")
|
||||
@Parameter(name = "menuId", description = "菜单ID", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('system:menu:query')")
|
||||
public CommonResult<List<MenuDataRuleRespVO>> getMenuDataRuleList(@RequestParam("menuId") Long menuId) {
|
||||
List<MenuDataRuleDO> list = menuDataRuleService.getMenuDataRuleListByMenuId(menuId);
|
||||
return success(MenuDataRuleConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,9 @@ public class PermissionController {
|
||||
PermissionAssignRoleMenuItemReqVO reqVO = new PermissionAssignRoleMenuItemReqVO();
|
||||
reqVO.setId(menu.getMenuId());
|
||||
reqVO.setShowMenu(menu.getShowMenu());
|
||||
// 获取该角色在该菜单下的数据规则ID列表
|
||||
Set<Long> dataRuleIds = permissionService.getRoleMenuDataRules(roleId, menu.getMenuId());
|
||||
reqVO.setDataRuleIds(dataRuleIds != null ? new ArrayList<>(dataRuleIds) : null);
|
||||
return reqVO;
|
||||
}).collect(Collectors.toSet());
|
||||
return success(result);
|
||||
@@ -83,6 +86,10 @@ public class PermissionController {
|
||||
|
||||
// 更新菜单的显示状态
|
||||
permissionService.updateMenuDisplay(reqVO.getRoleId(), reqVO.getMenus());
|
||||
|
||||
// 保存菜单数据规则关联
|
||||
permissionService.assignRoleMenuDataRules(reqVO.getRoleId(), reqVO.getMenus());
|
||||
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.zt.plat.module.system.controller.admin.permission.vo.role.RolePageReq
|
||||
import com.zt.plat.module.system.controller.admin.permission.vo.role.RoleRespVO;
|
||||
import com.zt.plat.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
|
||||
import com.zt.plat.module.system.dal.dataobject.permission.RoleDO;
|
||||
import com.zt.plat.framework.datapermission.core.menudatapermission.annotation.PermissionData;
|
||||
import com.zt.plat.module.system.service.permission.RoleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -78,6 +79,7 @@ public class RoleController {
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得角色分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:role:query')")
|
||||
@PermissionData(pageComponent = "system/role/index")
|
||||
public CommonResult<PageResult<RoleRespVO>> getRolePage(RolePageReqVO pageReqVO) {
|
||||
PageResult<RoleDO> pageResult = roleService.getRolePage(pageReqVO);
|
||||
// 获取所有父级角色信息
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.zt.plat.module.system.controller.admin.permission.vo.menudatarule;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 菜单数据规则 Response VO
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Schema(description = "管理后台 - 菜单数据规则 Response VO")
|
||||
@Data
|
||||
public class MenuDataRuleRespVO {
|
||||
|
||||
@Schema(description = "规则ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "菜单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long menuId;
|
||||
|
||||
@Schema(description = "规则名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "仅看本部门数据")
|
||||
private String ruleName;
|
||||
|
||||
@Schema(description = "规则字段", example = "dept_id")
|
||||
private String ruleColumn;
|
||||
|
||||
@Schema(description = "规则条件", requiredMode = Schema.RequiredMode.REQUIRED, example = "=")
|
||||
private String ruleConditions;
|
||||
|
||||
@Schema(description = "规则值", requiredMode = Schema.RequiredMode.REQUIRED, example = "#{deptId}")
|
||||
private String ruleValue;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序", example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注", example = "限制只能查看本部门数据")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zt.plat.module.system.controller.admin.permission.vo.menudatarule;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 菜单数据规则创建/修改 Request VO
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Schema(description = "管理后台 - 菜单数据规则创建/修改 Request VO")
|
||||
@Data
|
||||
public class MenuDataRuleSaveReqVO {
|
||||
|
||||
@Schema(description = "规则ID", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "菜单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "菜单ID不能为空")
|
||||
private Long menuId;
|
||||
|
||||
@Schema(description = "规则名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "仅看本部门数据")
|
||||
@NotBlank(message = "规则名称不能为空")
|
||||
@Size(max = 100, message = "规则名称长度不能超过 100 个字符")
|
||||
private String ruleName;
|
||||
|
||||
@Schema(description = "规则字段", example = "dept_id")
|
||||
@Size(max = 100, message = "规则字段长度不能超过 100 个字符")
|
||||
private String ruleColumn;
|
||||
|
||||
@Schema(description = "规则条件", requiredMode = Schema.RequiredMode.REQUIRED, example = "=")
|
||||
@NotBlank(message = "规则条件不能为空")
|
||||
@Size(max = 20, message = "规则条件长度不能超过 20 个字符")
|
||||
private String ruleConditions;
|
||||
|
||||
@Schema(description = "规则值", requiredMode = Schema.RequiredMode.REQUIRED, example = "#{deptId}")
|
||||
@NotBlank(message = "规则值不能为空")
|
||||
@Size(max = 500, message = "规则值长度不能超过 500 个字符")
|
||||
private String ruleValue;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序", example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注", example = "限制只能查看本部门数据")
|
||||
@Size(max = 500, message = "备注长度不能超过 500 个字符")
|
||||
private String remark;
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 赋予角色菜单--菜单列表 Request VO")
|
||||
@Data
|
||||
@@ -19,4 +21,7 @@ public class PermissionAssignRoleMenuItemReqVO {
|
||||
@Schema(description = "是否显示菜单按钮是否点击过(避免大量更新数据,只更新点击过的)")
|
||||
private Boolean showMenuChanged = false;
|
||||
|
||||
@Schema(description = "菜单数据规则ID列表", example = "[1, 2, 3]")
|
||||
private List<Long> dataRuleIds;
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user