Browse Source
- 新增权限数据规则方案实体类 PermissionDataRuleSchema - 创建权限数据规则方案服务接口和实现类 - 添加权限数据规则方案控制器提供增删改查接口 - 实现分页查询、按formId查询启用规则等功能 - 添加数据校验和业务逻辑验证机制 - 集成按钮权限校验功能 - 优化在线表单相关模型和控制器代码结构feature/form-permission-control
12 changed files with 598 additions and 34 deletions
@ -0,0 +1,183 @@ |
|||||||
|
package apelet.tenantadmin.tenant.controller; |
||||||
|
|
||||||
|
import apelet.common.core.annotation.MyRequestBody; |
||||||
|
import apelet.common.core.constant.ErrorCodeEnum; |
||||||
|
import apelet.common.core.object.CallResult; |
||||||
|
import apelet.common.core.object.MyOrderParam; |
||||||
|
import apelet.common.core.object.MyPageParam; |
||||||
|
import apelet.common.core.object.ResponseResult; |
||||||
|
import apelet.common.core.util.MyCommonUtil; |
||||||
|
import apelet.common.core.util.MyPageUtil; |
||||||
|
import apelet.common.core.validator.UpdateGroup; |
||||||
|
import apelet.common.log.annotation.OperationLog; |
||||||
|
import apelet.common.log.model.constant.SysOperationLogType; |
||||||
|
import apelet.tenantadmin.tenant.model.PermissionDataRuleSchema; |
||||||
|
import apelet.tenantadmin.tenant.service.IPermissionDataRuleSchemaService; |
||||||
|
import com.github.pagehelper.page.PageMethod; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.validation.groups.Default; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限数据规则方案表 控制器。 |
||||||
|
* |
||||||
|
* @author chenchuchuan |
||||||
|
* @date 2026-07-15 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/tenantadmin/tenant/permissionDataRuleSchema") |
||||||
|
public class PermissionDataRuleSchemaController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IPermissionDataRuleSchemaService service; |
||||||
|
|
||||||
|
// ========== 新增 ==========
|
||||||
|
/** |
||||||
|
* 新增数据规则方案。 |
||||||
|
* |
||||||
|
* @param schema 新增的规则方案对象。 |
||||||
|
* @return 新增后的规则方案对象。 |
||||||
|
*/ |
||||||
|
@OperationLog(type = SysOperationLogType.ADD) |
||||||
|
@PostMapping("/add") |
||||||
|
public ResponseResult<?> add(@RequestBody PermissionDataRuleSchema schema) { |
||||||
|
schema.setCreateTime(new Date()); |
||||||
|
// 1. 基础字段校验(@NotBlank / @NotNull)
|
||||||
|
String errorMessage = MyCommonUtil.getModelValidationError(schema); |
||||||
|
if (errorMessage != null) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); |
||||||
|
} |
||||||
|
// 2. 业务校验:formId → 主表/单表,并填充 tableType
|
||||||
|
CallResult result = service.verifyRelatedData(schema); |
||||||
|
if (!result.isSuccess()) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
||||||
|
} |
||||||
|
// 3. 保存
|
||||||
|
service.saveNew(schema); |
||||||
|
return ResponseResult.success(schema); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 编辑(含启用/禁用) ==========
|
||||||
|
/** |
||||||
|
* 更新数据规则方案(含启用/禁用)。 |
||||||
|
* |
||||||
|
* @param schema 更新的规则方案对象。 |
||||||
|
* @return 应答结果。 |
||||||
|
*/ |
||||||
|
@OperationLog(type = SysOperationLogType.UPDATE) |
||||||
|
@PostMapping("/update") |
||||||
|
public ResponseResult<?> update(@RequestBody PermissionDataRuleSchema schema) { |
||||||
|
// 1. 基础校验(需校验 id 非空 + 其他必填字段)
|
||||||
|
String errorMessage = MyCommonUtil.getModelValidationError(schema, Default.class, UpdateGroup.class); |
||||||
|
if (errorMessage != null) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); |
||||||
|
} |
||||||
|
// 2. 检查数据是否存在
|
||||||
|
PermissionDataRuleSchema original = service.getById(schema.getId()); |
||||||
|
if (original == null) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, |
||||||
|
"数据验证失败,当前规则方案不存在,请刷新后重试!"); |
||||||
|
} |
||||||
|
// 3. 业务校验:formId → 主表/单表,填充 tableType
|
||||||
|
CallResult result = service.verifyRelatedData(schema); |
||||||
|
if (!result.isSuccess()) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
||||||
|
} |
||||||
|
// 4. 更新
|
||||||
|
schema.setUpdateTime(new Date()); |
||||||
|
if (!service.updateById(schema)) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
||||||
|
} |
||||||
|
return ResponseResult.success(); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 删除(启用状态禁止删) ==========
|
||||||
|
/** |
||||||
|
* 删除数据规则方案(已启用的规则不允许删除)。 |
||||||
|
* |
||||||
|
* @param id 主键ID。 |
||||||
|
* @return 应答结果。 |
||||||
|
*/ |
||||||
|
@OperationLog(type = SysOperationLogType.DELETE) |
||||||
|
@PostMapping("/delete") |
||||||
|
public ResponseResult<?> delete(@RequestBody Long id) { |
||||||
|
if (MyCommonUtil.existBlankArgument(id)) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
||||||
|
} |
||||||
|
PermissionDataRuleSchema schema = service.getById(id); |
||||||
|
if (schema == null) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
||||||
|
} |
||||||
|
// 启用状态不允许删除
|
||||||
|
if (Objects.equals(schema.getStatus(), 1)) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, |
||||||
|
"该规则方案已启用,请先禁用后再删除!"); |
||||||
|
} |
||||||
|
if (!service.removeById(id)) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
||||||
|
} |
||||||
|
return ResponseResult.success(); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 分页列表 ==========
|
||||||
|
/** |
||||||
|
* 分页查询数据规则方案列表。 |
||||||
|
* |
||||||
|
* @param filter 过滤条件(支持 ruleCode/ruleName/status)。 |
||||||
|
* @param orderParam 排序参数。 |
||||||
|
* @param pageParam 分页参数。 |
||||||
|
* @return 分页结果。 |
||||||
|
*/ |
||||||
|
@PostMapping("/list") |
||||||
|
public ResponseResult<?> list( |
||||||
|
@MyRequestBody PermissionDataRuleSchema filter, |
||||||
|
@MyRequestBody MyOrderParam orderParam, |
||||||
|
@MyRequestBody MyPageParam pageParam) { |
||||||
|
if (pageParam != null) { |
||||||
|
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||||
|
} |
||||||
|
List<PermissionDataRuleSchema> list = service.getListByFilter( |
||||||
|
filter, MyOrderParam.buildOrderBy(orderParam, PermissionDataRuleSchema.class)); |
||||||
|
return ResponseResult.success(MyPageUtil.makeResponseData( |
||||||
|
list, PermissionDataRuleSchema.INSTANCE)); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 根据 formId 查询启用的规则(运行时用) ==========
|
||||||
|
/** |
||||||
|
* 根据 formId 查询启用状态的数据规则方案(运行时用)。 |
||||||
|
* |
||||||
|
* @param formId 在线表ID。 |
||||||
|
* @return 启用状态的规则方案列表。 |
||||||
|
*/ |
||||||
|
@GetMapping("/listByFormId") |
||||||
|
public ResponseResult<List<PermissionDataRuleSchema>> listByFormId(@RequestParam Long formId) { |
||||||
|
if (MyCommonUtil.existBlankArgument(formId)) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
||||||
|
} |
||||||
|
List<PermissionDataRuleSchema> list = service.listByFormId(formId); |
||||||
|
return ResponseResult.success(list); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 查看详情 ==========
|
||||||
|
/** |
||||||
|
* 查看数据规则方案详情。 |
||||||
|
* |
||||||
|
* @param id 主键ID。 |
||||||
|
* @return 规则方案详情。 |
||||||
|
*/ |
||||||
|
@GetMapping("/view") |
||||||
|
public ResponseResult<PermissionDataRuleSchema> view(@RequestParam Long id) { |
||||||
|
if (MyCommonUtil.existBlankArgument(id)) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
||||||
|
} |
||||||
|
PermissionDataRuleSchema schema = service.getById(id); |
||||||
|
if (schema == null) { |
||||||
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
||||||
|
} |
||||||
|
return ResponseResult.success(schema); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package apelet.tenantadmin.tenant.dao; |
||||||
|
|
||||||
|
import apelet.common.core.base.dao.BaseDaoMapper; |
||||||
|
import apelet.tenantadmin.tenant.model.PermissionDataRuleSchema; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限数据规则方案表 Mapper 接口。 |
||||||
|
* |
||||||
|
* @author chenchuchuan |
||||||
|
* @date 2026-07-15 |
||||||
|
*/ |
||||||
|
public interface PermissionDataRuleSchemaMapper extends BaseDaoMapper<PermissionDataRuleSchema> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 分页条件查询(支持 rule_code/rule_name/status 过滤 + 排序)。 |
||||||
|
* |
||||||
|
* @param filter 过滤条件。 |
||||||
|
* @param orderBy 排序语句。 |
||||||
|
* @return 规则方案列表。 |
||||||
|
*/ |
||||||
|
List<PermissionDataRuleSchema> getListByFilter( |
||||||
|
@Param("filter") PermissionDataRuleSchema filter, |
||||||
|
@Param("orderBy") String orderBy); |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="apelet.tenantadmin.tenant.dao.PermissionDataRuleSchemaMapper"> |
||||||
|
|
||||||
|
<select id="getListByFilter" |
||||||
|
resultType="apelet.tenantadmin.tenant.model.PermissionDataRuleSchema"> |
||||||
|
SELECT * FROM zz_permission_data_rule_schema |
||||||
|
WHERE 1=1 |
||||||
|
<if test="filter.ruleCode != null and filter.ruleCode != ''"> |
||||||
|
AND rule_code LIKE CONCAT('%', #{filter.ruleCode}, '%') |
||||||
|
</if> |
||||||
|
<if test="filter.ruleName != null and filter.ruleName != ''"> |
||||||
|
AND rule_name LIKE CONCAT('%', #{filter.ruleName}, '%') |
||||||
|
</if> |
||||||
|
<if test="filter.status != null"> |
||||||
|
AND status = #{filter.status} |
||||||
|
</if> |
||||||
|
<if test="orderBy != null and orderBy != ''"> |
||||||
|
ORDER BY ${orderBy} |
||||||
|
</if> |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
||||||
@ -0,0 +1,131 @@ |
|||||||
|
package apelet.tenantadmin.tenant.model; |
||||||
|
|
||||||
|
import apelet.common.core.base.mapper.BaseModelMapper; |
||||||
|
import apelet.common.core.base.model.BaseModel; |
||||||
|
import apelet.common.core.validator.UpdateGroup; |
||||||
|
import apelet.tenantadmin.tenant.vo.PermissionDataRuleSchemaVo; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.mapstruct.Mapper; |
||||||
|
import org.mapstruct.factory.Mappers; |
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank; |
||||||
|
import javax.validation.constraints.NotNull; |
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限数据规则方案表 实体对象。 |
||||||
|
* |
||||||
|
* @author chenchuchuan |
||||||
|
* @date 2026-07-15 |
||||||
|
*/ |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@Data |
||||||
|
@TableName("zz_permission_data_rule_schema") |
||||||
|
public class PermissionDataRuleSchema extends BaseModel implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主键ID。 |
||||||
|
*/ |
||||||
|
@TableId(value = "id") |
||||||
|
@NotNull(message = "数据验证失败,id不能为空!", groups = {UpdateGroup.class}) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* zz_online_table表Id。 |
||||||
|
*/ |
||||||
|
@TableField(value = "form_id") |
||||||
|
@NotNull(message = "数据验证失败,form_id不能为空!") |
||||||
|
private Long formId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 表单元数据编码。 |
||||||
|
*/ |
||||||
|
@TableField(value = "meta_code") |
||||||
|
// @NotBlank(message = "数据验证失败,表单元数据编码不能为空!")
|
||||||
|
private String metaCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主表类型:1-主表,2-单表(由后端自动填充,前端无需传入)。 |
||||||
|
*/ |
||||||
|
@TableField(value = "table_type") |
||||||
|
private Integer tableType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 规则编码。 |
||||||
|
*/ |
||||||
|
@TableField(value = "rule_code") |
||||||
|
@NotBlank(message = "数据验证失败,规则编码不能为空!") |
||||||
|
private String ruleCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 规则方案名称。 |
||||||
|
*/ |
||||||
|
@TableField(value = "rule_name") |
||||||
|
@NotBlank(message = "数据验证失败,规则方案名称不能为空!") |
||||||
|
private String ruleName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 条件表达式(JSON)。 |
||||||
|
*/ |
||||||
|
@TableField(value = "condition_expression") |
||||||
|
@NotBlank(message = "数据验证失败,条件表达式不能为空!") |
||||||
|
private String conditionExpression; |
||||||
|
|
||||||
|
/** |
||||||
|
* 元数据展示名称 |
||||||
|
*/ |
||||||
|
@TableField(value = "meta_show_name") |
||||||
|
private String metaShowName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 状态:1-启用,0-禁用。 |
||||||
|
*/ |
||||||
|
@TableField(value = "status") |
||||||
|
private Integer status; |
||||||
|
|
||||||
|
/** |
||||||
|
* 备注。 |
||||||
|
*/ |
||||||
|
@TableField(value = "remark") |
||||||
|
private String remark; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建人。 |
||||||
|
*/ |
||||||
|
@TableField(value = "create_by") |
||||||
|
private String createBy; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间。 |
||||||
|
*/ |
||||||
|
@TableField(value = "create_time") |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新人。 |
||||||
|
*/ |
||||||
|
@TableField(value = "update_by") |
||||||
|
private String updateBy; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间。 |
||||||
|
*/ |
||||||
|
@TableField(value = "update_time") |
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
// ========== MapStruct ==========
|
||||||
|
@Mapper |
||||||
|
public interface PermissionDataRuleSchemaModelMapper |
||||||
|
extends BaseModelMapper<PermissionDataRuleSchemaVo, PermissionDataRuleSchema> { |
||||||
|
} |
||||||
|
|
||||||
|
public static final PermissionDataRuleSchemaModelMapper INSTANCE = |
||||||
|
Mappers.getMapper(PermissionDataRuleSchemaModelMapper.class); |
||||||
|
} |
||||||
@ -0,0 +1,50 @@ |
|||||||
|
package apelet.tenantadmin.tenant.service; |
||||||
|
|
||||||
|
import apelet.common.core.base.service.IBaseService; |
||||||
|
import apelet.common.core.object.CallResult; |
||||||
|
import apelet.tenantadmin.tenant.model.PermissionDataRuleSchema; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限数据规则方案表 服务接口。 |
||||||
|
* |
||||||
|
* @author chenchuchuan |
||||||
|
* @date 2026-07-15 |
||||||
|
*/ |
||||||
|
public interface IPermissionDataRuleSchemaService |
||||||
|
extends IBaseService<PermissionDataRuleSchema, Long> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 分页条件查询规则方案列表。 |
||||||
|
* |
||||||
|
* @param filter 过滤条件。 |
||||||
|
* @param orderBy 排序语句。 |
||||||
|
* @return 规则方案列表。 |
||||||
|
*/ |
||||||
|
List<PermissionDataRuleSchema> getListByFilter(PermissionDataRuleSchema filter, String orderBy); |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据 tableId 查询启用状态的规则(运行时用)。 |
||||||
|
* |
||||||
|
* @param tableId 在线表ID。 |
||||||
|
* @return 启用状态的规则列表。 |
||||||
|
*/ |
||||||
|
List<PermissionDataRuleSchema> listByFormId(Long tableId); |
||||||
|
|
||||||
|
/** |
||||||
|
* 校验关联数据:验证 tableId 对应的是主表或单表,并自动填充 tableType。 |
||||||
|
* |
||||||
|
* @param schema 待校验的规则方案对象。 |
||||||
|
* @return 校验结果。 |
||||||
|
*/ |
||||||
|
CallResult verifyRelatedData(PermissionDataRuleSchema schema); |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存新增(含 ID生成 + 默认状态设置)。 |
||||||
|
* |
||||||
|
* @param schema 新增的规则方案对象。 |
||||||
|
* @return 新增后的规则方案对象。 |
||||||
|
*/ |
||||||
|
PermissionDataRuleSchema saveNew(PermissionDataRuleSchema schema); |
||||||
|
} |
||||||
@ -0,0 +1,93 @@ |
|||||||
|
package apelet.tenantadmin.tenant.service.impl; |
||||||
|
|
||||||
|
import apelet.common.core.base.dao.BaseDaoMapper; |
||||||
|
import apelet.common.core.base.service.BaseService; |
||||||
|
import apelet.common.core.object.CallResult; |
||||||
|
import apelet.common.generator.model.OnlFormHead; |
||||||
|
import apelet.common.generator.service.IOnlFormHeadService; |
||||||
|
import apelet.common.sequence.wrapper.IdGeneratorWrapper; |
||||||
|
import apelet.tenantadmin.tenant.dao.PermissionDataRuleSchemaMapper; |
||||||
|
import apelet.tenantadmin.tenant.model.PermissionDataRuleSchema; |
||||||
|
import apelet.tenantadmin.tenant.service.IPermissionDataRuleSchemaService; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限数据规则方案表 服务实现类。 |
||||||
|
* |
||||||
|
* @author chenchuchuan |
||||||
|
* @date 2026-07-15 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
public class PermissionDataRuleSchemaServiceImpl |
||||||
|
extends BaseService<PermissionDataRuleSchema, Long> |
||||||
|
implements IPermissionDataRuleSchemaService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
PermissionDataRuleSchemaMapper mapper; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IdGeneratorWrapper idGenerator; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IOnlFormHeadService onlFormHeadService; |
||||||
|
|
||||||
|
// ========== BaseService 要求重写 ==========
|
||||||
|
@Override |
||||||
|
protected BaseDaoMapper<PermissionDataRuleSchema> mapper() { |
||||||
|
return mapper; |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 分页查询 ==========
|
||||||
|
@Override |
||||||
|
public List<PermissionDataRuleSchema> getListByFilter( |
||||||
|
PermissionDataRuleSchema filter, String orderBy) { |
||||||
|
return mapper.getListByFilter(filter, orderBy); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 按 tableId 查询启用状态的规则 ==========
|
||||||
|
@Override |
||||||
|
public List<PermissionDataRuleSchema> listByFormId(Long formId) { |
||||||
|
LambdaQueryWrapper<PermissionDataRuleSchema> qw = new LambdaQueryWrapper<>(); |
||||||
|
qw.eq(PermissionDataRuleSchema::getFormId, formId) |
||||||
|
.eq(PermissionDataRuleSchema::getStatus, 1); |
||||||
|
return this.list(qw); |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 新增(含 ID生成 + 默认状态) ==========
|
||||||
|
@Override |
||||||
|
public PermissionDataRuleSchema saveNew(PermissionDataRuleSchema schema) { |
||||||
|
schema.setId(idGenerator.nextLongId()); |
||||||
|
if (schema.getStatus() == null) { |
||||||
|
schema.setStatus(1); |
||||||
|
} |
||||||
|
this.save(schema); |
||||||
|
return schema; |
||||||
|
} |
||||||
|
|
||||||
|
// ========== 核心校验: tableId → 主表/单表,自动填充 tableType ==========
|
||||||
|
@Override |
||||||
|
public CallResult verifyRelatedData(PermissionDataRuleSchema schema) { |
||||||
|
// 1. 通过 tableName 查询 onl_form_head 获取 tableType
|
||||||
|
OnlFormHead formHead = onlFormHeadService.getById(schema.getFormId()); |
||||||
|
if (formHead == null) { |
||||||
|
return CallResult.error("数据验证失败,无法获取表类型信息,请检查表单配置!"); |
||||||
|
} |
||||||
|
|
||||||
|
// 2. tableType 校验: 0=附表拒绝, 1=主表, 2=单表
|
||||||
|
String tableType = formHead.getTableType(); |
||||||
|
if (!"1".equals(tableType) && !"2".equals(tableType)) { |
||||||
|
return CallResult.error("数据验证失败,仅主表和单表支持配置数据规则,当前为附表!"); |
||||||
|
} |
||||||
|
|
||||||
|
// 3. 自动填充 tableType
|
||||||
|
schema.setTableType(Integer.valueOf(tableType)); |
||||||
|
|
||||||
|
return CallResult.ok(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package apelet.tenantadmin.tenant.vo; |
||||||
|
|
||||||
|
import apelet.tenantadmin.tenant.model.PermissionDataRuleSchema; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 权限数据规则方案表 VO。 |
||||||
|
* |
||||||
|
* @author chenchuchuan |
||||||
|
* @date 2026-07-15 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class PermissionDataRuleSchemaVo extends PermissionDataRuleSchema implements Serializable { |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
} |
||||||
Loading…
Reference in new issue