mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-18 02:56:30 +08:00
commit:升级到vue3,更新最近工作流技术栈,支持sa-token
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.orangeforms.common.online.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
/**
|
||||
* common-online模块的自动配置引导类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@EnableConfigurationProperties({OnlineProperties.class})
|
||||
public class OnlineAutoConfig {
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.orangeforms.common.online.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单的配置对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "common-online")
|
||||
public class OnlineProperties {
|
||||
|
||||
/**
|
||||
* 脱敏字段的掩码。只能为单个字符。
|
||||
*/
|
||||
private String maskChar = "*";
|
||||
/**
|
||||
* 在调用render接口的时候,是否打开一级缓存加速页面渲染数据的获取。
|
||||
*/
|
||||
private Boolean enableRenderCache = true;
|
||||
/**
|
||||
* 业务表和在线表单内置表是否跨库。
|
||||
*/
|
||||
private Boolean enabledMultiDatabaseWrite = true;
|
||||
/**
|
||||
* 仅以该前缀开头的数据表才会成为动态表单的候选数据表,如: zz_。如果为空,则所有表均可被选。
|
||||
*/
|
||||
private String tablePrefix;
|
||||
/**
|
||||
* 在线表单业务操作的URL前缀。
|
||||
*/
|
||||
private String urlPrefix;
|
||||
/**
|
||||
* 在线表单打印接口的路径
|
||||
*/
|
||||
private String printUrlPath;
|
||||
/**
|
||||
* 上传文件的根路径。
|
||||
*/
|
||||
private String uploadFileBaseDir;
|
||||
/**
|
||||
* 1: minio 2: aliyun-oss 3: qcloud-cos。
|
||||
* 0是本地系统,不推荐使用。
|
||||
*/
|
||||
private Integer distributeStoreType;
|
||||
/**
|
||||
* 在线表单查看权限的URL列表。
|
||||
*/
|
||||
private List<String> viewUrlList;
|
||||
/**
|
||||
* 在线表单编辑权限的URL列表。
|
||||
*/
|
||||
private List<String> editUrlList;
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.constant.MaskFieldTypeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineColumnDto;
|
||||
import com.orangeforms.common.online.dto.OnlineColumnRuleDto;
|
||||
import com.orangeforms.common.online.dto.OnlineRuleDto;
|
||||
import com.orangeforms.common.online.model.*;
|
||||
import com.orangeforms.common.online.model.constant.FieldKind;
|
||||
import com.orangeforms.common.online.service.*;
|
||||
import com.orangeforms.common.online.vo.OnlineColumnRuleVo;
|
||||
import com.orangeforms.common.online.vo.OnlineColumnVo;
|
||||
import com.orangeforms.common.online.vo.OnlineRuleVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 在线表单字段数据接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单字段数据接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineColumn")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineColumnController {
|
||||
|
||||
@Autowired
|
||||
private OnlineColumnService onlineColumnService;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private OnlineVirtualColumnService onlineVirtualColumnService;
|
||||
@Autowired
|
||||
private OnlineDblinkService onlineDblinkService;
|
||||
@Autowired
|
||||
private OnlineRuleService onlineRuleService;
|
||||
@Autowired
|
||||
private OnlineDictService onlineDictService;
|
||||
|
||||
/**
|
||||
* 根据数据库表字段信息,在指定在线表中添加在线表字段对象。
|
||||
*
|
||||
* @param dblinkId 数据库链接Id。
|
||||
* @param tableName 数据库表名称。
|
||||
* @param columnName 数据库表字段名。
|
||||
* @param tableId 目的表Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Void> add(
|
||||
@MyRequestBody Long dblinkId,
|
||||
@MyRequestBody String tableName,
|
||||
@MyRequestBody String columnName,
|
||||
@MyRequestBody Long tableId) {
|
||||
OnlineDblink dblink = onlineDblinkService.getById(dblinkId);
|
||||
if (dblink == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
String errorMessage;
|
||||
SqlTableColumn sqlTableColumn = onlineDblinkService.getDblinkTableColumn(dblink, tableName, columnName);
|
||||
if (sqlTableColumn == null) {
|
||||
errorMessage = "数据验证失败,指定的数据表字段不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyTable(tableId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
onlineColumnService.saveNewList(CollUtil.newLinkedList(sqlTableColumn), tableId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新字段数据数据。
|
||||
*
|
||||
* @param onlineColumnDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineColumnDto onlineColumnDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineColumnDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineColumn onlineColumn = MyModelUtil.copyTo(onlineColumnDto, OnlineColumn.class);
|
||||
OnlineColumn originalOnlineColumn = onlineColumnService.getById(onlineColumn.getColumnId());
|
||||
if (originalOnlineColumn == null) {
|
||||
errorMessage = "数据验证失败,当前在线表字段并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
ResponseResult<Void> verifyColumnResult = this.doVerifyColumn(onlineColumn, originalOnlineColumn);
|
||||
if (!verifyColumnResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyColumnResult);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyTable(originalOnlineColumn.getTableId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlineColumnService.update(onlineColumn, originalOnlineColumn)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字段数据数据。
|
||||
*
|
||||
* @param columnId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long columnId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(columnId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
OnlineColumn originalOnlineColumn = onlineColumnService.getById(columnId);
|
||||
if (originalOnlineColumn == null) {
|
||||
errorMessage = "数据验证失败,当前在线表字段并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyTable(originalOnlineColumn.getTableId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn();
|
||||
virtualColumnFilter.setAggregationColumnId(columnId);
|
||||
List<OnlineVirtualColumn> virtualColumnList =
|
||||
onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null);
|
||||
if (CollUtil.isNotEmpty(virtualColumnList)) {
|
||||
OnlineVirtualColumn virtualColumn = virtualColumnList.get(0);
|
||||
errorMessage = "数据验证失败,数据源关联正在被虚拟字段 [" + virtualColumn.getColumnPrompt() + "] 使用,不能被删除!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineColumnService.remove(originalOnlineColumn.getTableId(), columnId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的字段数据列表。
|
||||
*
|
||||
* @param onlineColumnDtoFilter 过滤对象。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineColumnVo>> list(
|
||||
@MyRequestBody OnlineColumnDto onlineColumnDtoFilter,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineColumn onlineColumnFilter = MyModelUtil.copyTo(onlineColumnDtoFilter, OnlineColumn.class);
|
||||
List<OnlineColumn> onlineColumnList =
|
||||
onlineColumnService.getOnlineColumnListWithRelation(onlineColumnFilter);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineColumnList, OnlineColumnVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定字段数据对象详情。
|
||||
*
|
||||
* @param columnId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineColumnVo> view(@RequestParam Long columnId) {
|
||||
if (MyCommonUtil.existBlankArgument(columnId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineColumn onlineColumn = onlineColumnService.getByIdWithRelation(columnId, MyRelationParam.full());
|
||||
if (onlineColumn == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success(onlineColumn, OnlineColumnVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数据库中的表字段信息刷新到已经导入的在线表字段信息。
|
||||
*
|
||||
* @param dblinkId 数据库链接Id。
|
||||
* @param tableName 数据库表名称。
|
||||
* @param columnName 数据库表字段名。
|
||||
* @param columnId 被刷新的在线字段Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/refresh")
|
||||
public ResponseResult<Void> refresh(
|
||||
@MyRequestBody Long dblinkId,
|
||||
@MyRequestBody String tableName,
|
||||
@MyRequestBody String columnName,
|
||||
@MyRequestBody Long columnId) {
|
||||
OnlineDblink dblink = onlineDblinkService.getById(dblinkId);
|
||||
if (dblink == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
String errorMsg;
|
||||
SqlTableColumn sqlTableColumn = onlineDblinkService.getDblinkTableColumn(dblink, tableName, columnName);
|
||||
if (sqlTableColumn == null) {
|
||||
errorMsg = "数据验证失败,指定的数据表字段不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMsg);
|
||||
}
|
||||
OnlineColumn onlineColumn = onlineColumnService.getById(columnId);
|
||||
if (onlineColumn == null) {
|
||||
errorMsg = "数据验证失败,指定的在线表字段Id不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMsg);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyTable(onlineColumn.getTableId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
onlineColumnService.refresh(sqlTableColumn, onlineColumn);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出不与指定字段数据存在多对多关系的 [验证规则] 列表数据。通常用于查看添加新 [验证规则] 对象的候选列表。
|
||||
*
|
||||
* @param columnId 主表关联字段。
|
||||
* @param onlineRuleDtoFilter [验证规则] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/listNotInOnlineColumnRule")
|
||||
public ResponseResult<MyPageData<OnlineRuleVo>> listNotInOnlineColumnRule(
|
||||
@MyRequestBody Long columnId,
|
||||
@MyRequestBody OnlineRuleDto onlineRuleDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doVerifyColumn(columnId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineRule filter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class);
|
||||
List<OnlineRule> onlineRuleList =
|
||||
onlineRuleService.getNotInOnlineRuleListByColumnId(columnId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出与指定字段数据存在多对多关系的 [验证规则] 列表数据。
|
||||
*
|
||||
* @param columnId 主表关联字段。
|
||||
* @param onlineRuleDtoFilter [验证规则] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/listOnlineColumnRule")
|
||||
public ResponseResult<MyPageData<OnlineRuleVo>> listOnlineColumnRule(
|
||||
@MyRequestBody Long columnId,
|
||||
@MyRequestBody OnlineRuleDto onlineRuleDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doVerifyColumn(columnId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineRule filter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class);
|
||||
List<OnlineRule> onlineRuleList =
|
||||
onlineRuleService.getOnlineRuleListByColumnId(columnId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加字段数据和 [验证规则] 对象的多对多关联关系数据。
|
||||
*
|
||||
* @param columnId 主表主键Id。
|
||||
* @param onlineColumnRuleDtoList 关联对象列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD_M2M)
|
||||
@PostMapping("/addOnlineColumnRule")
|
||||
public ResponseResult<Void> addOnlineColumnRule(
|
||||
@MyRequestBody Long columnId, @MyRequestBody List<OnlineColumnRuleDto> onlineColumnRuleDtoList) {
|
||||
if (MyCommonUtil.existBlankArgument(columnId, onlineColumnRuleDtoList)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
String errorMessage;
|
||||
for (OnlineColumnRuleDto onlineColumnRule : onlineColumnRuleDtoList) {
|
||||
errorMessage = MyCommonUtil.getModelValidationError(onlineColumnRule);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyColumn(columnId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
Set<Long> ruleIdSet = onlineColumnRuleDtoList.stream()
|
||||
.map(OnlineColumnRuleDto::getRuleId).collect(Collectors.toSet());
|
||||
List<OnlineRule> ruleList = onlineRuleService.getInList(ruleIdSet);
|
||||
if (ruleIdSet.size() != ruleList.size()) {
|
||||
errorMessage = "数据验证失败,参数中存在非法字段规则Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID, errorMessage);
|
||||
}
|
||||
for (OnlineRule rule : ruleList) {
|
||||
if (BooleanUtil.isFalse(rule.getBuiltin())
|
||||
&& !StrUtil.equals(rule.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,参数中存在不属于该应用的字段规则Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
List<OnlineColumnRule> onlineColumnRuleList =
|
||||
MyModelUtil.copyCollectionTo(onlineColumnRuleDtoList, OnlineColumnRule.class);
|
||||
onlineColumnService.addOnlineColumnRuleList(onlineColumnRuleList, columnId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定字段数据和指定 [验证规则] 的多对多关联数据。
|
||||
*
|
||||
* @param onlineColumnRuleDto 对多对中间表对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/updateOnlineColumnRule")
|
||||
public ResponseResult<Void> updateOnlineColumnRule(@MyRequestBody OnlineColumnRuleDto onlineColumnRuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineColumnRuleDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyColumn(onlineColumnRuleDto.getColumnId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineColumnRule onlineColumnRule = MyModelUtil.copyTo(onlineColumnRuleDto, OnlineColumnRule.class);
|
||||
if (!onlineColumnService.updateOnlineColumnRule(onlineColumnRule)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示字段数据和指定 [验证规则] 的多对多关联详情数据。
|
||||
*
|
||||
* @param columnId 主表主键Id。
|
||||
* @param ruleId 从表主键Id。
|
||||
* @return 应答结果对象,包括中间表详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/viewOnlineColumnRule")
|
||||
public ResponseResult<OnlineColumnRuleVo> viewOnlineColumnRule(
|
||||
@RequestParam Long columnId, @RequestParam Long ruleId) {
|
||||
if (MyCommonUtil.existBlankArgument(columnId, ruleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyColumn(columnId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineColumnRule onlineColumnRule = onlineColumnService.getOnlineColumnRule(columnId, ruleId);
|
||||
if (onlineColumnRule == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
OnlineColumnRuleVo onlineColumnRuleVo = MyModelUtil.copyTo(onlineColumnRule, OnlineColumnRuleVo.class);
|
||||
return ResponseResult.success(onlineColumnRuleVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定字段数据和指定 [验证规则] 的多对多关联关系。
|
||||
*
|
||||
* @param columnId 主表主键Id。
|
||||
* @param ruleId 从表主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE_M2M)
|
||||
@PostMapping("/deleteOnlineColumnRule")
|
||||
public ResponseResult<Void> deleteOnlineColumnRule(@MyRequestBody Long columnId, @MyRequestBody Long ruleId) {
|
||||
if (MyCommonUtil.existBlankArgument(columnId, ruleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyColumn(columnId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlineColumnService.removeOnlineColumnRule(columnId, ruleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字典形式返回全部字段数据数据集合。字典的键值为[columnId, columnName]。
|
||||
* 白名单接口,登录用户均可访问。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict(@ParameterObject OnlineColumnDto filter) {
|
||||
List<OnlineColumn> resultList =
|
||||
onlineColumnService.getListByFilter(MyModelUtil.copyTo(filter, OnlineColumn.class));
|
||||
return ResponseResult.success(
|
||||
MyCommonUtil.toDictDataList(resultList, OnlineColumn::getColumnId, OnlineColumn::getColumnName));
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doVerifyColumn(Long columnId) {
|
||||
if (MyCommonUtil.existBlankArgument(columnId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineColumn onlineColumn = onlineColumnService.getById(columnId);
|
||||
if (onlineColumn == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyTable(onlineColumn.getTableId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doVerifyColumn(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn) {
|
||||
String errorMessage;
|
||||
if (onlineColumn.getDictId() != null
|
||||
&& ObjectUtil.notEqual(onlineColumn.getDictId(), originalOnlineColumn.getDictId())) {
|
||||
OnlineDict dict = onlineDictService.getById(onlineColumn.getDictId());
|
||||
if (dict == null) {
|
||||
errorMessage = "数据验证失败,关联的字典Id不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(dict.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,关联的字典Id并不属于当前应用!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
}
|
||||
if (MyCommonUtil.equalsAny(onlineColumn.getFieldKind(), FieldKind.UPLOAD, FieldKind.UPLOAD_IMAGE)
|
||||
&& onlineColumn.getUploadFileSystemType() == null) {
|
||||
errorMessage = "数据验证失败,上传字段必须设置上传文件系统类型!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (ObjectUtil.equal(onlineColumn.getFieldKind(), FieldKind.MASK_FIELD)) {
|
||||
if (onlineColumn.getMaskFieldType() == null) {
|
||||
errorMessage = "数据验证失败,脱敏字段没有设置脱敏类型!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!EnumUtil.contains(MaskFieldTypeEnum.class, onlineColumn.getMaskFieldType())) {
|
||||
errorMessage = "数据验证失败,脱敏字段设置的脱敏类型并不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
if (!onlineColumn.getTableId().equals(originalOnlineColumn.getTableId())) {
|
||||
errorMessage = "数据验证失败,字段的所属表Id不能修改!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doVerifyTable(Long tableId) {
|
||||
String errorMessage;
|
||||
OnlineTable table = onlineTableService.getById(tableId);
|
||||
if (table == null) {
|
||||
errorMessage = "数据验证失败,指定的数据表Id不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(table.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,当前应用并不包含该字段所在的表!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.AddGroup;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineDatasourceDto;
|
||||
import com.orangeforms.common.online.model.*;
|
||||
import com.orangeforms.common.online.model.constant.PageType;
|
||||
import com.orangeforms.common.online.service.*;
|
||||
import com.orangeforms.common.online.vo.OnlineDatasourceVo;
|
||||
import com.orangeforms.common.online.vo.OnlineTableVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单数据源接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单数据源接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineDatasource")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineDatasourceController {
|
||||
|
||||
@Autowired
|
||||
private OnlineDatasourceService onlineDatasourceService;
|
||||
@Autowired
|
||||
private OnlineFormService onlineFormService;
|
||||
@Autowired
|
||||
private OnlinePageService onlinePageService;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private OnlineColumnService onlineColumnService;
|
||||
@Autowired
|
||||
private OnlineDblinkService onlineDblinkService;
|
||||
|
||||
/**
|
||||
* 新增数据模型数据。
|
||||
*
|
||||
* @param onlineDatasourceDto 新增对象。
|
||||
* @param pageId 关联的页面Id。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlineDatasourceDto.datasourceId"})
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody OnlineDatasourceDto onlineDatasourceDto,
|
||||
@MyRequestBody(required = true) Long pageId) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineDatasourceDto, Default.class, AddGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlinePage onlinePage = onlinePageService.getById(pageId);
|
||||
if (onlinePage == null) {
|
||||
errorMessage = "数据验证失败,页面Id不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
String appCode = TokenData.takeFromRequest().getAppCode();
|
||||
if (!StrUtil.equals(onlinePage.getAppCode(), appCode)) {
|
||||
errorMessage = "数据验证失败,当前应用并不存在该页面!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDatasource onlineDatasource = MyModelUtil.copyTo(onlineDatasourceDto, OnlineDatasource.class);
|
||||
if (onlineDatasourceService.existByVariableName(onlineDatasource.getVariableName())) {
|
||||
errorMessage = "数据验证失败,当前数据源变量已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
OnlineDblink onlineDblink = onlineDblinkService.getById(onlineDatasourceDto.getDblinkId());
|
||||
if (onlineDblink == null) {
|
||||
errorMessage = "数据验证失败,关联的数据库链接Id不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(onlineDblink.getAppCode(), appCode)) {
|
||||
errorMessage = "数据验证失败,当前应用并不存在该数据库链接!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SqlTable sqlTable = onlineDblinkService.getDblinkTable(onlineDblink, onlineDatasourceDto.getMasterTableName());
|
||||
if (sqlTable == null) {
|
||||
errorMessage = "数据验证失败,指定的数据表名不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerifyPrimaryKey(sqlTable, onlinePage);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
try {
|
||||
onlineDatasource = onlineDatasourceService.saveNew(onlineDatasource, sqlTable, pageId);
|
||||
} catch (DuplicateKeyException e) {
|
||||
errorMessage = "数据验证失败,当前应用的数据源变量名已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(onlineDatasource.getDatasourceId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据模型数据。
|
||||
*
|
||||
* @param onlineDatasourceDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineDatasourceDto onlineDatasourceDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineDatasourceDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDatasource onlineDatasource = MyModelUtil.copyTo(onlineDatasourceDto, OnlineDatasource.class);
|
||||
ResponseResult<OnlineDatasource> verifyResult = this.doVerifyAndGet(onlineDatasource.getDatasourceId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDatasource originalOnlineDatasource = verifyResult.getData();
|
||||
if (!onlineDatasource.getDblinkId().equals(originalOnlineDatasource.getDblinkId())) {
|
||||
errorMessage = "数据验证失败,不能修改数据库链接Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineDatasource.getMasterTableId().equals(originalOnlineDatasource.getMasterTableId())) {
|
||||
errorMessage = "数据验证失败,不能修改主表Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(onlineDatasource.getVariableName(), originalOnlineDatasource.getVariableName())
|
||||
&& onlineDatasourceService.existByVariableName(onlineDatasource.getVariableName())) {
|
||||
errorMessage = "数据验证失败,当前数据源变量已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
try {
|
||||
if (!onlineDatasourceService.update(onlineDatasource, originalOnlineDatasource)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
} catch (DuplicateKeyException e) {
|
||||
errorMessage = "数据验证失败,当前应用的数据源变量名已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据模型数据。
|
||||
*
|
||||
* @param datasourceId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long datasourceId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(datasourceId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
ResponseResult<OnlineDatasource> verifyResult = this.doVerifyAndGet(datasourceId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
List<OnlineForm> formList = onlineFormService.getOnlineFormListByDatasourceId(datasourceId);
|
||||
if (CollUtil.isNotEmpty(formList)) {
|
||||
errorMessage = "数据验证失败,当前数据源正在被 [" + formList.get(0).getFormName() + "] 表单占用,请先删除关联数据!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineDatasourceService.remove(datasourceId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的数据模型列表。
|
||||
*
|
||||
* @param onlineDatasourceDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineDatasourceVo>> list(
|
||||
@MyRequestBody OnlineDatasourceDto onlineDatasourceDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineDatasource onlineDatasourceFilter = MyModelUtil.copyTo(onlineDatasourceDtoFilter, OnlineDatasource.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasource.class);
|
||||
List<OnlineDatasource> onlineDatasourceList =
|
||||
onlineDatasourceService.getOnlineDatasourceListWithRelation(onlineDatasourceFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceList, OnlineDatasourceVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定数据模型对象详情。
|
||||
*
|
||||
* @param datasourceId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineDatasourceVo> view(@RequestParam Long datasourceId) {
|
||||
ResponseResult<OnlineDatasource> verifyResult = this.doVerifyAndGet(datasourceId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDatasource onlineDatasource =
|
||||
onlineDatasourceService.getByIdWithRelation(datasourceId, MyRelationParam.full());
|
||||
OnlineDatasourceVo onlineDatasourceVo = MyModelUtil.copyTo(onlineDatasource, OnlineDatasourceVo.class);
|
||||
List<OnlineTable> tableList = onlineTableService.getOnlineTableListByDatasourceId(datasourceId);
|
||||
if (CollUtil.isNotEmpty(tableList)) {
|
||||
onlineDatasourceVo.setTableList(MyModelUtil.copyCollectionTo(tableList, OnlineTableVo.class));
|
||||
}
|
||||
return ResponseResult.success(onlineDatasourceVo);
|
||||
}
|
||||
|
||||
private ResponseResult<OnlineDatasource> doVerifyAndGet(Long datasourceId) {
|
||||
if (MyCommonUtil.existBlankArgument(datasourceId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineDatasource onlineDatasource = onlineDatasourceService.getById(datasourceId);
|
||||
if (onlineDatasource == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (!StrUtil.equals(onlineDatasource.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据源!");
|
||||
}
|
||||
return ResponseResult.success(onlineDatasource);
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doVerifyPrimaryKey(SqlTable sqlTable, OnlinePage onlinePage) {
|
||||
String errorMessage;
|
||||
boolean hasPrimaryKey = false;
|
||||
for (SqlTableColumn tableColumn : sqlTable.getColumnList()) {
|
||||
if (BooleanUtil.isFalse(tableColumn.getPrimaryKey())) {
|
||||
continue;
|
||||
}
|
||||
if (hasPrimaryKey) {
|
||||
errorMessage = "数据验证失败,数据表只能包含一个主键字段!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
hasPrimaryKey = true;
|
||||
// 流程表单的主表主键,不能是自增主键。
|
||||
if (BooleanUtil.isTrue(tableColumn.getAutoIncrement())
|
||||
&& onlinePage.getPageType().equals(PageType.FLOW)) {
|
||||
errorMessage = "数据验证失败,流程页面所关联的主表主键,不能是自增主键!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
CallResult verifyResult = onlineColumnService.verifyPrimaryKey(tableColumn);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
}
|
||||
if (!hasPrimaryKey) {
|
||||
errorMessage = "数据验证失败,数据表必须包含主键字段!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.AddGroup;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineDatasourceRelationDto;
|
||||
import com.orangeforms.common.online.model.*;
|
||||
import com.orangeforms.common.online.service.*;
|
||||
import com.orangeforms.common.online.vo.OnlineDatasourceRelationVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单数据源关联接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单数据源关联接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineDatasourceRelation")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineDatasourceRelationController {
|
||||
|
||||
@Autowired
|
||||
private OnlineDatasourceRelationService onlineDatasourceRelationService;
|
||||
@Autowired
|
||||
private OnlineDatasourceService onlineDatasourceService;
|
||||
@Autowired
|
||||
private OnlineVirtualColumnService onlineVirtualColumnService;
|
||||
@Autowired
|
||||
private OnlineDblinkService onlineDblinkService;
|
||||
@Autowired
|
||||
private OnlineFormService onlineFormService;
|
||||
|
||||
/**
|
||||
* 新增数据关联数据。
|
||||
*
|
||||
* @param onlineDatasourceRelationDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlineDatasourceRelationDto.relationId"})
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(
|
||||
onlineDatasourceRelationDto, Default.class, AddGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDatasourceRelation onlineDatasourceRelation =
|
||||
MyModelUtil.copyTo(onlineDatasourceRelationDto, OnlineDatasourceRelation.class);
|
||||
OnlineDatasource onlineDatasource =
|
||||
onlineDatasourceService.getById(onlineDatasourceRelationDto.getDatasourceId());
|
||||
if (onlineDatasource == null) {
|
||||
errorMessage = "数据验证失败,关联的数据源Id不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
String appCode = TokenData.takeFromRequest().getAppCode();
|
||||
if (!StrUtil.equals(onlineDatasource.getAppCode(), appCode)) {
|
||||
errorMessage = "数据验证失败,当前应用并不包含该数据源Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDblink onlineDblink = onlineDblinkService.getById(onlineDatasource.getDblinkId());
|
||||
SqlTable slaveTable = onlineDblinkService.getDblinkTable(
|
||||
onlineDblink, onlineDatasourceRelationDto.getSlaveTableName());
|
||||
if (slaveTable == null) {
|
||||
errorMessage = "数据验证失败,指定的数据表不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SqlTableColumn slaveColumn = null;
|
||||
for (SqlTableColumn column : slaveTable.getColumnList()) {
|
||||
if (column.getColumnName().equals(onlineDatasourceRelationDto.getSlaveColumnName())) {
|
||||
slaveColumn = column;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slaveColumn == null) {
|
||||
errorMessage = "数据验证失败,指定的数据表字段 [" + onlineDatasourceRelationDto.getSlaveColumnName() + "] 不存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult =
|
||||
onlineDatasourceRelationService.verifyRelatedData(onlineDatasourceRelation, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
onlineDatasourceRelation = onlineDatasourceRelationService.saveNew(onlineDatasourceRelation, slaveTable, slaveColumn);
|
||||
return ResponseResult.success(onlineDatasourceRelation.getRelationId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据关联数据。
|
||||
*
|
||||
* @param onlineDatasourceRelationDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(
|
||||
onlineDatasourceRelationDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDatasourceRelation onlineDatasourceRelation =
|
||||
MyModelUtil.copyTo(onlineDatasourceRelationDto, OnlineDatasourceRelation.class);
|
||||
ResponseResult<OnlineDatasourceRelation> verifyResult =
|
||||
this.doVerifyAndGet(onlineDatasourceRelation.getRelationId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDatasourceRelation originalOnlineDatasourceRelation = verifyResult.getData();
|
||||
if (!onlineDatasourceRelationDto.getRelationType().equals(originalOnlineDatasourceRelation.getRelationType())) {
|
||||
errorMessage = "数据验证失败,不能修改关联类型!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineDatasourceRelationDto.getSlaveTableId().equals(originalOnlineDatasourceRelation.getSlaveTableId())) {
|
||||
errorMessage = "数据验证失败,不能修改从表Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineDatasourceRelationDto.getDatasourceId().equals(originalOnlineDatasourceRelation.getDatasourceId())) {
|
||||
errorMessage = "数据验证失败,不能修改数据源Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = onlineDatasourceRelationService
|
||||
.verifyRelatedData(onlineDatasourceRelation, originalOnlineDatasourceRelation);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!onlineDatasourceRelationService.update(onlineDatasourceRelation, originalOnlineDatasourceRelation)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据关联数据。
|
||||
*
|
||||
* @param relationId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long relationId) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlineDatasourceRelation> verifyResult = this.doVerifyAndGet(relationId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDatasourceRelation onlineDatasourceRelation = verifyResult.getData();
|
||||
OnlineVirtualColumn virtualColumnFilter = new OnlineVirtualColumn();
|
||||
virtualColumnFilter.setRelationId(relationId);
|
||||
List<OnlineVirtualColumn> virtualColumnList =
|
||||
onlineVirtualColumnService.getOnlineVirtualColumnList(virtualColumnFilter, null);
|
||||
if (CollUtil.isNotEmpty(virtualColumnList)) {
|
||||
OnlineVirtualColumn virtualColumn = virtualColumnList.get(0);
|
||||
errorMessage = "数据验证失败,数据源关联正在被虚拟字段 [" + virtualColumn.getColumnPrompt() + "] 使用,不能被删除!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
List<OnlineForm> formList =
|
||||
onlineFormService.getOnlineFormListByTableId(onlineDatasourceRelation.getSlaveTableId());
|
||||
if (CollUtil.isNotEmpty(formList)) {
|
||||
errorMessage = "数据验证失败,当前数据源关联正在被 [" + formList.get(0).getFormName() + "] 表单占用,请先删除关联数据!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineDatasourceRelationService.remove(relationId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的数据关联列表。
|
||||
*
|
||||
* @param onlineDatasourceRelationDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分 页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineDatasourceRelationVo>> list(
|
||||
@MyRequestBody OnlineDatasourceRelationDto onlineDatasourceRelationDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineDatasourceRelation onlineDatasourceRelationFilter =
|
||||
MyModelUtil.copyTo(onlineDatasourceRelationDtoFilter, OnlineDatasourceRelation.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasourceRelation.class);
|
||||
List<OnlineDatasourceRelation> onlineDatasourceRelationList =
|
||||
onlineDatasourceRelationService.getOnlineDatasourceRelationListWithRelation(onlineDatasourceRelationFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceRelationList, OnlineDatasourceRelationVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定数据关联对象详情。
|
||||
*
|
||||
* @param relationId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineDatasourceRelationVo> view(@RequestParam Long relationId) {
|
||||
ResponseResult<OnlineDatasourceRelation> verifyResult = this.doVerifyAndGet(relationId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDatasourceRelation onlineDatasourceRelation =
|
||||
onlineDatasourceRelationService.getByIdWithRelation(relationId, MyRelationParam.full());
|
||||
return ResponseResult.success(onlineDatasourceRelation, OnlineDatasourceRelationVo.class);
|
||||
}
|
||||
|
||||
private ResponseResult<OnlineDatasourceRelation> doVerifyAndGet(Long relationId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(relationId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineDatasourceRelation relation =
|
||||
onlineDatasourceRelationService.getByIdWithRelation(relationId, MyRelationParam.full());
|
||||
if (relation == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (!StrUtil.equals(relation.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,当前应用不包含该数据源关联!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(relation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineDblinkDto;
|
||||
import com.orangeforms.common.online.model.OnlineDblink;
|
||||
import com.orangeforms.common.online.service.OnlineDblinkService;
|
||||
import com.orangeforms.common.online.util.OnlineDataSourceUtil;
|
||||
import com.orangeforms.common.online.vo.OnlineDblinkVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单数据库链接接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单数据库链接接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineDblink")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineDblinkController {
|
||||
|
||||
@Autowired
|
||||
private OnlineDblinkService onlineDblinkService;
|
||||
@Autowired
|
||||
private OnlineDataSourceUtil dataSourceUtil;
|
||||
|
||||
/**
|
||||
* 新增数据库链接数据。
|
||||
*
|
||||
* @param onlineDblinkDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlineDblinkDto onlineDblinkDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineDblinkDto, false);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDblink onlineDblink = MyModelUtil.copyTo(onlineDblinkDto, OnlineDblink.class);
|
||||
onlineDblink = onlineDblinkService.saveNew(onlineDblink);
|
||||
return ResponseResult.success(onlineDblink.getDblinkId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据库链接数据。
|
||||
*
|
||||
* @param onlineDblinkDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineDblinkDto onlineDblinkDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineDblinkDto, true);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDblink onlineDblink = MyModelUtil.copyTo(onlineDblinkDto, OnlineDblink.class);
|
||||
ResponseResult<OnlineDblink> verifyResult = this.doVerifyAndGet(onlineDblinkDto.getDblinkId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDblink originalOnlineDblink = verifyResult.getData();
|
||||
if (ObjectUtil.notEqual(onlineDblink.getDblinkType(), originalOnlineDblink.getDblinkType())) {
|
||||
errorMessage = "数据验证失败,不能修改数据库类型!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
String passwdKey = "password";
|
||||
JSONObject configJson = JSON.parseObject(onlineDblink.getConfiguration());
|
||||
String password = configJson.getString(passwdKey);
|
||||
if (StrUtil.isNotBlank(password) && StrUtil.isAllCharMatch(password, c -> '*' == c)) {
|
||||
password = JSON.parseObject(originalOnlineDblink.getConfiguration()).getString(passwdKey);
|
||||
configJson.put(passwdKey, password);
|
||||
onlineDblink.setConfiguration(configJson.toJSONString());
|
||||
}
|
||||
if (!onlineDblinkService.update(onlineDblink, originalOnlineDblink)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据库链接数据。
|
||||
*
|
||||
* @param dblinkId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long dblinkId) {
|
||||
String errorMessage;
|
||||
// 验证关联Id的数据合法性
|
||||
ResponseResult<OnlineDblink> verifyResult = this.doVerifyAndGet(dblinkId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlineDblinkService.remove(dblinkId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的数据库链接列表。
|
||||
*
|
||||
* @param onlineDblinkDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineDblinkVo>> list(
|
||||
@MyRequestBody OnlineDblinkDto onlineDblinkDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineDblink onlineDblinkFilter = MyModelUtil.copyTo(onlineDblinkDtoFilter, OnlineDblink.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDblink.class);
|
||||
List<OnlineDblink> onlineDblinkList =
|
||||
onlineDblinkService.getOnlineDblinkListWithRelation(onlineDblinkFilter, orderBy);
|
||||
for (OnlineDblink dblink : onlineDblinkList) {
|
||||
this.maskOffPassword(dblink);
|
||||
}
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineDblinkList, OnlineDblinkVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定数据库链接对象详情。
|
||||
*
|
||||
* @param dblinkId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineDblinkVo> view(@RequestParam Long dblinkId) {
|
||||
ResponseResult<OnlineDblink> verifyResult = this.doVerifyAndGet(dblinkId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDblink onlineDblink = verifyResult.getData();
|
||||
onlineDblinkService.buildRelationForData(onlineDblink, MyRelationParam.full());
|
||||
if (!StrUtil.equals(onlineDblink.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据库链接!");
|
||||
}
|
||||
this.maskOffPassword(onlineDblink);
|
||||
return ResponseResult.success(onlineDblink, OnlineDblinkVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定数据库链接下的所有动态表单依赖的数据表列表。
|
||||
*
|
||||
* @param dblinkId 数据库链接Id。
|
||||
* @return 所有动态表单依赖的数据表列表
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@GetMapping("/listDblinkTables")
|
||||
public ResponseResult<List<SqlTable>> listDblinkTables(@RequestParam Long dblinkId) {
|
||||
OnlineDblink dblink = onlineDblinkService.getById(dblinkId);
|
||||
if (dblink == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success(onlineDblinkService.getDblinkTableList(dblink));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定数据库链接下,指定数据表的所有字段信息。
|
||||
*
|
||||
* @param dblinkId 数据库链接Id。
|
||||
* @param tableName 表名。
|
||||
* @return 该表的所有字段列表。
|
||||
*/
|
||||
@SaCheckPermission("onlineDblink.all")
|
||||
@GetMapping("/listDblinkTableColumns")
|
||||
public ResponseResult<List<SqlTableColumn>> listDblinkTableColumns(
|
||||
@RequestParam Long dblinkId, @RequestParam String tableName) {
|
||||
OnlineDblink dblink = onlineDblinkService.getById(dblinkId);
|
||||
if (dblink == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success(onlineDblinkService.getDblinkTableColumnList(dblink, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试数据库链接的接口。
|
||||
*
|
||||
* @return 应答结果。
|
||||
*/
|
||||
@GetMapping("/testConnection")
|
||||
public ResponseResult<Void> testConnection(@RequestParam Long dblinkId) {
|
||||
ResponseResult<OnlineDblink> verifyAndGet = this.doVerifyAndGet(dblinkId);
|
||||
if (!verifyAndGet.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyAndGet);
|
||||
}
|
||||
try {
|
||||
dataSourceUtil.testConnection(dblinkId);
|
||||
return ResponseResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to test connection with ONLINE_DBLINK_ID [" + dblinkId + "]!", e);
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_ACCESS_FAILED, "数据库连接失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字典形式返回全部数据库链接数据集合。字典的键值为[dblinkId, dblinkName]。
|
||||
* 白名单接口,登录用户均可访问。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict(@ParameterObject OnlineDblinkDto filter) {
|
||||
List<OnlineDblink> resultList =
|
||||
onlineDblinkService.getOnlineDblinkList(MyModelUtil.copyTo(filter, OnlineDblink.class), null);
|
||||
return ResponseResult.success(
|
||||
MyCommonUtil.toDictDataList(resultList, OnlineDblink::getDblinkId, OnlineDblink::getDblinkName));
|
||||
}
|
||||
|
||||
private ResponseResult<OnlineDblink> doVerifyAndGet(Long dblinkId) {
|
||||
if (MyCommonUtil.existBlankArgument(dblinkId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineDblink onlineDblink = onlineDblinkService.getById(dblinkId);
|
||||
if (onlineDblink == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (!StrUtil.equals(onlineDblink.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
return ResponseResult.error(
|
||||
ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用并不存在该数据库链接!");
|
||||
}
|
||||
return ResponseResult.success(onlineDblink);
|
||||
}
|
||||
|
||||
private void maskOffPassword(OnlineDblink dblink) {
|
||||
String passwdKey = "password";
|
||||
JSONObject configJson = JSON.parseObject(dblink.getConfiguration());
|
||||
if (configJson.containsKey(passwdKey)) {
|
||||
String password = configJson.getString(passwdKey);
|
||||
if (StrUtil.isNotBlank(password)) {
|
||||
configJson.put(passwdKey, StrUtil.repeat('*', password.length()));
|
||||
dblink.setConfiguration(configJson.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.dict.dto.GlobalDictDto;
|
||||
import com.orangeforms.common.dict.util.GlobalDictOperationHelper;
|
||||
import com.orangeforms.common.dict.vo.GlobalDictVo;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineDictDto;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import com.orangeforms.common.online.model.OnlineDict;
|
||||
import com.orangeforms.common.online.model.OnlineTable;
|
||||
import com.orangeforms.common.online.service.OnlineColumnService;
|
||||
import com.orangeforms.common.online.service.OnlineTableService;
|
||||
import com.orangeforms.common.online.service.OnlineDictService;
|
||||
import com.orangeforms.common.online.vo.OnlineDictVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单字典接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单字典接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineDict")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineDictController {
|
||||
|
||||
@Autowired
|
||||
private OnlineDictService onlineDictService;
|
||||
@Autowired
|
||||
private OnlineColumnService onlineColumnService;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private GlobalDictOperationHelper globalDictOperationHelper;
|
||||
|
||||
/**
|
||||
* 新增在线表单字典数据。
|
||||
*
|
||||
* @param onlineDictDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlineDictDto.dictId"})
|
||||
@SaCheckPermission("onlineDict.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlineDictDto onlineDictDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineDictDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDict onlineDict = MyModelUtil.copyTo(onlineDictDto, OnlineDict.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = onlineDictService.verifyRelatedData(onlineDict, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
onlineDict = onlineDictService.saveNew(onlineDict);
|
||||
return ResponseResult.success(onlineDict.getDictId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新在线表单字典数据。
|
||||
*
|
||||
* @param onlineDictDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlineDict.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineDictDto onlineDictDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineDictDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineDict onlineDict = MyModelUtil.copyTo(onlineDictDto, OnlineDict.class);
|
||||
ResponseResult<OnlineDict> verifyResult = this.doVerifyAndGet(onlineDict.getDictId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDict originalOnlineDict = verifyResult.getData();
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = onlineDictService.verifyRelatedData(onlineDict, originalOnlineDict);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!onlineDictService.update(onlineDict, originalOnlineDict)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除在线表单字典数据。
|
||||
*
|
||||
* @param dictId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlineDict.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long dictId) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlineDict> verifyResult = this.doVerifyAndGet(dictId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineColumn filter = new OnlineColumn();
|
||||
filter.setDictId(dictId);
|
||||
List<OnlineColumn> columns = onlineColumnService.getListByFilter(filter);
|
||||
if (CollUtil.isNotEmpty(columns)) {
|
||||
OnlineColumn usingColumn = columns.get(0);
|
||||
OnlineTable table = onlineTableService.getById(usingColumn.getTableId());
|
||||
errorMessage = String.format("数据验证失败,数据表 [%s] 字段 [%s] 正在引用该字典,因此不能直接删除!",
|
||||
table.getTableName(), usingColumn.getColumnName());
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!onlineDictService.remove(dictId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的在线表单字典列表。
|
||||
*
|
||||
* @param onlineDictDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlineDict.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineDictVo>> list(
|
||||
@MyRequestBody OnlineDictDto onlineDictDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineDict onlineDictFilter = MyModelUtil.copyTo(onlineDictDtoFilter, OnlineDict.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDict.class);
|
||||
List<OnlineDict> onlineDictList = onlineDictService.getOnlineDictListWithRelation(onlineDictFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineDictList, OnlineDictVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定在线表单字典对象详情。
|
||||
*
|
||||
* @param dictId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlineDict.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineDictVo> view(@RequestParam Long dictId) {
|
||||
ResponseResult<OnlineDict> verifyResult = this.doVerifyAndGet(dictId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineDict onlineDict = onlineDictService.getByIdWithRelation(dictId, MyRelationParam.full());
|
||||
if (onlineDict == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success(onlineDict, OnlineDictVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部编码字典列表。
|
||||
* NOTE: 白名单接口。
|
||||
*
|
||||
* @param globalDictDtoFilter 过滤对象。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 字典的数据列表。
|
||||
*/
|
||||
@PostMapping("/listAllGlobalDict")
|
||||
public ResponseResult<MyPageData<GlobalDictVo>> listAllGlobalDict(
|
||||
@MyRequestBody GlobalDictDto globalDictDtoFilter,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
return globalDictOperationHelper.listAllGlobalDict(globalDictDtoFilter, pageParam);
|
||||
}
|
||||
|
||||
private ResponseResult<OnlineDict> doVerifyAndGet(Long dictId) {
|
||||
if (MyCommonUtil.existBlankArgument(dictId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineDict originalDict = onlineDictService.getById(dictId);
|
||||
if (originalDict == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (!StrUtil.equals(originalDict.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
return ResponseResult.error(
|
||||
ErrorCodeEnum.DATA_VALIDATED_FAILED, "数据验证失败,当前应用不存在该在线表单字典!");
|
||||
}
|
||||
return ResponseResult.success(originalDict);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orangeforms.common.core.cache.CacheConfig;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.config.OnlineProperties;
|
||||
import com.orangeforms.common.online.dto.OnlineFormDto;
|
||||
import com.orangeforms.common.online.model.*;
|
||||
import com.orangeforms.common.online.service.*;
|
||||
import com.orangeforms.common.online.vo.OnlineFormVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 在线表单表单接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单表单接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineForm")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineFormController {
|
||||
|
||||
@Autowired
|
||||
private OnlineFormService onlineFormService;
|
||||
@Autowired
|
||||
private OnlineDatasourceService onlineDatasourceService;
|
||||
@Autowired
|
||||
private OnlineDatasourceRelationService onlineDatasourceRelationService;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private OnlineColumnService onlineColumnService;
|
||||
@Autowired
|
||||
private OnlineVirtualColumnService onlineVirtualColumnService;
|
||||
@Autowired
|
||||
private OnlineDictService onlineDictService;
|
||||
@Autowired
|
||||
private OnlineRuleService onlineRuleService;
|
||||
@Autowired
|
||||
private OnlineProperties properties;
|
||||
@Resource(name = "caffeineCacheManager")
|
||||
private CacheManager cacheManager;
|
||||
|
||||
/**
|
||||
* 新增在线表单数据。
|
||||
*
|
||||
* @param onlineFormDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlineFormDto.formId"})
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlineFormDto onlineFormDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineFormDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineForm onlineForm = MyModelUtil.copyTo(onlineFormDto, OnlineForm.class);
|
||||
if (onlineFormService.existByFormCode(onlineForm.getFormCode())) {
|
||||
errorMessage = "数据验证失败,表单编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = onlineFormService.verifyRelatedData(onlineForm, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Set<Long> datasourceIdSet = null;
|
||||
if (CollUtil.isNotEmpty(onlineFormDto.getDatasourceIdList())) {
|
||||
ResponseResult<Set<Long>> verifyDatasourceIdsResult =
|
||||
this.doVerifyDatasourceIdsAndGet(onlineFormDto.getDatasourceIdList());
|
||||
if (!verifyDatasourceIdsResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyDatasourceIdsResult);
|
||||
}
|
||||
datasourceIdSet = verifyDatasourceIdsResult.getData();
|
||||
}
|
||||
onlineForm = onlineFormService.saveNew(onlineForm, datasourceIdSet);
|
||||
return ResponseResult.success(onlineForm.getFormId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新在线表单数据。
|
||||
*
|
||||
* @param onlineFormDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineFormDto onlineFormDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineFormDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineForm onlineForm = MyModelUtil.copyTo(onlineFormDto, OnlineForm.class);
|
||||
ResponseResult<OnlineForm> verifyResult = this.doVerifyAndGet(onlineForm.getFormId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineForm originalOnlineForm = verifyResult.getData();
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = onlineFormService.verifyRelatedData(onlineForm, originalOnlineForm);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(onlineForm.getFormCode(), originalOnlineForm.getFormCode())
|
||||
&& onlineFormService.existByFormCode(onlineForm.getFormCode())) {
|
||||
errorMessage = "数据验证失败,表单编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
Set<Long> datasourceIdSet = null;
|
||||
if (CollUtil.isNotEmpty(onlineFormDto.getDatasourceIdList())) {
|
||||
ResponseResult<Set<Long>> verifyDatasourceIdsResult =
|
||||
this.doVerifyDatasourceIdsAndGet(onlineFormDto.getDatasourceIdList());
|
||||
if (!verifyDatasourceIdsResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyDatasourceIdsResult);
|
||||
}
|
||||
datasourceIdSet = verifyDatasourceIdsResult.getData();
|
||||
}
|
||||
if (!onlineFormService.update(onlineForm, originalOnlineForm, datasourceIdSet)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除在线表单数据。
|
||||
*
|
||||
* @param formId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long formId) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlineForm> verifyResult = this.doVerifyAndGet(formId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlineFormService.remove(formId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 克隆一个在线表单对象。
|
||||
*
|
||||
* @param formId 源表单主键Id。
|
||||
* @return 新克隆表单主键Id。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/clone")
|
||||
public ResponseResult<Long> clone(@MyRequestBody Long formId) {
|
||||
ResponseResult<OnlineForm> verifyResult = this.doVerifyAndGet(formId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineForm form = verifyResult.getData();
|
||||
form.setFormName(form.getFormName() + "_copy");
|
||||
form.setFormCode(form.getFormCode() + "_copy_" + System.currentTimeMillis());
|
||||
List<OnlineFormDatasource> formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId);
|
||||
Set<Long> datasourceIdSet = formDatasourceList.stream()
|
||||
.map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toSet());
|
||||
onlineFormService.saveNew(form, datasourceIdSet);
|
||||
return ResponseResult.success(form.getFormId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的在线表单列表。
|
||||
*
|
||||
* @param onlineFormDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineFormVo>> list(
|
||||
@MyRequestBody OnlineFormDto onlineFormDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineForm onlineFormFilter = MyModelUtil.copyTo(onlineFormDtoFilter, OnlineForm.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineForm.class);
|
||||
List<OnlineForm> onlineFormList =
|
||||
onlineFormService.getOnlineFormListWithRelation(onlineFormFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineFormList, OnlineFormVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定在线表单对象详情。
|
||||
*
|
||||
* @param formId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineFormVo> view(@RequestParam Long formId) {
|
||||
ResponseResult<OnlineForm> verifyResult = this.doVerifyAndGet(formId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineForm onlineForm = onlineFormService.getByIdWithRelation(formId, MyRelationParam.full());
|
||||
OnlineFormVo onlineFormVo = MyModelUtil.copyTo(onlineForm, OnlineFormVo.class);
|
||||
List<OnlineFormDatasource> formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId);
|
||||
if (CollUtil.isNotEmpty(formDatasourceList)) {
|
||||
onlineFormVo.setDatasourceIdList(formDatasourceList.stream()
|
||||
.map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toList()));
|
||||
}
|
||||
return ResponseResult.success(onlineFormVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定在线表单对象在前端渲染时所需的所有数据对象。
|
||||
*
|
||||
* @param formId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/render")
|
||||
public ResponseResult<JSONObject> render(@RequestParam Long formId) {
|
||||
String errorMessage;
|
||||
Cache cache = null;
|
||||
if (BooleanUtil.isTrue(properties.getEnableRenderCache())) {
|
||||
cache = cacheManager.getCache(CacheConfig.CacheEnum.ONLINE_FORM_RENDER_CACCHE.name());
|
||||
Assert.notNull(cache, "Cache ONLINE_FORM_RENDER_CACCHE can't be NULL");
|
||||
JSONObject responseData = cache.get(formId, JSONObject.class);
|
||||
if (responseData != null) {
|
||||
Object appCode = responseData.get("appCode");
|
||||
if (ObjectUtil.notEqual(appCode, TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,当前应用不包含该表单Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(responseData);
|
||||
}
|
||||
}
|
||||
OnlineForm onlineForm = onlineFormService.getOnlineFormFromCache(formId);
|
||||
if (onlineForm == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
OnlineFormVo onlineFormVo = MyModelUtil.copyTo(onlineForm, OnlineFormVo.class);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("onlineForm", onlineFormVo);
|
||||
List<OnlineFormDatasource> formDatasourceList = onlineFormService.getFormDatasourceListFromCache(formId);
|
||||
if (CollUtil.isEmpty(formDatasourceList)) {
|
||||
return ResponseResult.success(jsonObject);
|
||||
}
|
||||
Set<Long> datasourceIdSet = formDatasourceList.stream()
|
||||
.map(OnlineFormDatasource::getDatasourceId).collect(Collectors.toSet());
|
||||
List<OnlineDatasource> onlineDatasourceList =
|
||||
onlineDatasourceService.getOnlineDatasourceListFromCache(datasourceIdSet);
|
||||
jsonObject.put("onlineDatasourceList", onlineDatasourceList);
|
||||
Set<Long> tableIdSet = onlineDatasourceList.stream()
|
||||
.map(OnlineDatasource::getMasterTableId).collect(Collectors.toSet());
|
||||
List<OnlineDatasourceRelation> onlineDatasourceRelationList =
|
||||
onlineDatasourceRelationService.getOnlineDatasourceRelationListFromCache(datasourceIdSet);
|
||||
if (CollUtil.isNotEmpty(onlineDatasourceRelationList)) {
|
||||
jsonObject.put("onlineDatasourceRelationList", onlineDatasourceRelationList);
|
||||
tableIdSet.addAll(onlineDatasourceRelationList.stream()
|
||||
.map(OnlineDatasourceRelation::getSlaveTableId).collect(Collectors.toList()));
|
||||
}
|
||||
List<OnlineTable> onlineTableList = new LinkedList<>();
|
||||
List<OnlineColumn> onlineColumnList = new LinkedList<>();
|
||||
for (Long tableId : tableIdSet) {
|
||||
OnlineTable table = onlineTableService.getOnlineTableFromCache(tableId);
|
||||
onlineTableList.add(table);
|
||||
onlineColumnList.addAll(table.getColumnMap().values());
|
||||
table.setColumnMap(null);
|
||||
}
|
||||
jsonObject.put("onlineTableList", onlineTableList);
|
||||
jsonObject.put("onlineColumnList", onlineColumnList);
|
||||
List<OnlineVirtualColumn> virtualColumnList =
|
||||
onlineVirtualColumnService.getOnlineVirtualColumnListByTableIds(tableIdSet);
|
||||
jsonObject.put("onlineVirtualColumnList", virtualColumnList);
|
||||
Set<Long> dictIdSet = onlineColumnList.stream()
|
||||
.filter(c -> c.getDictId() != null).map(OnlineColumn::getDictId).collect(Collectors.toSet());
|
||||
Set<Long> widgetDictIdSet = this.extractDictIdSetFromWidgetJson(onlineForm.getWidgetJson());
|
||||
CollUtil.addAll(dictIdSet, widgetDictIdSet);
|
||||
if (CollUtil.isNotEmpty(dictIdSet)) {
|
||||
List<OnlineDict> onlineDictList = onlineDictService.getOnlineDictListFromCache(dictIdSet);
|
||||
if (onlineDictList.size() != dictIdSet.size()) {
|
||||
Set<Long> columnDictIdSet = onlineDictList.stream().map(OnlineDict::getDictId).collect(Collectors.toSet());
|
||||
Long notExistDictId = this.findNotExistDictId(dictIdSet, columnDictIdSet);
|
||||
Assert.notNull(notExistDictId, "notExistDictId can't be NULL");
|
||||
errorMessage = String.format("数据验证失败,字典Id [%s] 不存在!", notExistDictId);
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
jsonObject.put("onlineDictList", onlineDictList);
|
||||
}
|
||||
Set<Long> columnIdSet = onlineColumnList.stream().map(OnlineColumn::getColumnId).collect(Collectors.toSet());
|
||||
List<OnlineColumnRule> colunmRuleList = onlineRuleService.getOnlineColumnRuleListByColumnIds(columnIdSet);
|
||||
if (CollUtil.isNotEmpty(colunmRuleList)) {
|
||||
jsonObject.put("onlineColumnRuleList", colunmRuleList);
|
||||
}
|
||||
jsonObject.put("appCode", TokenData.takeFromRequest().getAppCode());
|
||||
if (BooleanUtil.isTrue(properties.getEnableRenderCache())) {
|
||||
Assert.notNull(cache, "Cache ONLINE_FORM_RENDER_CACCHE can't be NULL");
|
||||
cache.put(formId, jsonObject);
|
||||
}
|
||||
return ResponseResult.success(jsonObject);
|
||||
}
|
||||
|
||||
private Long findNotExistDictId(Set<Long> originalDictIdSet, Set<Long> dictIdSet) {
|
||||
return originalDictIdSet.stream().filter(d -> !dictIdSet.contains(d)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
private ResponseResult<OnlineForm> doVerifyAndGet(Long formId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(formId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
OnlineForm form = onlineFormService.getById(formId);
|
||||
if (form == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (!StrUtil.equals(form.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,当前应用不包含该表单!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (ObjectUtil.notEqual(form.getTenantId(), TokenData.takeFromRequest().getTenantId())) {
|
||||
errorMessage = "数据验证失败,当前租户不包含该表单!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(form);
|
||||
}
|
||||
|
||||
private ResponseResult<Set<Long>> doVerifyDatasourceIdsAndGet(List<Long> datasourceIdList) {
|
||||
String errorMessage;
|
||||
Set<Long> datasourceIdSet = new HashSet<>(datasourceIdList);
|
||||
List<OnlineDatasource> datasourceList = onlineDatasourceService.getInList(datasourceIdSet);
|
||||
if (datasourceIdSet.size() != datasourceList.size()) {
|
||||
errorMessage = "数据验证失败,当前在线表单包含不存在的数据源Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
String appCode = TokenData.takeFromRequest().getAppCode();
|
||||
for (OnlineDatasource datasource : datasourceList) {
|
||||
if (!StrUtil.equals(datasource.getAppCode(), appCode)) {
|
||||
errorMessage = "数据验证失败,存在不是当前应用的数据源!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
return ResponseResult.success(datasourceIdSet);
|
||||
}
|
||||
|
||||
private Set<Long> extractDictIdSetFromWidgetJson(String widgetJson) {
|
||||
Set<Long> dictIdSet = new HashSet<>();
|
||||
if (StrUtil.isBlank(widgetJson)) {
|
||||
return dictIdSet;
|
||||
}
|
||||
JSONObject allData = JSON.parseObject(widgetJson);
|
||||
JSONObject pcData = allData.getJSONObject("pc");
|
||||
if (MapUtil.isEmpty(pcData)) {
|
||||
return dictIdSet;
|
||||
}
|
||||
JSONArray widgetListArray = pcData.getJSONArray("widgetList");
|
||||
if (CollUtil.isEmpty(widgetListArray)) {
|
||||
return dictIdSet;
|
||||
}
|
||||
for (int i = 0; i < widgetListArray.size(); i++) {
|
||||
this.recursiveExtractDictId(widgetListArray.getJSONObject(i), dictIdSet);
|
||||
}
|
||||
return dictIdSet;
|
||||
}
|
||||
|
||||
private void recursiveExtractDictId(JSONObject widgetData, Set<Long> dictIdSet) {
|
||||
JSONObject propsData = widgetData.getJSONObject("props");
|
||||
if (MapUtil.isNotEmpty(propsData)) {
|
||||
JSONObject dictInfoData = propsData.getJSONObject("dictInfo");
|
||||
if (MapUtil.isNotEmpty(dictInfoData)) {
|
||||
Long dictId = dictInfoData.getLong("dictId");
|
||||
if (dictId != null) {
|
||||
dictIdSet.add(dictId);
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray childWidgetArray = widgetData.getJSONArray("childWidgetList");
|
||||
if (CollUtil.isNotEmpty(childWidgetArray)) {
|
||||
for (int i = 0; i < childWidgetArray.size(); i++) {
|
||||
this.recursiveExtractDictId(childWidgetArray.getJSONObject(i), dictIdSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,386 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineDatasourceDto;
|
||||
import com.orangeforms.common.online.dto.OnlinePageDatasourceDto;
|
||||
import com.orangeforms.common.online.dto.OnlinePageDto;
|
||||
import com.orangeforms.common.online.model.OnlineDatasource;
|
||||
import com.orangeforms.common.online.model.OnlineForm;
|
||||
import com.orangeforms.common.online.model.OnlinePage;
|
||||
import com.orangeforms.common.online.model.OnlinePageDatasource;
|
||||
import com.orangeforms.common.online.model.constant.PageStatus;
|
||||
import com.orangeforms.common.online.service.OnlineDatasourceService;
|
||||
import com.orangeforms.common.online.service.OnlineFormService;
|
||||
import com.orangeforms.common.online.service.OnlinePageService;
|
||||
import com.orangeforms.common.online.vo.OnlineDatasourceVo;
|
||||
import com.orangeforms.common.online.vo.OnlinePageDatasourceVo;
|
||||
import com.orangeforms.common.online.vo.OnlinePageVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 在线表单页面接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单页面接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlinePage")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlinePageController {
|
||||
|
||||
@Autowired
|
||||
private OnlinePageService onlinePageService;
|
||||
@Autowired
|
||||
private OnlineFormService onlineFormService;
|
||||
@Autowired
|
||||
private OnlineDatasourceService onlineDatasourceService;
|
||||
|
||||
/**
|
||||
* 新增在线表单页面数据。
|
||||
*
|
||||
* @param onlinePageDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlinePageDto.pageId"})
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlinePageDto onlinePageDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlinePage onlinePage = MyModelUtil.copyTo(onlinePageDto, OnlinePage.class);
|
||||
if (onlinePageService.existByPageCode(onlinePage.getPageCode())) {
|
||||
errorMessage = "数据验证失败,页面编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
try {
|
||||
onlinePage = onlinePageService.saveNew(onlinePage);
|
||||
} catch (DuplicateKeyException e) {
|
||||
errorMessage = "数据验证失败,当前应用的页面编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(onlinePage.getPageId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新在线表单页面数据。
|
||||
*
|
||||
* @param onlinePageDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlinePageDto onlinePageDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlinePageDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlinePage onlinePage = MyModelUtil.copyTo(onlinePageDto, OnlinePage.class);
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(onlinePage.getPageId());
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlinePage originalOnlinePage = verifyResult.getData();
|
||||
if (!onlinePage.getPageType().equals(originalOnlinePage.getPageType())) {
|
||||
errorMessage = "数据验证失败,页面类型不能修改!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(onlinePage.getPageCode(), originalOnlinePage.getPageCode())
|
||||
&& onlinePageService.existByPageCode(onlinePage.getPageCode())) {
|
||||
errorMessage = "数据验证失败,页面编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
try {
|
||||
if (!onlinePageService.update(onlinePage, originalOnlinePage)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
} catch (DuplicateKeyException e) {
|
||||
errorMessage = "数据验证失败,当前应用的页面编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新在线表单页面对象的发布状态字段。
|
||||
*
|
||||
* @param pageId 待更新的页面对象主键Id。
|
||||
* @param published 发布状态。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@PostMapping("/updatePublished")
|
||||
public ResponseResult<Void> updateStatus(
|
||||
@MyRequestBody(required = true) Long pageId,
|
||||
@MyRequestBody(required = true) Boolean published) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlinePage originalOnlinePage = verifyResult.getData();
|
||||
if (!published.equals(originalOnlinePage.getPublished())) {
|
||||
if (BooleanUtil.isTrue(published) && !originalOnlinePage.getStatus().equals(PageStatus.FORM_DESIGN)) {
|
||||
errorMessage = "数据验证失败,当前页面状态不为 [设计] 状态,因此不能发布!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
onlinePageService.updatePublished(pageId, published);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除在线表单页面数据。
|
||||
*
|
||||
* @param pageId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long pageId) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlinePageService.remove(pageId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的在线表单页面列表。
|
||||
*
|
||||
* @param onlinePageDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlinePageVo>> list(
|
||||
@MyRequestBody OnlinePageDto onlinePageDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlinePage onlinePageFilter = MyModelUtil.copyTo(onlinePageDtoFilter, OnlinePage.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlinePage.class);
|
||||
List<OnlinePage> onlinePageList = onlinePageService.getOnlinePageListWithRelation(onlinePageFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlinePageList, OnlinePageVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统中配置的所有Page和表单的列表。
|
||||
*
|
||||
* @return 系统中配置的所有Page和表单的列表。
|
||||
*/
|
||||
@PostMapping("/listAllPageAndForm")
|
||||
public ResponseResult<JSONObject> listAllPageAndForm() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("pageList", onlinePageService.getOnlinePageList(null, null));
|
||||
List<OnlineForm> formList = onlineFormService.getOnlineFormList(null, null);
|
||||
formList.forEach(f -> f.setWidgetJson(null));
|
||||
jsonObject.put("formList", formList);
|
||||
return ResponseResult.success(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定在线表单页面对象详情。
|
||||
*
|
||||
* @param pageId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlinePageVo> view(@RequestParam Long pageId) {
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlinePage onlinePage = onlinePageService.getByIdWithRelation(pageId, MyRelationParam.full());
|
||||
if (onlinePage == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success(onlinePage, OnlinePageVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出与指定在线表单页面存在多对多关系的在线数据源列表数据。
|
||||
*
|
||||
* @param pageId 主表关联字段。
|
||||
* @param onlineDatasourceDtoFilter 在线数据源过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/listOnlinePageDatasource")
|
||||
public ResponseResult<MyPageData<OnlineDatasourceVo>> listOnlinePageDatasource(
|
||||
@MyRequestBody Long pageId,
|
||||
@MyRequestBody OnlineDatasourceDto onlineDatasourceDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineDatasource filter = MyModelUtil.copyTo(onlineDatasourceDtoFilter, OnlineDatasource.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineDatasource.class);
|
||||
List<OnlineDatasource> onlineDatasourceList =
|
||||
onlineDatasourceService.getOnlineDatasourceListByPageId(pageId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineDatasourceList, OnlineDatasourceVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加在线表单页面和在线数据源对象的多对多关联关系数据。
|
||||
*
|
||||
* @param pageId 主表主键Id。
|
||||
* @param onlinePageDatasourceDtoList 关联对象列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD_M2M)
|
||||
@PostMapping("/addOnlinePageDatasource")
|
||||
public ResponseResult<Void> addOnlinePageDatasource(
|
||||
@MyRequestBody Long pageId,
|
||||
@MyRequestBody(value = "onlinePageDatasourceList") List<OnlinePageDatasourceDto> onlinePageDatasourceDtoList) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (MyCommonUtil.existBlankArgument(onlinePageDatasourceDtoList)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
for (OnlinePageDatasourceDto onlinePageDatasource : onlinePageDatasourceDtoList) {
|
||||
errorMessage = MyCommonUtil.getModelValidationError(onlinePageDatasource);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
Set<Long> datasourceIdSet = onlinePageDatasourceDtoList.stream()
|
||||
.map(OnlinePageDatasourceDto::getDatasourceId).collect(Collectors.toSet());
|
||||
List<OnlineDatasource> datasourceList = onlineDatasourceService.getInList(datasourceIdSet);
|
||||
if (datasourceIdSet.size() != datasourceList.size()) {
|
||||
errorMessage = "数据验证失败,当前在线表单包含不存在的数据源Id!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
String appCode = TokenData.takeFromRequest().getAppCode();
|
||||
for (OnlineDatasource datasource : datasourceList) {
|
||||
if (!StrUtil.equals(datasource.getAppCode(), appCode)) {
|
||||
errorMessage = "数据验证失败,存在不是当前应用的数据源!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
List<OnlinePageDatasource> onlinePageDatasourceList =
|
||||
MyModelUtil.copyCollectionTo(onlinePageDatasourceDtoList, OnlinePageDatasource.class);
|
||||
onlinePageService.addOnlinePageDatasourceList(onlinePageDatasourceList, pageId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示在线表单页面和指定数据源的多对多关联详情数据。
|
||||
*
|
||||
* @param pageId 主表主键Id。
|
||||
* @param datasourceId 从表主键Id。
|
||||
* @return 应答结果对象,包括中间表详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/viewOnlinePageDatasource")
|
||||
public ResponseResult<OnlinePageDatasourceVo> viewOnlinePageDatasource(
|
||||
@RequestParam Long pageId, @RequestParam Long datasourceId) {
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlinePageDatasource onlinePageDatasource = onlinePageService.getOnlinePageDatasource(pageId, datasourceId);
|
||||
if (onlinePageDatasource == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
OnlinePageDatasourceVo onlinePageDatasourceVo =
|
||||
MyModelUtil.copyTo(onlinePageDatasource, OnlinePageDatasourceVo.class);
|
||||
return ResponseResult.success(onlinePageDatasourceVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定在线表单页面和指定数据源的多对多关联关系。
|
||||
*
|
||||
* @param pageId 主表主键Id。
|
||||
* @param datasourceId 从表主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE_M2M)
|
||||
@PostMapping("/deleteOnlinePageDatasource")
|
||||
public ResponseResult<Void> deleteOnlinePageDatasource(
|
||||
@MyRequestBody Long pageId, @MyRequestBody(required = true) Long datasourceId) {
|
||||
ResponseResult<OnlinePage> verifyResult = this.doVerifyAndGet(pageId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlinePageService.removeOnlinePageDatasource(pageId, datasourceId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
private ResponseResult<OnlinePage> doVerifyAndGet(Long pageId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(pageId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlinePage onlinePage = onlinePageService.getById(pageId);
|
||||
if (onlinePage == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
if (!StrUtil.equals(onlinePage.getAppCode(), tokenData.getAppCode())) {
|
||||
errorMessage = "数据验证失败,当前应用不存在该页面!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (ObjectUtil.notEqual(onlinePage.getTenantId(), tokenData.getTenantId())) {
|
||||
errorMessage = "数据验证失败,当前租户不包含该页面!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(onlinePage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.MyPageUtil;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineRuleDto;
|
||||
import com.orangeforms.common.online.model.OnlineRule;
|
||||
import com.orangeforms.common.online.service.OnlineRuleService;
|
||||
import com.orangeforms.common.online.vo.OnlineRuleVo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.groups.Default;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单字段验证规则接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单字段验证规则接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineRule")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineRuleController {
|
||||
|
||||
@Autowired
|
||||
private OnlineRuleService onlineRuleService;
|
||||
|
||||
/**
|
||||
* 新增验证规则数据。
|
||||
*
|
||||
* @param onlineRuleDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlineRuleDto.ruleId"})
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlineRuleDto onlineRuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineRuleDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineRule onlineRule = MyModelUtil.copyTo(onlineRuleDto, OnlineRule.class);
|
||||
onlineRule = onlineRuleService.saveNew(onlineRule);
|
||||
return ResponseResult.success(onlineRule.getRuleId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新验证规则数据。
|
||||
*
|
||||
* @param onlineRuleDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineRuleDto onlineRuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineRuleDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineRule onlineRule = MyModelUtil.copyTo(onlineRuleDto, OnlineRule.class);
|
||||
ResponseResult<OnlineRule> verifyResult = this.doVerifyAndGet(onlineRule.getRuleId(), false);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineRule originalOnlineRule = verifyResult.getData();
|
||||
if (!onlineRuleService.update(onlineRule, originalOnlineRule)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除验证规则数据。
|
||||
*
|
||||
* @param ruleId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long ruleId) {
|
||||
String errorMessage;
|
||||
ResponseResult<OnlineRule> verifyResult = this.doVerifyAndGet(ruleId, false);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlineRuleService.remove(ruleId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的验证规则列表。
|
||||
*
|
||||
* @param onlineRuleDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineRuleVo>> list(
|
||||
@MyRequestBody OnlineRuleDto onlineRuleDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineRule onlineRuleFilter = MyModelUtil.copyTo(onlineRuleDtoFilter, OnlineRule.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineRule.class);
|
||||
List<OnlineRule> onlineRuleList = onlineRuleService.getOnlineRuleListWithRelation(onlineRuleFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(onlineRuleList, OnlineRuleVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定验证规则对象详情。
|
||||
*
|
||||
* @param ruleId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineRuleVo> view(@RequestParam Long ruleId) {
|
||||
ResponseResult<OnlineRule> verifyResult = this.doVerifyAndGet(ruleId, true);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
OnlineRule onlineRule = verifyResult.getData();
|
||||
return ResponseResult.success(onlineRule, OnlineRuleVo.class);
|
||||
}
|
||||
|
||||
private ResponseResult<OnlineRule> doVerifyAndGet(Long ruleId, boolean readOnly) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(ruleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
OnlineRule rule = onlineRuleService.getById(ruleId);
|
||||
if (rule == null) {
|
||||
errorMessage = "数据验证失败,当前在线字段规则并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!readOnly && BooleanUtil.isTrue(rule.getBuiltin())) {
|
||||
errorMessage = "数据验证失败,内置规则不能删除!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!StrUtil.equals(rule.getAppCode(), TokenData.takeFromRequest().getAppCode())) {
|
||||
errorMessage = "数据验证失败,当前应用并不包含该规则!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
return ResponseResult.success(rule);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package com.orangeforms.common.online.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orangeforms.common.core.object.*;
|
||||
import com.orangeforms.common.core.util.*;
|
||||
import com.orangeforms.common.core.constant.*;
|
||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.log.annotation.OperationLog;
|
||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
||||
import com.orangeforms.common.online.dto.OnlineVirtualColumnDto;
|
||||
import com.orangeforms.common.online.model.OnlineVirtualColumn;
|
||||
import com.orangeforms.common.online.model.constant.VirtualType;
|
||||
import com.orangeforms.common.online.service.OnlineVirtualColumnService;
|
||||
import com.orangeforms.common.online.vo.OnlineVirtualColumnVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 在线表单虚拟字段接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Tag(name = "在线表单虚拟字段接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("${common-online.urlPrefix}/onlineVirtualColumn")
|
||||
@ConditionalOnProperty(name = "common-online.operationEnabled", havingValue = "true")
|
||||
public class OnlineVirtualColumnController {
|
||||
|
||||
@Autowired
|
||||
private OnlineVirtualColumnService onlineVirtualColumnService;
|
||||
|
||||
/**
|
||||
* 新增虚拟字段数据。
|
||||
*
|
||||
* @param onlineVirtualColumnDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"onlineVirtualColumnDto.virtualColumnId"})
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@OperationLog(type = SysOperationLogType.ADD)
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(onlineVirtualColumnDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineVirtualColumn onlineVirtualColumn =
|
||||
MyModelUtil.copyTo(onlineVirtualColumnDto, OnlineVirtualColumn.class);
|
||||
ResponseResult<Void> verifyResult = this.doVerify(onlineVirtualColumn, null);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
onlineVirtualColumn = onlineVirtualColumnService.saveNew(onlineVirtualColumn);
|
||||
return ResponseResult.success(onlineVirtualColumn.getVirtualColumnId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新虚拟字段数据。
|
||||
*
|
||||
* @param onlineVirtualColumnDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(
|
||||
onlineVirtualColumnDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
OnlineVirtualColumn onlineVirtualColumn =
|
||||
MyModelUtil.copyTo(onlineVirtualColumnDto, OnlineVirtualColumn.class);
|
||||
OnlineVirtualColumn originalOnlineVirtualColumn =
|
||||
onlineVirtualColumnService.getById(onlineVirtualColumn.getVirtualColumnId());
|
||||
if (originalOnlineVirtualColumn == null) {
|
||||
errorMessage = "数据验证失败,当前虚拟字段并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
ResponseResult<Void> verifyResult = this.doVerify(onlineVirtualColumn, originalOnlineVirtualColumn);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (!onlineVirtualColumnService.update(onlineVirtualColumn, originalOnlineVirtualColumn)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除虚拟字段数据。
|
||||
*
|
||||
* @param virtualColumnId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@OperationLog(type = SysOperationLogType.DELETE)
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long virtualColumnId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(virtualColumnId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
OnlineVirtualColumn originalOnlineVirtualColumn = onlineVirtualColumnService.getById(virtualColumnId);
|
||||
if (originalOnlineVirtualColumn == null) {
|
||||
errorMessage = "数据验证失败,当前虚拟字段并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!onlineVirtualColumnService.remove(virtualColumnId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的虚拟字段列表。
|
||||
*
|
||||
* @param onlineVirtualColumnDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<OnlineVirtualColumnVo>> list(
|
||||
@MyRequestBody OnlineVirtualColumnDto onlineVirtualColumnDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
OnlineVirtualColumn onlineVirtualColumnFilter =
|
||||
MyModelUtil.copyTo(onlineVirtualColumnDtoFilter, OnlineVirtualColumn.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineVirtualColumn.class);
|
||||
List<OnlineVirtualColumn> onlineVirtualColumnList =
|
||||
onlineVirtualColumnService.getOnlineVirtualColumnListWithRelation(onlineVirtualColumnFilter, orderBy);
|
||||
MyPageData<OnlineVirtualColumnVo> pageData =
|
||||
MyPageUtil.makeResponseData(onlineVirtualColumnList, OnlineVirtualColumnVo.class);
|
||||
return ResponseResult.success(pageData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定虚拟字段对象详情。
|
||||
*
|
||||
* @param virtualColumnId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@SaCheckPermission("onlinePage.all")
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<OnlineVirtualColumnVo> view(@RequestParam Long virtualColumnId) {
|
||||
if (MyCommonUtil.existBlankArgument(virtualColumnId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
OnlineVirtualColumn onlineVirtualColumn =
|
||||
onlineVirtualColumnService.getByIdWithRelation(virtualColumnId, MyRelationParam.full());
|
||||
if (onlineVirtualColumn == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success(onlineVirtualColumn, OnlineVirtualColumnVo.class);
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doVerify(
|
||||
OnlineVirtualColumn virtualColumn, OnlineVirtualColumn originalVirtualColumn) {
|
||||
if (!virtualColumn.getVirtualType().equals(VirtualType.AGGREGATION)) {
|
||||
return ResponseResult.success();
|
||||
}
|
||||
if (MyCommonUtil.existBlankArgument(
|
||||
virtualColumn.getAggregationColumnId(),
|
||||
virtualColumn.getAggregationTableId(),
|
||||
virtualColumn.getDatasourceId(),
|
||||
virtualColumn.getRelationId(),
|
||||
virtualColumn.getAggregationType())) {
|
||||
String errorMessage = "数据验证失败,数据源、关联关系、聚合表、聚合字段和聚合类型,均不能为空!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
CallResult verifyResult = onlineVirtualColumnService.verifyRelatedData(virtualColumn, originalVirtualColumn);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字段数据数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineColumnMapper extends BaseDaoMapper<OnlineColumn> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineColumnFilter 主表过滤对象。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineColumn> getOnlineColumnList(@Param("onlineColumnFilter") OnlineColumn onlineColumnFilter);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineColumnRule;
|
||||
|
||||
/**
|
||||
* 数据字段规则访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineColumnRuleMapper extends BaseDaoMapper<OnlineColumnRule> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDatasource;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据模型数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDatasourceMapper extends BaseDaoMapper<OnlineDatasource> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineDatasourceFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceList(
|
||||
@Param("onlineDatasourceFilter") OnlineDatasource onlineDatasourceFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表数据列表。
|
||||
*
|
||||
* @param pageId 关联主表Id。
|
||||
* @param onlineDatasourceFilter 从表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 从表数据列表。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceListByPageId(
|
||||
@Param("pageId") Long pageId,
|
||||
@Param("onlineDatasourceFilter") OnlineDatasource onlineDatasourceFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据在线表单Id集合,获取关联的在线数据源对象列表。
|
||||
*
|
||||
* @param formIdSet 在线表单Id集合。
|
||||
* @return 与参数表单Id关联的数据源列表。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceListByFormIds(@Param("formIdSet") Set<Long> formIdSet);
|
||||
|
||||
/**
|
||||
* 获取在线表单页面和在线表单数据源变量名的映射关系。
|
||||
*
|
||||
* @param pageIds 页面Id集合。
|
||||
* @return 在线表单页面和在线表单数据源变量名的映射关系。
|
||||
*/
|
||||
@Select("SELECT a.page_id, b.variable_name FROM zz_online_page_datasource a, zz_online_datasource b" +
|
||||
" WHERE a.page_id in (${pageIds}) AND a.datasource_id = b.datasource_id")
|
||||
List<Map<String, Object>> getPageIdAndVariableNameMapByPageIds(@Param("pageIds") String pageIds);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceRelation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据关联数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDatasourceRelationMapper extends BaseDaoMapper<OnlineDatasourceRelation> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineDatasourceRelation> getOnlineDatasourceRelationList(
|
||||
@Param("filter") OnlineDatasourceRelation filter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceTable;
|
||||
|
||||
/**
|
||||
* 数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDatasourceTableMapper extends BaseDaoMapper<OnlineDatasourceTable> {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDblink;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库链接数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDblinkMapper extends BaseDaoMapper<OnlineDblink> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineDblinkFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineDblink> getOnlineDblinkList(
|
||||
@Param("onlineDblinkFilter") OnlineDblink onlineDblinkFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDict;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单字典数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDictMapper extends BaseDaoMapper<OnlineDict> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineDictFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineDict> getOnlineDictList(
|
||||
@Param("onlineDictFilter") OnlineDict onlineDictFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineFormDatasource;
|
||||
|
||||
/**
|
||||
* 在线表单与数据源多对多关联的数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineFormDatasourceMapper extends BaseDaoMapper<OnlineFormDatasource> {
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineForm;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineFormMapper extends BaseDaoMapper<OnlineForm> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineFormFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormList(
|
||||
@Param("onlineFormFilter") OnlineForm onlineFormFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据数据源Id,返回使用该数据源的OnlineForm对象。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @param onlineFormFilter 主表过滤对象。
|
||||
* @return 使用该数据源的表单列表。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormListByDatasourceId(
|
||||
@Param("datasourceId") Long datasourceId, @Param("onlineFormFilter") OnlineForm onlineFormFilter);
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.online.dto.OnlineFilterDto;
|
||||
import com.orangeforms.common.online.object.ColumnData;
|
||||
import com.orangeforms.common.online.object.JoinTableInfo;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单运行时数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Mapper
|
||||
public interface OnlineOperationMapper {
|
||||
|
||||
/**
|
||||
* 插入新数据。
|
||||
*
|
||||
* @param tableName 数据表名。
|
||||
* @param columnNames 字段名列表。
|
||||
* @param columnValueList 字段值列表。
|
||||
*/
|
||||
@Insert("<script>"
|
||||
+ "INSERT INTO ${tableName} (${columnNames}) VALUES "
|
||||
+ " <foreach collection=\"columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ "</script>")
|
||||
void insert(
|
||||
@Param("tableName") String tableName,
|
||||
@Param("columnNames") String columnNames,
|
||||
@Param("columnValueList") List<Object> columnValueList);
|
||||
|
||||
/**
|
||||
* 更新表数据。
|
||||
*
|
||||
* @param tableName 数据表名。
|
||||
* @param updateColumnList 更新字段列表。
|
||||
* @param filterList SQL过滤条件列表。
|
||||
* @param dataPermFilter 数据权限过滤字符串。
|
||||
* @return 更新行数。
|
||||
*/
|
||||
@Update("<script>"
|
||||
+ "UPDATE ${tableName} SET "
|
||||
+ " <foreach collection=\"updateColumnList\" item=\"columnData\" separator=\",\" >"
|
||||
+ " <if test=\"columnData.columnValue != null\">"
|
||||
+ " ${columnData.column.columnName} = #{columnData.columnValue} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"columnData.columnValue == null\">"
|
||||
+ " ${columnData.column.columnName} = NULL "
|
||||
+ " </if>"
|
||||
+ " </foreach>"
|
||||
+ "<where>"
|
||||
+ " <if test=\"filterList != null\">"
|
||||
+ " <foreach collection=\"filterList\" item=\"filter\">"
|
||||
+ " <if test=\"filter.filterType == 1\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} = #{filter.columnValue} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 4\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} IN "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 6\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} NOT IN "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"dataPermFilter != null and dataPermFilter != ''\">"
|
||||
+ " AND ${dataPermFilter} "
|
||||
+ " </if>"
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
int update(
|
||||
@Param("tableName") String tableName,
|
||||
@Param("updateColumnList") List<ColumnData> updateColumnList,
|
||||
@Param("filterList") List<OnlineFilterDto> filterList,
|
||||
@Param("dataPermFilter") String dataPermFilter);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param tableName 表名。
|
||||
* @param filterList SQL过滤条件列表。
|
||||
* @param dataPermFilter 数据权限过滤字符串。
|
||||
* @return 删除行数。
|
||||
*/
|
||||
@Delete("<script>"
|
||||
+ "DELETE FROM ${tableName} "
|
||||
+ "<where>"
|
||||
+ " <if test=\"filterList != null\">"
|
||||
+ " <foreach collection=\"filterList\" item=\"filter\">"
|
||||
+ " <if test=\"filter.filterType == 1\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} = #{filter.columnValue} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 4\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} IN "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 6\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} NOT IN "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"dataPermFilter != null and dataPermFilter != ''\">"
|
||||
+ " AND ${dataPermFilter}"
|
||||
+ " </if>"
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
int delete(
|
||||
@Param("tableName") String tableName,
|
||||
@Param("filterList") List<OnlineFilterDto> filterList,
|
||||
@Param("dataPermFilter") String dataPermFilter);
|
||||
|
||||
/**
|
||||
* 执行动态查询,并返回查询结果集。
|
||||
*
|
||||
* @param masterTableName 主表名称。
|
||||
* @param joinInfoList 关联表信息列表。
|
||||
* @param selectFields 返回字段列表,逗号分隔。
|
||||
* @param filterList SQL过滤条件列表。
|
||||
* @param dataPermFilter 数据权限过滤字符串。
|
||||
* @param orderBy 排序字符串。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Select("<script>"
|
||||
+ "SELECT ${selectFields} FROM ${masterTableName} "
|
||||
+ "<if test=\"joinInfoList != null\">"
|
||||
+ " <foreach collection=\"joinInfoList\" item=\"joinInfo\">"
|
||||
+ " <if test=\"joinInfo.leftJoin\">"
|
||||
+ " LEFT JOIN ${joinInfo.joinTableName} ON ${joinInfo.joinCondition}"
|
||||
+ " </if>"
|
||||
+ " <if test=\"!joinInfo.leftJoin\">"
|
||||
+ " INNER JOIN ${joinInfo.joinTableName} ON ${joinInfo.joinCondition}"
|
||||
+ " </if>"
|
||||
+ " </foreach>"
|
||||
+ "</if>"
|
||||
+ "<where>"
|
||||
+ " <if test=\"filterList != null\">"
|
||||
+ " <foreach collection=\"filterList\" item=\"filter\">"
|
||||
+ " <if test=\"filter.filterType == 1\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} = #{filter.columnValue} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 2\">"
|
||||
+ " <if test=\"filter.columnValueStart != null and filter.columnValueStart != ''\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} >= #{filter.columnValueStart} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.columnValueEnd != null and filter.columnValueEnd != ''\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} <= #{filter.columnValueEnd} "
|
||||
+ " </if>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 3\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} LIKE #{filter.columnValue} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 4\">"
|
||||
+ " AND ${filter.tableName}.${filter.columnName} IN "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 5\">"
|
||||
+ " AND "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\" OR \" open=\"(\" close=\")\">"
|
||||
+ " ${filter.tableName}.${filter.columnName} LIKE #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"dataPermFilter != null and dataPermFilter != ''\">"
|
||||
+ " AND ${dataPermFilter} "
|
||||
+ " </if>"
|
||||
+ "</where>"
|
||||
+ "<if test=\"orderBy != null and orderBy != ''\">"
|
||||
+ " ORDER BY ${orderBy}"
|
||||
+ "</if>"
|
||||
+ "</script>")
|
||||
List<Map<String, Object>> getList(
|
||||
@Param("masterTableName") String masterTableName,
|
||||
@Param("joinInfoList") List<JoinTableInfo> joinInfoList,
|
||||
@Param("selectFields") String selectFields,
|
||||
@Param("filterList") List<OnlineFilterDto> filterList,
|
||||
@Param("dataPermFilter") String dataPermFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 以字典键值对的方式返回数据。
|
||||
*
|
||||
* @param tableName 表名称。
|
||||
* @param selectFields 返回字段列表,逗号分隔。
|
||||
* @param filterList SQL过滤条件列表。
|
||||
* @param dataPermFilter 数据权限过滤字符串。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Select("<script>"
|
||||
+ "SELECT ${selectFields} FROM ${tableName} "
|
||||
+ "<where>"
|
||||
+ " <if test=\"filterList != null\">"
|
||||
+ " <foreach collection=\"filterList\" item=\"filter\">"
|
||||
+ " <if test=\"filter.filterType == 1\">"
|
||||
+ " AND ${filter.columnName} = #{filter.columnValue} "
|
||||
+ " </if>"
|
||||
+ " <if test=\"filter.filterType == 4\">"
|
||||
+ " AND ${filter.columnName} IN "
|
||||
+ " <foreach collection=\"filter.columnValueList\" item=\"columnValue\" separator=\",\" open=\"(\" close=\")\">"
|
||||
+ " #{columnValue} "
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " </foreach>"
|
||||
+ " </if>"
|
||||
+ " <if test=\"dataPermFilter != null and dataPermFilter != ''\">"
|
||||
+ " AND ${dataPermFilter} "
|
||||
+ " </if>"
|
||||
+ "</where>"
|
||||
+ "</script>")
|
||||
List<Map<String, Object>> getDictList(
|
||||
@Param("tableName") String tableName,
|
||||
@Param("selectFields") String selectFields,
|
||||
@Param("filterList") List<OnlineFilterDto> filterList,
|
||||
@Param("dataPermFilter") String dataPermFilter);
|
||||
|
||||
/**
|
||||
* 根据指定的表名、显示字段列表、过滤条件字符串和分组字段,返回聚合计算后的查询结果。
|
||||
*
|
||||
* @param selectTable 表名称。
|
||||
* @param selectFields 返回字段列表,逗号分隔。
|
||||
* @param whereClause SQL常量形式的条件从句。
|
||||
* @param groupBy 分组字段列表,逗号分隔。
|
||||
* @return 对象可选字段Map列表。
|
||||
*/
|
||||
@Select("<script>"
|
||||
+ "SELECT ${selectFields} FROM ${selectTable}"
|
||||
+ "<where>"
|
||||
+ " <if test=\"whereClause != null and whereClause != ''\">"
|
||||
+ " AND ${whereClause}"
|
||||
+ " </if>"
|
||||
+ "</where>"
|
||||
+ "<if test=\"groupBy != null and groupBy != ''\">"
|
||||
+ " GROUP BY ${groupBy}"
|
||||
+ "</if>"
|
||||
+ "</script>")
|
||||
List<Map<String, Object>> getGroupedListByCondition(
|
||||
@Param("selectTable") String selectTable,
|
||||
@Param("selectFields") String selectFields,
|
||||
@Param("whereClause") String whereClause,
|
||||
@Param("groupBy") String groupBy);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlinePageDatasource;
|
||||
|
||||
/**
|
||||
* 在线表单页面和数据源关联对象的数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlinePageDatasourceMapper extends BaseDaoMapper<OnlinePageDatasource> {
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlinePage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单页面数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlinePageMapper extends BaseDaoMapper<OnlinePage> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlinePageFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlinePage> getOnlinePageList(
|
||||
@Param("onlinePageFilter") OnlinePage onlinePageFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 根据数据源Id,返回使用该数据源的OnlinePage对象。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @return 使用该数据源的页面列表。
|
||||
*/
|
||||
List<OnlinePage> getOnlinePageListByDatasourceId(
|
||||
@Param("datasourceId") Long datasourceId, @Param("onlinePageFilter") OnlinePage onlinePageFilter);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineRule;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 验证规则数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineRuleMapper extends BaseDaoMapper<OnlineRule> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineRuleFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineRule> getOnlineRuleList(
|
||||
@Param("onlineRuleFilter") OnlineRule onlineRuleFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表数据列表。
|
||||
*
|
||||
* @param columnId 关联主表Id。
|
||||
* @param onlineRuleFilter 从表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 从表数据列表。
|
||||
*/
|
||||
List<OnlineRule> getOnlineRuleListByColumnId(
|
||||
@Param("columnId") Long columnId,
|
||||
@Param("onlineRuleFilter") OnlineRule onlineRuleFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。
|
||||
*
|
||||
* @param columnId 关联主表Id。
|
||||
* @param onlineRuleFilter 过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 与主表没有建立关联的从表数据列表。
|
||||
*/
|
||||
List<OnlineRule> getNotInOnlineRuleListByColumnId(
|
||||
@Param("columnId") Long columnId,
|
||||
@Param("onlineRuleFilter") OnlineRule onlineRuleFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineTable;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据表数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineTableMapper extends BaseDaoMapper<OnlineTable> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineTableFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineTable> getOnlineTableList(
|
||||
@Param("onlineTableFilter") OnlineTable onlineTableFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据数据源Id,获取该数据源及其关联所引用的数据表列表。
|
||||
*
|
||||
* @param datasourceId 指定的数据源Id。
|
||||
* @return 该数据源及其关联所引用的数据表列表。
|
||||
*/
|
||||
List<OnlineTable> getOnlineTableListByDatasourceId(@Param("datasourceId") Long datasourceId);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orangeforms.common.online.dao;
|
||||
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.online.model.OnlineVirtualColumn;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 虚拟字段数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineVirtualColumnMapper extends BaseDaoMapper<OnlineVirtualColumn> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param onlineVirtualColumnFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<OnlineVirtualColumn> getOnlineVirtualColumnList(
|
||||
@Param("onlineVirtualColumnFilter") OnlineVirtualColumn onlineVirtualColumnFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineColumnMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineColumn">
|
||||
<id column="column_id" jdbcType="BIGINT" property="columnId"/>
|
||||
<result column="column_name" jdbcType="VARCHAR" property="columnName"/>
|
||||
<result column="table_id" jdbcType="BIGINT" property="tableId"/>
|
||||
<result column="column_type" jdbcType="VARCHAR" property="columnType"/>
|
||||
<result column="full_column_type" jdbcType="VARCHAR" property="fullColumnType"/>
|
||||
<result column="primary_key" jdbcType="BOOLEAN" property="primaryKey"/>
|
||||
<result column="auto_incr" jdbcType="BOOLEAN" property="autoIncrement"/>
|
||||
<result column="nullable" jdbcType="BOOLEAN" property="nullable"/>
|
||||
<result column="column_default" jdbcType="VARCHAR" property="columnDefault"/>
|
||||
<result column="column_show_order" jdbcType="INTEGER" property="columnShowOrder"/>
|
||||
<result column="column_comment" jdbcType="VARCHAR" property="columnComment"/>
|
||||
<result column="object_field_name" jdbcType="VARCHAR" property="objectFieldName"/>
|
||||
<result column="object_field_type" jdbcType="VARCHAR" property="objectFieldType"/>
|
||||
<result column="numeric_precision" jdbcType="INTEGER" property="numericPrecision"/>
|
||||
<result column="numeric_scale" jdbcType="INTEGER" property="numericScale"/>
|
||||
<result column="filter_type" jdbcType="INTEGER" property="filterType"/>
|
||||
<result column="parent_key" jdbcType="BOOLEAN" property="parentKey"/>
|
||||
<result column="dept_filter" jdbcType="BOOLEAN" property="deptFilter"/>
|
||||
<result column="user_filter" jdbcType="BOOLEAN" property="userFilter"/>
|
||||
<result column="field_kind" jdbcType="INTEGER" property="fieldKind"/>
|
||||
<result column="max_file_count" jdbcType="INTEGER" property="maxFileCount"/>
|
||||
<result column="upload_file_system_type" jdbcType="INTEGER" property="uploadFileSystemType"/>
|
||||
<result column="encoded_rule" jdbcType="VARCHAR" property="encodedRule"/>
|
||||
<result column="mask_field_type" jdbcType="VARCHAR" property="maskFieldType"/>
|
||||
<result column="dict_id" jdbcType="BIGINT" property="dictId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineColumnMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineColumnFilter != null">
|
||||
<if test="onlineColumnFilter.tableId != null">
|
||||
AND zz_online_column.table_id = #{onlineColumnFilter.tableId}
|
||||
</if>
|
||||
<if test="onlineColumnFilter.columnName != null and onlineColumnFilter.columnName != ''">
|
||||
AND zz_online_column.column_name = #{onlineColumnFilter.columnName}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineColumnList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineColumn">
|
||||
SELECT * FROM zz_online_column
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
ORDER BY column_show_order
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineColumnRuleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineColumnRule">
|
||||
<id column="column_id" jdbcType="BIGINT" property="columnId"/>
|
||||
<id column="rule_id" jdbcType="BIGINT" property="ruleId"/>
|
||||
<result column="prop_data_json" jdbcType="LONGVARCHAR" property="propDataJson"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineDatasourceMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineDatasource">
|
||||
<id column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="datasource_name" jdbcType="VARCHAR" property="datasourceName"/>
|
||||
<result column="variable_name" jdbcType="VARCHAR" property="variableName"/>
|
||||
<result column="dblink_id" jdbcType="BIGINT" property="dblinkId"/>
|
||||
<result column="master_table_id" jdbcType="BIGINT" property="masterTableId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="BaseResultMapWithOnlinePageDatasource" type="com.orangeforms.common.online.model.OnlineDatasource" extends="BaseResultMap">
|
||||
<association property="onlinePageDatasource" column="datasource_id" foreignColumn="datasource_id"
|
||||
notNullColumn="datasource_id" resultMap="com.orangeforms.common.online.dao.OnlinePageDatasourceMapper.BaseResultMap" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="BaseResultMapWithOnlineFormDatasource" type="com.orangeforms.common.online.model.OnlineDatasource" extends="BaseResultMap">
|
||||
<collection property="onlineFormDatasourceList" column="datasource_id" foreignColumn="datasource_id" javaType="ArrayList"
|
||||
ofType="com.orangeforms.common.online.model.OnlineFormDatasource"
|
||||
notNullColumn="form_id" resultMap="com.orangeforms.common.online.dao.OnlineFormDatasourceMapper.BaseResultMap" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineDatasourceMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineDatasourceFilter != null">
|
||||
<if test="onlineDatasourceFilter.appCode == null">
|
||||
AND zz_online_datasource.app_code IS NULL
|
||||
</if>
|
||||
<if test="onlineDatasourceFilter.appCode != null">
|
||||
AND zz_online_datasource.app_code = #{onlineDatasourceFilter.appCode}
|
||||
</if>
|
||||
<if test="onlineDatasourceFilter.variableName != null and onlineDatasourceFilter.variableName != ''">
|
||||
AND zz_online_datasource.variable_name = #{onlineDatasourceFilter.variableName}
|
||||
</if>
|
||||
<if test="onlineDatasourceFilter.datasourceName != null and onlineDatasourceFilter.datasourceName != ''">
|
||||
AND zz_online_datasource.datasource_name = #{onlineDatasourceFilter.datasourceName}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineDatasourceList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineDatasource">
|
||||
SELECT * FROM zz_online_datasource
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getOnlineDatasourceListByPageId" resultMap="BaseResultMapWithOnlinePageDatasource">
|
||||
SELECT
|
||||
zz_online_datasource.*,
|
||||
zz_online_page_datasource.*
|
||||
FROM
|
||||
zz_online_datasource,
|
||||
zz_online_page_datasource
|
||||
<where>
|
||||
AND zz_online_page_datasource.page_id = #{pageId}
|
||||
AND zz_online_page_datasource.datasource_id = zz_online_datasource.datasource_id
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getOnlineDatasourceListByFormIds" resultMap="BaseResultMapWithOnlineFormDatasource">
|
||||
SELECT
|
||||
zz_online_datasource.*,
|
||||
zz_online_form_datasource.*
|
||||
FROM
|
||||
zz_online_datasource, zz_online_form_datasource
|
||||
<where>
|
||||
AND zz_online_form_datasource.datasource_id = zz_online_datasource.datasource_id
|
||||
AND zz_online_form_datasource.form_id IN
|
||||
<foreach collection="formIdSet" item="formId" separator="," open="(" close=")">
|
||||
#{formId}
|
||||
</foreach>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineDatasourceRelationMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineDatasourceRelation">
|
||||
<id column="relation_id" jdbcType="BIGINT" property="relationId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="relation_name" jdbcType="VARCHAR" property="relationName"/>
|
||||
<result column="variable_name" jdbcType="VARCHAR" property="variableName"/>
|
||||
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
|
||||
<result column="relation_type" jdbcType="INTEGER" property="relationType"/>
|
||||
<result column="master_column_id" jdbcType="BIGINT" property="masterColumnId"/>
|
||||
<result column="slave_table_id" jdbcType="BIGINT" property="slaveTableId"/>
|
||||
<result column="slave_column_id" jdbcType="BIGINT" property="slaveColumnId"/>
|
||||
<result column="cascade_delete" jdbcType="BOOLEAN" property="cascadeDelete"/>
|
||||
<result column="left_join" jdbcType="BOOLEAN" property="leftJoin"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineDatasourceRelationMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="filter != null">
|
||||
<if test="filter.appCode == null">
|
||||
AND zz_online_datasource_relation.app_code IS NULL
|
||||
</if>
|
||||
<if test="filter.appCode != null">
|
||||
AND zz_online_datasource_relation.app_code = #{filter.appCode}
|
||||
</if>
|
||||
<if test="filter.relationName != null and filter.relationName != ''">
|
||||
AND zz_online_datasource_relation.relation_name = #{filter.relationName}
|
||||
</if>
|
||||
<if test="filter.datasourceId != null">
|
||||
AND zz_online_datasource_relation.datasource_id = #{filter.datasourceId}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineDatasourceRelationList" resultMap="BaseResultMap"
|
||||
parameterType="com.orangeforms.common.online.model.OnlineDatasourceRelation">
|
||||
SELECT * FROM zz_online_datasource_relation
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineDatasourceTableMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineDatasourceTable">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
|
||||
<result column="relation_id" jdbcType="BIGINT" property="relationId"/>
|
||||
<result column="table_id" jdbcType="BIGINT" property="tableId"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineDblinkMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineDblink">
|
||||
<id column="dblink_id" jdbcType="BIGINT" property="dblinkId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="dblink_name" jdbcType="VARCHAR" property="dblinkName"/>
|
||||
<result column="dblink_description" jdbcType="VARCHAR" property="dblinkDescription"/>
|
||||
<result column="configuration" jdbcType="VARCHAR" property="configuration"/>
|
||||
<result column="dblink_type" jdbcType="INTEGER" property="dblinkType"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineDblinkMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineDblinkFilter != null">
|
||||
<if test="onlineDblinkFilter.appCode == null">
|
||||
AND zz_online_dblink.app_code IS NULL
|
||||
</if>
|
||||
<if test="onlineDblinkFilter.appCode != null">
|
||||
AND zz_online_dblink.app_code = #{onlineDblinkFilter.appCode}
|
||||
</if>
|
||||
<if test="onlineDblinkFilter.dblinkType != null">
|
||||
AND zz_online_dblink.dblink_type = #{onlineDblinkFilter.dblinkType}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineDblinkList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineDblink">
|
||||
SELECT * FROM zz_online_dblink
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineDictMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineDict">
|
||||
<id column="dict_id" jdbcType="BIGINT" property="dictId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="dict_name" jdbcType="VARCHAR" property="dictName"/>
|
||||
<result column="dict_type" jdbcType="INTEGER" property="dictType"/>
|
||||
<result column="dblink_id" jdbcType="BIGINT" property="dblinkId"/>
|
||||
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
|
||||
<result column="dict_code" jdbcType="VARCHAR" property="dictCode"/>
|
||||
<result column="key_column_name" jdbcType="VARCHAR" property="keyColumnName"/>
|
||||
<result column="parent_key_column_name" jdbcType="VARCHAR" property="parentKeyColumnName"/>
|
||||
<result column="value_column_name" jdbcType="VARCHAR" property="valueColumnName"/>
|
||||
<result column="deleted_column_name" jdbcType="VARCHAR" property="deletedColumnName"/>
|
||||
<result column="user_filter_column_name" jdbcType="VARCHAR" property="userFilterColumnName"/>
|
||||
<result column="dept_filter_column_name" jdbcType="VARCHAR" property="deptFilterColumnName"/>
|
||||
<result column="tenant_filter_column_name" jdbcType="VARCHAR" property="tenantFilterColumnName"/>
|
||||
<result column="tree_flag" jdbcType="BOOLEAN" property="treeFlag"/>
|
||||
<result column="dict_list_url" jdbcType="VARCHAR" property="dictListUrl"/>
|
||||
<result column="dict_ids_url" jdbcType="VARCHAR" property="dictIdsUrl"/>
|
||||
<result column="dict_data_json" jdbcType="LONGVARCHAR" property="dictDataJson"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineDictMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineDictFilter != null">
|
||||
<if test="onlineDictFilter.dictId != null">
|
||||
AND zz_online_dict.dict_id = #{onlineDictFilter.dictId}
|
||||
</if>
|
||||
<if test="onlineDictFilter.appCode == null">
|
||||
AND zz_online_dict.app_code IS NULL
|
||||
</if>
|
||||
<if test="onlineDictFilter.appCode != null">
|
||||
AND zz_online_dict.app_code = #{onlineDictFilter.appCode}
|
||||
</if>
|
||||
<if test="onlineDictFilter.dictName != null and onlineDictFilter.dictName != ''">
|
||||
AND zz_online_dict.dict_name = #{onlineDictFilter.dictName}
|
||||
</if>
|
||||
<if test="onlineDictFilter.dictType != null">
|
||||
AND zz_online_dict.dict_type = #{onlineDictFilter.dictType}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineDictList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineDict">
|
||||
SELECT * FROM zz_online_dict
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineFormDatasourceMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineFormDatasource">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="form_id" jdbcType="BIGINT" property="formId"/>
|
||||
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineFormMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineForm">
|
||||
<id column="form_id" jdbcType="BIGINT" property="formId"/>
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="page_id" jdbcType="BIGINT" property="pageId"/>
|
||||
<result column="form_code" jdbcType="VARCHAR" property="formCode"/>
|
||||
<result column="form_name" jdbcType="VARCHAR" property="formName"/>
|
||||
<result column="form_kind" jdbcType="INTEGER" property="formKind"/>
|
||||
<result column="form_type" jdbcType="INTEGER" property="formType"/>
|
||||
<result column="master_table_id" jdbcType="BIGINT" property="masterTableId"/>
|
||||
<result column="widget_json" jdbcType="LONGVARCHAR" property="widgetJson"/>
|
||||
<result column="params_json" jdbcType="LONGVARCHAR" property="paramsJson"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineFormMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineFormFilter != null">
|
||||
<if test="onlineFormFilter.tenantId == null">
|
||||
AND zz_online_form.tenant_id IS NULL
|
||||
</if>
|
||||
<if test="onlineFormFilter.tenantId != null">
|
||||
AND zz_online_form.tenant_id = #{onlineFormFilter.tenantId}
|
||||
</if>
|
||||
<if test="onlineFormFilter.appCode == null">
|
||||
AND zz_online_form.app_code IS NULL
|
||||
</if>
|
||||
<if test="onlineFormFilter.appCode != null">
|
||||
AND zz_online_form.app_code = #{onlineFormFilter.appCode}
|
||||
</if>
|
||||
<if test="onlineFormFilter.pageId != null">
|
||||
AND zz_online_form.page_id = #{onlineFormFilter.pageId}
|
||||
</if>
|
||||
<if test="onlineFormFilter.formCode != null and onlineFormFilter.formCode != ''">
|
||||
AND zz_online_form.form_code = #{onlineFormFilter.formCode}
|
||||
</if>
|
||||
<if test="onlineFormFilter.formName != null and onlineFormFilter.formName != ''">
|
||||
<bind name= "safeFormName" value= "'%' + onlineFormFilter.formName + '%'"/>
|
||||
AND zz_online_form.form_name LIKE #{safeFormName}
|
||||
</if>
|
||||
<if test="onlineFormFilter.formType != null">
|
||||
AND zz_online_form.form_type = #{onlineFormFilter.formType}
|
||||
</if>
|
||||
<if test="onlineFormFilter.masterTableId != null">
|
||||
AND zz_online_form.master_table_id = #{onlineFormFilter.masterTableId}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineFormList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineForm">
|
||||
SELECT * FROM zz_online_form
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getOnlineFormListByDatasourceId" resultMap="BaseResultMap">
|
||||
SELECT a.* FROM zz_online_form a, zz_online_form_datasource b
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
AND b.datasource_id = #{datasourceI} AND b.form_id = a.form_id
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlinePageDatasourceMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlinePageDatasource">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="page_id" jdbcType="BIGINT" property="pageId"/>
|
||||
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlinePageMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlinePage">
|
||||
<id column="page_id" jdbcType="BIGINT" property="pageId"/>
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="page_code" jdbcType="VARCHAR" property="pageCode"/>
|
||||
<result column="page_name" jdbcType="VARCHAR" property="pageName"/>
|
||||
<result column="page_type" jdbcType="INTEGER" property="pageType"/>
|
||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||
<result column="published" jdbcType="BOOLEAN" property="published"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlinePageMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlinePageFilter != null">
|
||||
<if test="onlinePageFilter.tenantId == null">
|
||||
AND zz_online_page.tenant_id IS NULL
|
||||
</if>
|
||||
<if test="onlinePageFilter.tenantId != null">
|
||||
AND zz_online_page.tenant_id = #{onlinePageFilter.tenantId}
|
||||
</if>
|
||||
<if test="onlinePageFilter.appCode == null">
|
||||
AND zz_online_page.app_code IS NULL
|
||||
</if>
|
||||
<if test="onlinePageFilter.appCode != null">
|
||||
AND zz_online_page.app_code = #{onlinePageFilter.appCode}
|
||||
</if>
|
||||
<if test="onlinePageFilter.pageCode != null and onlinePageFilter.pageCode != ''">
|
||||
AND zz_online_page.page_code = #{onlinePageFilter.pageCode}
|
||||
</if>
|
||||
<if test="onlinePageFilter.pageName != null and onlinePageFilter.pageName != ''">
|
||||
<bind name= "safePageName" value= "'%' + onlinePageFilter.pageName + '%'"/>
|
||||
AND zz_online_page.page_name LIKE #{safePageName}
|
||||
</if>
|
||||
<if test="onlinePageFilter.pageType != null">
|
||||
AND zz_online_page.page_type = #{onlinePageFilter.pageType}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlinePageList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlinePage">
|
||||
SELECT * FROM zz_online_page
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getOnlinePageListByDatasourceId" resultMap="BaseResultMap">
|
||||
SELECT a.* FROM zz_online_page a, zz_online_page_datasource b
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
AND b.datasource_id = #{datasourceI} AND b.page_id = a.page_id
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineRuleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineRule">
|
||||
<id column="rule_id" jdbcType="BIGINT" property="ruleId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="rule_name" jdbcType="VARCHAR" property="ruleName"/>
|
||||
<result column="rule_type" jdbcType="INTEGER" property="ruleType"/>
|
||||
<result column="builtin" jdbcType="BOOLEAN" property="builtin"/>
|
||||
<result column="pattern" jdbcType="VARCHAR" property="pattern"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="BaseResultMapWithOnlineColumnRule" type="com.orangeforms.common.online.model.OnlineRule" extends="BaseResultMap">
|
||||
<association property="onlineColumnRule" column="rule_id" foreignColumn="rule_id"
|
||||
notNullColumn="rule_id" resultMap="com.orangeforms.common.online.dao.OnlineColumnRuleMapper.BaseResultMap" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<if test="onlineRuleFilter != null">
|
||||
<if test="onlineRuleFilter.appCode == null">
|
||||
AND (zz_online_rule.app_code IS NULL OR zz_online_rule.builtin = 1)
|
||||
</if>
|
||||
<if test="onlineRuleFilter.appCode != null">
|
||||
AND (zz_online_rule.app_code = #{onlineRuleFilter.appCode} OR zz_online_rule.builtin = 1)
|
||||
</if>
|
||||
</if>
|
||||
AND zz_online_rule.deleted_flag = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineRuleList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineRule">
|
||||
SELECT * FROM zz_online_rule
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getOnlineRuleListByColumnId" resultMap="BaseResultMapWithOnlineColumnRule">
|
||||
SELECT
|
||||
zz_online_rule.*,
|
||||
zz_online_column_rule.*
|
||||
FROM
|
||||
zz_online_rule,
|
||||
zz_online_column_rule
|
||||
<where>
|
||||
AND zz_online_column_rule.column_id = #{columnId}
|
||||
AND zz_online_column_rule.rule_id = zz_online_rule.rule_id
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getNotInOnlineRuleListByColumnId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
zz_online_rule.*
|
||||
FROM
|
||||
zz_online_rule
|
||||
<where>
|
||||
AND NOT EXISTS (SELECT * FROM zz_online_column_rule
|
||||
WHERE zz_online_column_rule.column_id = #{columnId} AND zz_online_column_rule.rule_id = zz_online_rule.rule_id)
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineTableMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineTable">
|
||||
<id column="table_id" jdbcType="BIGINT" property="tableId"/>
|
||||
<result column="app_code" jdbcType="VARCHAR" property="appCode"/>
|
||||
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
|
||||
<result column="model_name" jdbcType="VARCHAR" property="modelName"/>
|
||||
<result column="dblink_id" jdbcType="BIGINT" property="dblinkId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineTableMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineTableFilter != null">
|
||||
<if test="onlineTableFilter.appCode == null">
|
||||
AND zz_online_table.app_code IS NULL
|
||||
</if>
|
||||
<if test="onlineTableFilter.appCode != null">
|
||||
AND zz_online_table.app_code = #{onlineTableFilter.appCode}
|
||||
</if>
|
||||
<if test="onlineTableFilter.tableName != null and onlineTableFilter.tableName != ''">
|
||||
AND zz_online_table.table_name = #{onlineTableFilter.tableName}
|
||||
</if>
|
||||
<if test="onlineTableFilter.modelName != null and onlineTableFilter.modelName != ''">
|
||||
AND zz_online_table.model_name = #{onlineTableFilter.modelName}
|
||||
</if>
|
||||
<if test="onlineTableFilter.dblinkId != null">
|
||||
AND zz_online_table.dblink_id = #{onlineTableFilter.dblinkId}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineTableList" resultMap="BaseResultMap" parameterType="com.orangeforms.common.online.model.OnlineTable">
|
||||
SELECT * FROM zz_online_table
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getOnlineTableListByDatasourceId" resultMap="BaseResultMap">
|
||||
SELECT a.* FROM zz_online_table a, zz_online_datasource_table b
|
||||
WHERE b.datasource_id = #{datasourceId} AND b.table_id = a.table_id
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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="com.orangeforms.common.online.dao.OnlineVirtualColumnMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orangeforms.common.online.model.OnlineVirtualColumn">
|
||||
<id column="virtual_column_id" jdbcType="BIGINT" property="virtualColumnId"/>
|
||||
<result column="table_id" jdbcType="BIGINT" property="tableId"/>
|
||||
<result column="object_field_name" jdbcType="VARCHAR" property="objectFieldName"/>
|
||||
<result column="object_field_type" jdbcType="VARCHAR" property="objectFieldType"/>
|
||||
<result column="column_prompt" jdbcType="VARCHAR" property="columnPrompt"/>
|
||||
<result column="virtual_type" jdbcType="INTEGER" property="virtualType"/>
|
||||
<result column="datasource_id" jdbcType="BIGINT" property="datasourceId"/>
|
||||
<result column="relation_id" jdbcType="BIGINT" property="relationId"/>
|
||||
<result column="aggregation_table_id" jdbcType="BIGINT" property="aggregationTableId"/>
|
||||
<result column="aggregation_column_id" jdbcType="BIGINT" property="aggregationColumnId"/>
|
||||
<result column="aggregation_type" jdbcType="INTEGER" property="aggregationType"/>
|
||||
<result column="where_clause_json" jdbcType="VARCHAR" property="whereClauseJson"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orangeforms.common.online.dao.OnlineVirtualColumnMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="onlineVirtualColumnFilter != null">
|
||||
<if test="onlineVirtualColumnFilter.datasourceId != null">
|
||||
AND zz_online_virtual_column.datasource_id = #{onlineVirtualColumnFilter.datasourceId}
|
||||
</if>
|
||||
<if test="onlineVirtualColumnFilter.relationId != null">
|
||||
AND zz_online_virtual_column.relation_id = #{onlineVirtualColumnFilter.relationId}
|
||||
</if>
|
||||
<if test="onlineVirtualColumnFilter.tableId != null">
|
||||
AND zz_online_virtual_column.table_id = #{onlineVirtualColumnFilter.tableId}
|
||||
</if>
|
||||
<if test="onlineVirtualColumnFilter.aggregationColumnId != null">
|
||||
AND zz_online_virtual_column.aggregation_column_id = #{onlineVirtualColumnFilter.aggregationColumnId}
|
||||
</if>
|
||||
<if test="onlineVirtualColumnFilter.virtualType != null">
|
||||
AND zz_online_virtual_column.virtual_type = #{onlineVirtualColumnFilter.virtualType}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getOnlineVirtualColumnList" resultMap="BaseResultMap"
|
||||
parameterType="com.orangeforms.common.online.model.OnlineVirtualColumn">
|
||||
SELECT * FROM zz_online_virtual_column
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,189 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.online.model.constant.FieldFilterType;
|
||||
import com.orangeforms.common.online.model.constant.FieldKind;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单数据表字段Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单数据表字段Dto对象")
|
||||
@Data
|
||||
public class OnlineColumnDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long columnId;
|
||||
|
||||
/**
|
||||
* 字段名。
|
||||
*/
|
||||
@Schema(description = "字段名")
|
||||
@NotBlank(message = "数据验证失败,字段名不能为空!")
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 数据表Id。
|
||||
*/
|
||||
@Schema(description = "数据表Id")
|
||||
@NotNull(message = "数据验证失败,数据表Id不能为空!")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 数据表中的字段类型。
|
||||
*/
|
||||
@Schema(description = "数据表中的字段类型")
|
||||
@NotBlank(message = "数据验证失败,数据表中的字段类型不能为空!")
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 数据表中的完整字段类型(包括了精度和刻度)。
|
||||
*/
|
||||
@Schema(description = "数据表中的完整字段类型")
|
||||
@NotBlank(message = "数据验证失败,数据表中的完整字段类型(包括了精度和刻度)不能为空!")
|
||||
private String fullColumnType;
|
||||
|
||||
/**
|
||||
* 是否为主键。
|
||||
*/
|
||||
@Schema(description = "是否为主键")
|
||||
@NotNull(message = "数据验证失败,是否为主键不能为空!")
|
||||
private Boolean primaryKey;
|
||||
|
||||
/**
|
||||
* 是否是自增主键(0: 不是 1: 是)。
|
||||
*/
|
||||
@Schema(description = "是否是自增主键")
|
||||
@NotNull(message = "数据验证失败,是否是自增主键(0: 不是 1: 是)不能为空!")
|
||||
private Boolean autoIncrement;
|
||||
|
||||
/**
|
||||
* 是否可以为空 (0: 不可以为空 1: 可以为空)。
|
||||
*/
|
||||
@Schema(description = "是否可以为空")
|
||||
@NotNull(message = "数据验证失败,是否可以为空 (0: 不可以为空 1: 可以为空)不能为空!")
|
||||
private Boolean nullable;
|
||||
|
||||
/**
|
||||
* 缺省值。
|
||||
*/
|
||||
@Schema(description = "缺省值")
|
||||
private String columnDefault;
|
||||
|
||||
/**
|
||||
* 字段在数据表中的显示位置。
|
||||
*/
|
||||
@Schema(description = "字段在数据表中的显示位置")
|
||||
@NotNull(message = "数据验证失败,字段在数据表中的显示位置不能为空!")
|
||||
private Integer columnShowOrder;
|
||||
|
||||
/**
|
||||
* 数据表中的字段注释。
|
||||
*/
|
||||
@Schema(description = "数据表中的字段注释")
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
* 对象映射字段名称。
|
||||
*/
|
||||
@Schema(description = "对象映射字段名称")
|
||||
@NotBlank(message = "数据验证失败,对象映射字段名称不能为空!")
|
||||
private String objectFieldName;
|
||||
|
||||
/**
|
||||
* 对象映射字段类型。
|
||||
*/
|
||||
@Schema(description = "对象映射字段类型")
|
||||
@NotBlank(message = "数据验证失败,对象映射字段类型不能为空!")
|
||||
private String objectFieldType;
|
||||
|
||||
/**
|
||||
* 数值型字段的精度(目前仅Oracle使用)。
|
||||
*/
|
||||
@Schema(description = "数值型字段的精度")
|
||||
private Integer numericPrecision;
|
||||
|
||||
/**
|
||||
* 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。
|
||||
*/
|
||||
@Schema(description = "数值型字段的刻度")
|
||||
private Integer numericScale;
|
||||
|
||||
/**
|
||||
* 过滤类型字段。
|
||||
*/
|
||||
@Schema(description = "过滤类型字段")
|
||||
@NotNull(message = "数据验证失败,过滤类型字段不能为空!", groups = {UpdateGroup.class})
|
||||
@ConstDictRef(constDictClass = FieldFilterType.class, message = "数据验证失败,过滤类型字段为无效值!")
|
||||
private Integer filterType;
|
||||
|
||||
/**
|
||||
* 是否是主键的父Id。
|
||||
*/
|
||||
@Schema(description = "是否是主键的父Id")
|
||||
@NotNull(message = "数据验证失败,是否是主键的父Id不能为空!")
|
||||
private Boolean parentKey;
|
||||
|
||||
/**
|
||||
* 是否部门过滤字段。
|
||||
*/
|
||||
@Schema(description = "是否部门过滤字段")
|
||||
@NotNull(message = "数据验证失败,是否部门过滤字段标记不能为空!")
|
||||
private Boolean deptFilter;
|
||||
|
||||
/**
|
||||
* 是否用户过滤字段。
|
||||
*/
|
||||
@Schema(description = "是否用户过滤字段")
|
||||
@NotNull(message = "数据验证失败,是否用户过滤字段标记不能为空!")
|
||||
private Boolean userFilter;
|
||||
|
||||
/**
|
||||
* 字段类别。
|
||||
*/
|
||||
@Schema(description = "字段类别")
|
||||
@ConstDictRef(constDictClass = FieldKind.class, message = "数据验证失败,字段类别为无效值!")
|
||||
private Integer fieldKind;
|
||||
|
||||
/**
|
||||
* 包含的文件文件数量,0表示无限制。
|
||||
*/
|
||||
@Schema(description = "包含的文件文件数量,0表示无限制")
|
||||
private Integer maxFileCount;
|
||||
|
||||
/**
|
||||
* 上传文件系统类型。
|
||||
*/
|
||||
@Schema(description = "上传文件系统类型")
|
||||
private Integer uploadFileSystemType;
|
||||
|
||||
/**
|
||||
* 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。
|
||||
*/
|
||||
@Schema(description = "脱敏字段类型")
|
||||
private String maskFieldType;
|
||||
|
||||
/**
|
||||
* 编码规则的JSON格式数据。
|
||||
*/
|
||||
@Schema(description = "编码规则的JSON格式数据")
|
||||
private String encodedRule;
|
||||
|
||||
/**
|
||||
* 字典Id。
|
||||
*/
|
||||
@Schema(description = "字典Id")
|
||||
private Long dictId;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单数据表字段规则和字段多对多关联Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单数据表字段规则和字段多对多关联Dto对象")
|
||||
@Data
|
||||
public class OnlineColumnRuleDto {
|
||||
|
||||
/**
|
||||
* 字段Id。
|
||||
*/
|
||||
@Schema(description = "字段Id")
|
||||
@NotNull(message = "数据验证失败,字段Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long columnId;
|
||||
|
||||
/**
|
||||
* 规则Id。
|
||||
*/
|
||||
@Schema(description = "规则Id")
|
||||
@NotNull(message = "数据验证失败,规则Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long ruleId;
|
||||
|
||||
/**
|
||||
* 规则属性数据。
|
||||
*/
|
||||
@Schema(description = "规则属性数据")
|
||||
private String propDataJson;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.AddGroup;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单的数据源Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单的数据源Dto对象")
|
||||
@Data
|
||||
public class OnlineDatasourceDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 数据源名称。
|
||||
*/
|
||||
@Schema(description = "数据源名称")
|
||||
@NotBlank(message = "数据验证失败,数据源名称不能为空!")
|
||||
private String datasourceName;
|
||||
|
||||
/**
|
||||
* 数据源变量名,会成为数据访问url的一部分。
|
||||
*/
|
||||
@Schema(description = "数据源变量名,会成为数据访问url的一部分")
|
||||
@NotBlank(message = "数据验证失败,数据源变量名不能为空!")
|
||||
private String variableName;
|
||||
|
||||
/**
|
||||
* 主表所在的数据库链接Id。
|
||||
*/
|
||||
@Schema(description = "主表所在的数据库链接Id")
|
||||
@NotNull(message = "数据验证失败,数据库链接Id不能为空!")
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 主表Id。
|
||||
*/
|
||||
@Schema(description = "主表Id")
|
||||
@NotNull(message = "数据验证失败,主表Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long masterTableId;
|
||||
|
||||
/**
|
||||
* 主表表名。
|
||||
*/
|
||||
@Schema(description = "主表表名")
|
||||
@NotBlank(message = "数据验证失败,主表名不能为空!", groups = {AddGroup.class})
|
||||
private String masterTableName;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.AddGroup;
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.online.model.constant.RelationType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单的数据源关联Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单的数据源关联Dto对象")
|
||||
@Data
|
||||
public class OnlineDatasourceRelationDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 关联名称。
|
||||
*/
|
||||
@Schema(description = "关联名称")
|
||||
@NotBlank(message = "数据验证失败,关联名称不能为空!")
|
||||
private String relationName;
|
||||
|
||||
/**
|
||||
* 变量名。
|
||||
*/
|
||||
@Schema(description = "变量名")
|
||||
@NotBlank(message = "数据验证失败,变量名不能为空!")
|
||||
private String variableName;
|
||||
|
||||
/**
|
||||
* 主数据源Id。
|
||||
*/
|
||||
@Schema(description = "主数据源Id")
|
||||
@NotNull(message = "数据验证失败,主数据源Id不能为空!")
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 关联类型。
|
||||
*/
|
||||
@Schema(description = "关联类型")
|
||||
@NotNull(message = "数据验证失败,关联类型不能为空!")
|
||||
@ConstDictRef(constDictClass = RelationType.class, message = "数据验证失败,关联类型为无效值!")
|
||||
private Integer relationType;
|
||||
|
||||
/**
|
||||
* 主表关联字段Id。
|
||||
*/
|
||||
@Schema(description = "主表关联字段Id")
|
||||
@NotNull(message = "数据验证失败,主表关联字段Id不能为空!")
|
||||
private Long masterColumnId;
|
||||
|
||||
/**
|
||||
* 从表Id。
|
||||
*/
|
||||
@Schema(description = "从表Id")
|
||||
@NotNull(message = "数据验证失败,从表Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long slaveTableId;
|
||||
|
||||
/**
|
||||
* 从表名。
|
||||
*/
|
||||
@Schema(description = "从表名")
|
||||
@NotBlank(message = "数据验证失败,从表名不能为空!", groups = {AddGroup.class})
|
||||
private String slaveTableName;
|
||||
|
||||
/**
|
||||
* 从表关联字段Id。
|
||||
*/
|
||||
@Schema(description = "从表关联字段Id")
|
||||
@NotNull(message = "数据验证失败,从表关联字段Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long slaveColumnId;
|
||||
|
||||
/**
|
||||
* 从表字段名。
|
||||
*/
|
||||
@Schema(description = "从表字段名")
|
||||
@NotBlank(message = "数据验证失败,从表字段名不能为空!", groups = {AddGroup.class})
|
||||
private String slaveColumnName;
|
||||
|
||||
/**
|
||||
* 是否级联删除标记。
|
||||
*/
|
||||
@Schema(description = "是否级联删除标记")
|
||||
@NotNull(message = "数据验证失败,是否级联删除标记不能为空!")
|
||||
private Boolean cascadeDelete;
|
||||
|
||||
/**
|
||||
* 是否左连接标记。
|
||||
*/
|
||||
@Schema(description = "是否左连接标记")
|
||||
@NotNull(message = "数据验证失败,是否左连接标记不能为空!")
|
||||
private Boolean leftJoin;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单数据表所在数据库链接Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单数据表所在数据库链接Dto对象")
|
||||
@Data
|
||||
public class OnlineDblinkDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 链接中文名称。
|
||||
*/
|
||||
@Schema(description = "链接中文名称")
|
||||
@NotBlank(message = "数据验证失败,链接中文名称不能为空!")
|
||||
private String dblinkName;
|
||||
|
||||
/**
|
||||
* 链接描述。
|
||||
*/
|
||||
@Schema(description = "链接中文名称")
|
||||
private String dblinkDescription;
|
||||
|
||||
/**
|
||||
* 配置信息。
|
||||
*/
|
||||
@Schema(description = "配置信息")
|
||||
@NotBlank(message = "数据验证失败,配置信息不能为空!")
|
||||
private String configuration;
|
||||
|
||||
/**
|
||||
* 数据库链接类型。
|
||||
*/
|
||||
@Schema(description = "数据库链接类型")
|
||||
@NotNull(message = "数据验证失败,数据库链接类型不能为空!")
|
||||
private Integer dblinkType;
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.core.constant.DictType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单关联的字典Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单关联的字典Dto对象")
|
||||
@Data
|
||||
public class OnlineDictDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 字典名称。
|
||||
*/
|
||||
@Schema(description = "字典名称")
|
||||
@NotBlank(message = "数据验证失败,字典名称不能为空!")
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型。
|
||||
*/
|
||||
@Schema(description = "字典类型")
|
||||
@NotNull(message = "数据验证失败,字典类型不能为空!")
|
||||
@ConstDictRef(constDictClass = DictType.class, message = "数据验证失败,字典类型为无效值!")
|
||||
private Integer dictType;
|
||||
|
||||
/**
|
||||
* 数据库链接Id。
|
||||
*/
|
||||
@Schema(description = "数据库链接Id")
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 字典表名称。
|
||||
*/
|
||||
@Schema(description = "字典表名称")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 全局字典编码。
|
||||
*/
|
||||
@Schema(description = "全局字典编码")
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典表键字段名称。
|
||||
*/
|
||||
@Schema(description = "字典表键字段名称")
|
||||
private String keyColumnName;
|
||||
|
||||
/**
|
||||
* 字典表父键字段名称。
|
||||
*/
|
||||
@Schema(description = "字典表父键字段名称")
|
||||
private String parentKeyColumnName;
|
||||
|
||||
/**
|
||||
* 字典值字段名称。
|
||||
*/
|
||||
@Schema(description = "字典值字段名称")
|
||||
private String valueColumnName;
|
||||
|
||||
/**
|
||||
* 逻辑删除字段。
|
||||
*/
|
||||
@Schema(description = "逻辑删除字段")
|
||||
private String deletedColumnName;
|
||||
|
||||
/**
|
||||
* 用户过滤滤字段名称。
|
||||
*/
|
||||
@Schema(description = "用户过滤滤字段名称")
|
||||
private String userFilterColumnName;
|
||||
|
||||
/**
|
||||
* 部门过滤字段名称。
|
||||
*/
|
||||
@Schema(description = "部门过滤字段名称")
|
||||
private String deptFilterColumnName;
|
||||
|
||||
/**
|
||||
* 租户过滤字段名称。
|
||||
*/
|
||||
@Schema(description = "租户过滤字段名称")
|
||||
private String tenantFilterColumnName;
|
||||
|
||||
/**
|
||||
* 获取字典数据的url。
|
||||
*/
|
||||
@Schema(description = "获取字典数据的url")
|
||||
private String dictListUrl;
|
||||
|
||||
/**
|
||||
* 根据主键id批量获取字典数据的url。
|
||||
*/
|
||||
@Schema(description = "根据主键id批量获取字典数据的url")
|
||||
private String dictIdsUrl;
|
||||
|
||||
/**
|
||||
* 字典的JSON数据。
|
||||
*/
|
||||
@Schema(description = "字典的JSON数据")
|
||||
private String dictDataJson;
|
||||
|
||||
/**
|
||||
* 是否树形标记。
|
||||
*/
|
||||
@Schema(description = "是否树形标记")
|
||||
@NotNull(message = "数据验证失败,是否树形标记不能为空!")
|
||||
private Boolean treeFlag;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.online.model.constant.FieldFilterType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 在线表单数据过滤参数对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单数据过滤参数对象")
|
||||
@Data
|
||||
public class OnlineFilterDto {
|
||||
|
||||
/**
|
||||
* 表名。
|
||||
*/
|
||||
@Schema(description = "表名")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 过滤字段名。
|
||||
*/
|
||||
@Schema(description = "过滤字段名")
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 过滤值。
|
||||
*/
|
||||
@Schema(description = "过滤值")
|
||||
private Object columnValue;
|
||||
|
||||
/**
|
||||
* 范围比较的最小值。
|
||||
*/
|
||||
@Schema(description = "范围比较的最小值")
|
||||
private Object columnValueStart;
|
||||
|
||||
/**
|
||||
* 范围比较的最大值。
|
||||
*/
|
||||
@Schema(description = "范围比较的最大值")
|
||||
private Object columnValueEnd;
|
||||
|
||||
/**
|
||||
* 仅当操作符为IN的时候使用。
|
||||
*/
|
||||
@Schema(description = "仅当操作符为IN的时候使用")
|
||||
private Set<Serializable> columnValueList;
|
||||
|
||||
/**
|
||||
* 过滤类型,参考FieldFilterType常量对象。缺省值就是等于过滤了。
|
||||
*/
|
||||
@Schema(description = "过滤类型")
|
||||
private Integer filterType = FieldFilterType.EQUAL_FILTER;
|
||||
|
||||
/**
|
||||
* 是否为字典多选。
|
||||
*/
|
||||
@Schema(description = "是否为字典多选")
|
||||
private Boolean dictMultiSelect = false;
|
||||
|
||||
/**
|
||||
* 是否为Oracle的日期类型。
|
||||
*/
|
||||
private Boolean isOracleDate = false;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.online.model.constant.FormKind;
|
||||
import com.orangeforms.common.online.model.constant.FormType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单Dto对象")
|
||||
@Data
|
||||
public class OnlineFormDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long formId;
|
||||
|
||||
/**
|
||||
* 页面id。
|
||||
*/
|
||||
@Schema(description = "页面id")
|
||||
@NotNull(message = "数据验证失败,页面id不能为空!")
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 表单编码。
|
||||
*/
|
||||
@Schema(description = "表单编码")
|
||||
private String formCode;
|
||||
|
||||
/**
|
||||
* 表单名称。
|
||||
*/
|
||||
@Schema(description = "表单名称")
|
||||
@NotBlank(message = "数据验证失败,表单名称不能为空!")
|
||||
private String formName;
|
||||
|
||||
/**
|
||||
* 表单类别。
|
||||
*/
|
||||
@Schema(description = "表单类别")
|
||||
@NotNull(message = "数据验证失败,表单类别不能为空!")
|
||||
@ConstDictRef(constDictClass = FormKind.class, message = "数据验证失败,表单类别为无效值!")
|
||||
private Integer formKind;
|
||||
|
||||
/**
|
||||
* 表单类型。
|
||||
*/
|
||||
@Schema(description = "表单类型")
|
||||
@NotNull(message = "数据验证失败,表单类型不能为空!")
|
||||
@ConstDictRef(constDictClass = FormType.class, message = "数据验证失败,表单类型为无效值!")
|
||||
private Integer formType;
|
||||
|
||||
/**
|
||||
* 表单主表id。
|
||||
*/
|
||||
@Schema(description = "表单主表id")
|
||||
@NotNull(message = "数据验证失败,表单主表id不能为空!")
|
||||
private Long masterTableId;
|
||||
|
||||
/**
|
||||
* 当前表单关联的数据源Id集合。
|
||||
*/
|
||||
@Schema(description = "当前表单关联的数据源Id集合")
|
||||
private List<Long> datasourceIdList;
|
||||
|
||||
/**
|
||||
* 表单组件JSON。
|
||||
*/
|
||||
@Schema(description = "表单组件JSON")
|
||||
private String widgetJson;
|
||||
|
||||
/**
|
||||
* 表单参数JSON。
|
||||
*/
|
||||
@Schema(description = "表单参数JSON")
|
||||
private String paramsJson;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单页面和数据源多对多关联Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单页面和数据源多对多关联Dto对象")
|
||||
@Data
|
||||
public class OnlinePageDatasourceDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 页面主键Id。
|
||||
*/
|
||||
@Schema(description = "页面主键Id")
|
||||
@NotNull(message = "数据验证失败,页面主键Id不能为空!")
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 数据源主键Id。
|
||||
*/
|
||||
@Schema(description = "数据源主键Id")
|
||||
@NotNull(message = "数据验证失败,数据源主键Id不能为空!")
|
||||
private Long datasourceId;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.online.model.constant.PageStatus;
|
||||
import com.orangeforms.common.online.model.constant.PageType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单所在页面Dto对象。这里我们可以把页面理解为表单的容器。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单所在页面Dto对象")
|
||||
@Data
|
||||
public class OnlinePageDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 页面编码。
|
||||
*/
|
||||
@Schema(description = "页面编码")
|
||||
private String pageCode;
|
||||
|
||||
/**
|
||||
* 页面名称。
|
||||
*/
|
||||
@Schema(description = "页面名称")
|
||||
@NotBlank(message = "数据验证失败,页面名称不能为空!")
|
||||
private String pageName;
|
||||
|
||||
/**
|
||||
* 页面类型。
|
||||
*/
|
||||
@Schema(description = "页面类型")
|
||||
@NotNull(message = "数据验证失败,页面类型不能为空!")
|
||||
@ConstDictRef(constDictClass = PageType.class, message = "数据验证失败,页面类型为无效值!")
|
||||
private Integer pageType;
|
||||
|
||||
/**
|
||||
* 页面编辑状态。
|
||||
*/
|
||||
@Schema(description = "页面编辑状态")
|
||||
@NotNull(message = "数据验证失败,状态不能为空!")
|
||||
@ConstDictRef(constDictClass = PageStatus.class, message = "数据验证失败,状态为无效值!")
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import com.orangeforms.common.online.model.constant.RuleType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单数据表字段验证规则Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单数据表字段验证规则Dto对象")
|
||||
@Data
|
||||
public class OnlineRuleDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long ruleId;
|
||||
|
||||
/**
|
||||
* 规则名称。
|
||||
*/
|
||||
@Schema(description = "规则名称")
|
||||
@NotBlank(message = "数据验证失败,规则名称不能为空!")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型。
|
||||
*/
|
||||
@Schema(description = "规则类型")
|
||||
@NotNull(message = "数据验证失败,规则类型不能为空!")
|
||||
@ConstDictRef(constDictClass = RuleType.class, message = "数据验证失败,规则类型为无效值!")
|
||||
private Integer ruleType;
|
||||
|
||||
/**
|
||||
* 内置规则标记。
|
||||
*/
|
||||
@Schema(description = "内置规则标记")
|
||||
@NotNull(message = "数据验证失败,内置规则标记不能为空!")
|
||||
private Boolean builtin;
|
||||
|
||||
/**
|
||||
* 自定义规则的正则表达式。
|
||||
*/
|
||||
@Schema(description = "自定义规则的正则表达式")
|
||||
private String pattern;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 在线表单的数据表Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线表单的数据表Dto对象")
|
||||
@Data
|
||||
public class OnlineTableDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 表名称。
|
||||
*/
|
||||
@Schema(description = "表名称")
|
||||
@NotBlank(message = "数据验证失败,表名称不能为空!")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 实体名称。
|
||||
*/
|
||||
@Schema(description = "实体名称")
|
||||
@NotBlank(message = "数据验证失败,实体名称不能为空!")
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 数据库链接Id。
|
||||
*/
|
||||
@Schema(description = "数据库链接Id")
|
||||
@NotNull(message = "数据验证失败,数据库链接Id不能为空!")
|
||||
private Long dblinkId;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.orangeforms.common.online.dto;
|
||||
|
||||
import com.orangeforms.common.core.constant.AggregationType;
|
||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.orangeforms.common.online.model.constant.VirtualType;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 在线数据表虚拟字段Dto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Schema(description = "在线数据表虚拟字段Dto对象")
|
||||
@Data
|
||||
public class OnlineVirtualColumnDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Schema(description = "主键Id")
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long virtualColumnId;
|
||||
|
||||
/**
|
||||
* 所在表Id。
|
||||
*/
|
||||
@Schema(description = "所在表Id")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 字段名称。
|
||||
*/
|
||||
@Schema(description = "字段名称")
|
||||
@NotBlank(message = "数据验证失败,字段名称不能为空!")
|
||||
private String objectFieldName;
|
||||
|
||||
/**
|
||||
* 属性类型。
|
||||
*/
|
||||
@Schema(description = "属性类型")
|
||||
@NotBlank(message = "数据验证失败,属性类型不能为空!")
|
||||
private String objectFieldType;
|
||||
|
||||
/**
|
||||
* 字段提示名。
|
||||
*/
|
||||
@Schema(description = "字段提示名")
|
||||
@NotBlank(message = "数据验证失败,字段提示名不能为空!")
|
||||
private String columnPrompt;
|
||||
|
||||
/**
|
||||
* 虚拟字段类型(0: 聚合)。
|
||||
*/
|
||||
@Schema(description = "虚拟字段类型(0: 聚合)")
|
||||
@ConstDictRef(constDictClass = VirtualType.class, message = "数据验证失败,虚拟字段类型为无效值!")
|
||||
@NotNull(message = "数据验证失败,虚拟字段类型(0: 聚合)不能为空!")
|
||||
private Integer virtualType;
|
||||
|
||||
/**
|
||||
* 关联数据源Id。
|
||||
*/
|
||||
@Schema(description = "关联数据源Id")
|
||||
@NotNull(message = "数据验证失败,关联数据源Id不能为空!")
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 关联Id。
|
||||
*/
|
||||
@Schema(description = "关联Id")
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 聚合字段所在关联表Id。
|
||||
*/
|
||||
@Schema(description = "聚合字段所在关联表Id")
|
||||
private Long aggregationTableId;
|
||||
|
||||
/**
|
||||
* 关联表聚合字段Id。
|
||||
*/
|
||||
@Schema(description = "关联表聚合字段Id")
|
||||
private Long aggregationColumnId;
|
||||
|
||||
/**
|
||||
* 聚合类型(0: sum 1: count 2: avg 3: min 4: max)。
|
||||
*/
|
||||
@Schema(description = "聚合类型(0: sum 1: count 2: avg 3: min 4: max)")
|
||||
@ConstDictRef(constDictClass = AggregationType.class, message = "数据验证失败,虚拟字段聚合计算类型为无效值!")
|
||||
private Integer aggregationType;
|
||||
|
||||
/**
|
||||
* 存储过滤条件的json。
|
||||
*/
|
||||
@Schema(description = "存储过滤条件的json")
|
||||
private String whereClauseJson;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.orangeforms.common.online.exception;
|
||||
|
||||
import com.orangeforms.common.core.exception.MyRuntimeException;
|
||||
|
||||
/**
|
||||
* 在线表单运行时异常。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public class OnlineRuntimeException extends MyRuntimeException {
|
||||
|
||||
/**
|
||||
* 构造函数。
|
||||
*/
|
||||
public OnlineRuntimeException() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数。
|
||||
*
|
||||
* @param msg 错误信息。
|
||||
*/
|
||||
public OnlineRuntimeException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationConstDict;
|
||||
import com.orangeforms.common.core.annotation.RelationOneToOne;
|
||||
import com.orangeforms.common.online.model.constant.FieldKind;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单数据表字段实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_column")
|
||||
public class OnlineColumn {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "column_id")
|
||||
private Long columnId;
|
||||
|
||||
/**
|
||||
* 字段名。
|
||||
*/
|
||||
@Column(value = "column_name")
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 数据表Id。
|
||||
*/
|
||||
@Column(value = "table_id")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 数据表中的字段类型。
|
||||
*/
|
||||
@Column(value = "column_type")
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 数据表中的完整字段类型(包括了精度和刻度)。
|
||||
*/
|
||||
@Column(value = "full_column_type")
|
||||
private String fullColumnType;
|
||||
|
||||
/**
|
||||
* 是否为主键。
|
||||
*/
|
||||
@Column(value = "primary_key")
|
||||
private Boolean primaryKey;
|
||||
|
||||
/**
|
||||
* 是否是自增主键(0: 不是 1: 是)。
|
||||
*/
|
||||
@Column(value = "auto_incr")
|
||||
private Boolean autoIncrement;
|
||||
|
||||
/**
|
||||
* 是否可以为空 (0: 不可以为空 1: 可以为空)。
|
||||
*/
|
||||
@Column(value = "nullable")
|
||||
private Boolean nullable;
|
||||
|
||||
/**
|
||||
* 缺省值。
|
||||
*/
|
||||
@Column(value = "column_default")
|
||||
private String columnDefault;
|
||||
|
||||
/**
|
||||
* 字段在数据表中的显示位置。
|
||||
*/
|
||||
@Column(value = "column_show_order")
|
||||
private Integer columnShowOrder;
|
||||
|
||||
/**
|
||||
* 数据表中的字段注释。
|
||||
*/
|
||||
@Column(value = "column_comment")
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
* 对象映射字段名称。
|
||||
*/
|
||||
@Column(value = "object_field_name")
|
||||
private String objectFieldName;
|
||||
|
||||
/**
|
||||
* 对象映射字段类型。
|
||||
*/
|
||||
@Column(value = "object_field_type")
|
||||
private String objectFieldType;
|
||||
|
||||
/**
|
||||
* 数值型字段的精度(目前仅Oracle使用)。
|
||||
*/
|
||||
@Column(value = "numeric_precision")
|
||||
private Integer numericPrecision;
|
||||
|
||||
/**
|
||||
* 数值型字段的刻度(小数点后位数,目前仅Oracle使用)。
|
||||
*/
|
||||
@Column(value = "numeric_scale")
|
||||
private Integer numericScale;
|
||||
|
||||
/**
|
||||
* 过滤字段类型。
|
||||
*/
|
||||
@Column(value = "filter_type")
|
||||
private Integer filterType;
|
||||
|
||||
/**
|
||||
* 是否是主键的父Id。
|
||||
*/
|
||||
@Column(value = "parent_key")
|
||||
private Boolean parentKey;
|
||||
|
||||
/**
|
||||
* 是否部门过滤字段。
|
||||
*/
|
||||
@Column(value = "dept_filter")
|
||||
private Boolean deptFilter;
|
||||
|
||||
/**
|
||||
* 是否用户过滤字段。
|
||||
*/
|
||||
@Column(value = "user_filter")
|
||||
private Boolean userFilter;
|
||||
|
||||
/**
|
||||
* 字段类别。
|
||||
*/
|
||||
@Column(value = "field_kind")
|
||||
private Integer fieldKind;
|
||||
|
||||
/**
|
||||
* 包含的文件文件数量,0表示无限制。
|
||||
*/
|
||||
@Column(value = "max_file_count")
|
||||
private Integer maxFileCount;
|
||||
|
||||
/**
|
||||
* 上传文件系统类型。
|
||||
*/
|
||||
@Column(value = "upload_file_system_type")
|
||||
private Integer uploadFileSystemType;
|
||||
|
||||
/**
|
||||
* 编码规则的JSON格式数据。
|
||||
*/
|
||||
@Column(value = "encoded_rule")
|
||||
private String encodedRule;
|
||||
|
||||
/**
|
||||
* 脱敏字段类型,具体值可参考MaskFieldTypeEnum枚举。
|
||||
*/
|
||||
@Column(value = "mask_field_type")
|
||||
private String maskFieldType;
|
||||
|
||||
/**
|
||||
* 字典Id。
|
||||
*/
|
||||
@Column(value = "dict_id")
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* SQL查询时候使用的别名。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private String columnAliasName;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "fieldKind",
|
||||
constantDictClass = FieldKind.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> fieldKindDictMap;
|
||||
|
||||
@RelationOneToOne(
|
||||
masterIdField = "dictId",
|
||||
slaveModelClass = OnlineDict.class,
|
||||
slaveIdField = "dictId",
|
||||
loadSlaveDict = false)
|
||||
@Column(ignore = true)
|
||||
private OnlineDict dictInfo;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 在线表单数据表字段规则和字段多对多关联实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_column_rule")
|
||||
public class OnlineColumnRule {
|
||||
|
||||
/**
|
||||
* 字段Id。
|
||||
*/
|
||||
@Column(value = "column_id")
|
||||
private Long columnId;
|
||||
|
||||
/**
|
||||
* 规则Id。
|
||||
*/
|
||||
@Column(value = "rule_id")
|
||||
private Long ruleId;
|
||||
|
||||
/**
|
||||
* 规则属性数据。
|
||||
*/
|
||||
@Column(value = "prop_data_json")
|
||||
private String propDataJson;
|
||||
|
||||
@Column(ignore = true)
|
||||
private OnlineRule onlineRule;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationDict;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单的数据源实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_datasource")
|
||||
public class OnlineDatasource {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "datasource_id")
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 数据源名称。
|
||||
*/
|
||||
@Column(value = "datasource_name")
|
||||
private String datasourceName;
|
||||
|
||||
/**
|
||||
* 数据源变量名,会成为数据访问url的一部分。
|
||||
*/
|
||||
@Column(value = "variable_name")
|
||||
private String variableName;
|
||||
|
||||
/**
|
||||
* 数据库链接Id。
|
||||
*/
|
||||
@Column(value = "dblink_id")
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 主表Id。
|
||||
*/
|
||||
@Column(value = "master_table_id")
|
||||
private Long masterTableId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* datasourceId 的多对多关联的数据对象。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private OnlinePageDatasource onlinePageDatasource;
|
||||
|
||||
/**
|
||||
* datasourceId 的多对多关联的数据对象。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private List<OnlineFormDatasource> onlineFormDatasourceList;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "masterTableId",
|
||||
slaveModelClass = OnlineTable.class,
|
||||
slaveIdField = "tableId",
|
||||
slaveNameField = "tableName")
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> masterTableIdDictMap;
|
||||
|
||||
@Column(ignore = true)
|
||||
private OnlineTable masterTable;
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationConstDict;
|
||||
import com.orangeforms.common.core.annotation.RelationDict;
|
||||
import com.orangeforms.common.core.annotation.RelationOneToOne;
|
||||
import com.orangeforms.common.online.model.constant.RelationType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单的数据源关联实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_datasource_relation")
|
||||
public class OnlineDatasourceRelation {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "relation_id")
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 应用Id。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 关联名称。
|
||||
*/
|
||||
@Column(value = "relation_name")
|
||||
private String relationName;
|
||||
|
||||
/**
|
||||
* 变量名。
|
||||
*/
|
||||
@Column(value = "variable_name")
|
||||
private String variableName;
|
||||
|
||||
/**
|
||||
* 主数据源Id。
|
||||
*/
|
||||
@Column(value = "datasource_id")
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 关联类型。
|
||||
*/
|
||||
@Column(value = "relation_type")
|
||||
private Integer relationType;
|
||||
|
||||
/**
|
||||
* 主表关联字段Id。
|
||||
*/
|
||||
@Column(value = "master_column_id")
|
||||
private Long masterColumnId;
|
||||
|
||||
/**
|
||||
* 从表Id。
|
||||
*/
|
||||
@Column(value = "slave_table_id")
|
||||
private Long slaveTableId;
|
||||
|
||||
/**
|
||||
* 从表关联字段Id。
|
||||
*/
|
||||
@Column(value = "slave_column_id")
|
||||
private Long slaveColumnId;
|
||||
|
||||
/**
|
||||
* 删除主表的时候是否级联删除一对一和一对多的从表数据,多对多只是删除关联,不受到这个标记的影响。。
|
||||
*/
|
||||
@Column(value = "cascade_delete")
|
||||
private Boolean cascadeDelete;
|
||||
|
||||
/**
|
||||
* 是否左连接。
|
||||
*/
|
||||
@Column(value = "left_join")
|
||||
private Boolean leftJoin;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
@RelationOneToOne(
|
||||
masterIdField = "masterColumnId",
|
||||
slaveModelClass = OnlineColumn.class,
|
||||
slaveIdField = "columnId")
|
||||
@Column(ignore = true)
|
||||
private OnlineColumn masterColumn;
|
||||
|
||||
@RelationOneToOne(
|
||||
masterIdField = "slaveTableId",
|
||||
slaveModelClass = OnlineTable.class,
|
||||
slaveIdField = "tableId")
|
||||
@Column(ignore = true)
|
||||
private OnlineTable slaveTable;
|
||||
|
||||
@RelationOneToOne(
|
||||
masterIdField = "slaveColumnId",
|
||||
slaveModelClass = OnlineColumn.class,
|
||||
slaveIdField = "columnId")
|
||||
@Column(ignore = true)
|
||||
private OnlineColumn slaveColumn;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "masterColumnId",
|
||||
equalOneToOneRelationField = "onlineColumn",
|
||||
slaveModelClass = OnlineColumn.class,
|
||||
slaveIdField = "columnId",
|
||||
slaveNameField = "columnName")
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> masterColumnIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "slaveTableId",
|
||||
equalOneToOneRelationField = "onlineTable",
|
||||
slaveModelClass = OnlineTable.class,
|
||||
slaveIdField = "tableId",
|
||||
slaveNameField = "modelName")
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> slaveTableIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "slaveColumnId",
|
||||
equalOneToOneRelationField = "onlineColumn",
|
||||
slaveModelClass = OnlineColumn.class,
|
||||
slaveIdField = "columnId",
|
||||
slaveNameField = "columnName")
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> slaveColumnIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "relationType",
|
||||
constantDictClass = RelationType.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> relationTypeDictMap;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据源及其关联所引用的数据表实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_datasource_table")
|
||||
public class OnlineDatasourceTable {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源Id。
|
||||
*/
|
||||
@Column(value = "datasource_id")
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 数据源关联Id。
|
||||
*/
|
||||
@Column(value = "relation_id")
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 数据表Id。
|
||||
*/
|
||||
@Column(value = "table_id")
|
||||
private Long tableId;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationConstDict;
|
||||
import com.orangeforms.common.dbutil.constant.DblinkType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单数据表所在数据库链接实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_dblink")
|
||||
public class OnlineDblink {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "dblink_id")
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 链接中文名称。
|
||||
*/
|
||||
@Column(value = "dblink_name")
|
||||
private String dblinkName;
|
||||
|
||||
/**
|
||||
* 链接描述。
|
||||
*/
|
||||
@Column(value = "dblink_description")
|
||||
private String dblinkDescription;
|
||||
|
||||
/**
|
||||
* 配置信息。
|
||||
*/
|
||||
private String configuration;
|
||||
|
||||
/**
|
||||
* 数据库链接类型。
|
||||
*/
|
||||
@Column(value = "dblink_type")
|
||||
private Integer dblinkType;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 修改时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "dblinkType",
|
||||
constantDictClass = DblinkType.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> dblinkTypeDictMap;
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationConstDict;
|
||||
import com.orangeforms.common.core.annotation.RelationDict;
|
||||
import com.orangeforms.common.core.constant.DictType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单关联的字典实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_dict")
|
||||
public class OnlineDict {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "dict_id")
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 字典名称。
|
||||
*/
|
||||
@Column(value = "dict_name")
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型。
|
||||
*/
|
||||
@Column(value = "dict_type")
|
||||
private Integer dictType;
|
||||
|
||||
/**
|
||||
* 数据库链接Id。
|
||||
*/
|
||||
@Column(value = "dblink_id")
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 字典表名称。
|
||||
*/
|
||||
@Column(value = "table_name")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 全局字典编码。
|
||||
*/
|
||||
@Column(value = "dict_code")
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典表键字段名称。
|
||||
*/
|
||||
@Column(value = "key_column_name")
|
||||
private String keyColumnName;
|
||||
|
||||
/**
|
||||
* 字典表父键字段名称。
|
||||
*/
|
||||
@Column(value = "parent_key_column_name")
|
||||
private String parentKeyColumnName;
|
||||
|
||||
/**
|
||||
* 字典值字段名称。
|
||||
*/
|
||||
@Column(value = "value_column_name")
|
||||
private String valueColumnName;
|
||||
|
||||
/**
|
||||
* 逻辑删除字段。
|
||||
*/
|
||||
@Column(value = "deleted_column_name")
|
||||
private String deletedColumnName;
|
||||
|
||||
/**
|
||||
* 用户过滤滤字段名称。
|
||||
*/
|
||||
@Column(value = "user_filter_column_name")
|
||||
private String userFilterColumnName;
|
||||
|
||||
/**
|
||||
* 部门过滤字段名称。
|
||||
*/
|
||||
@Column(value = "dept_filter_column_name")
|
||||
private String deptFilterColumnName;
|
||||
|
||||
/**
|
||||
* 租户过滤字段名称。
|
||||
*/
|
||||
@Column(value = "tenant_filter_column_name")
|
||||
private String tenantFilterColumnName;
|
||||
|
||||
/**
|
||||
* 是否树形标记。
|
||||
*/
|
||||
@Column(value = "tree_flag")
|
||||
private Boolean treeFlag;
|
||||
|
||||
/**
|
||||
* 获取字典数据的url。
|
||||
*/
|
||||
@Column(value = "dict_list_url")
|
||||
private String dictListUrl;
|
||||
|
||||
/**
|
||||
* 根据主键id批量获取字典数据的url。
|
||||
*/
|
||||
@Column(value = "dict_ids_url")
|
||||
private String dictIdsUrl;
|
||||
|
||||
/**
|
||||
* 字典的JSON数据。
|
||||
*/
|
||||
@Column(value = "dict_data_json")
|
||||
private String dictDataJson;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "dictType",
|
||||
constantDictClass = DictType.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> dictTypeDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "dblinkId",
|
||||
slaveModelClass = OnlineDblink.class,
|
||||
slaveIdField = "dblinkId",
|
||||
slaveNameField = "dblinkName")
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> dblinkIdDictMap;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.orangeforms.common.core.annotation.*;
|
||||
import com.orangeforms.common.online.model.constant.FormType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_form")
|
||||
public class OnlineForm {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "form_id")
|
||||
private Long formId;
|
||||
|
||||
/**
|
||||
* 租户Id。
|
||||
*/
|
||||
@Column(value = "tenant_id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 页面id。
|
||||
*/
|
||||
@Column(value = "page_id")
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 表单编码。
|
||||
*/
|
||||
@Column(value = "form_code")
|
||||
private String formCode;
|
||||
|
||||
/**
|
||||
* 表单名称。
|
||||
*/
|
||||
@Column(value = "form_name")
|
||||
private String formName;
|
||||
|
||||
/**
|
||||
* 表单类别。
|
||||
*/
|
||||
@Column(value = "form_kind")
|
||||
private Integer formKind;
|
||||
|
||||
/**
|
||||
* 表单类型。
|
||||
*/
|
||||
@Column(value = "form_type")
|
||||
private Integer formType;
|
||||
|
||||
/**
|
||||
* 表单主表id。
|
||||
*/
|
||||
@Column(value = "master_table_id")
|
||||
private Long masterTableId;
|
||||
|
||||
/**
|
||||
* 表单组件JSON。
|
||||
*/
|
||||
@Column(value = "widget_json")
|
||||
private String widgetJson;
|
||||
|
||||
/**
|
||||
* 表单参数JSON。
|
||||
*/
|
||||
@Column(value = "params_json")
|
||||
private String paramsJson;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
@RelationOneToOne(
|
||||
masterIdField = "masterTableId",
|
||||
slaveModelClass = OnlineTable.class,
|
||||
slaveIdField = "tableId")
|
||||
@Column(ignore = true)
|
||||
private OnlineTable onlineTable;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "masterTableId",
|
||||
equalOneToOneRelationField = "onlineTable",
|
||||
slaveModelClass = OnlineTable.class,
|
||||
slaveIdField = "tableId",
|
||||
slaveNameField = "modelName")
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> masterTableIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "formType",
|
||||
constantDictClass = FormType.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> formTypeDictMap;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 在线表单和数据源多对多关联实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_form_datasource")
|
||||
public class OnlineFormDatasource {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 表单Id。
|
||||
*/
|
||||
@Column(value = "form_id")
|
||||
private Long formId;
|
||||
|
||||
/**
|
||||
* 数据源Id。
|
||||
*/
|
||||
@Column(value = "datasource_id")
|
||||
private Long datasourceId;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationConstDict;
|
||||
import com.orangeforms.common.online.model.constant.PageStatus;
|
||||
import com.orangeforms.common.online.model.constant.PageType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单所在页面实体对象。这里我们可以把页面理解为表单的容器。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_page")
|
||||
public class OnlinePage {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "page_id")
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 租户Id。
|
||||
*/
|
||||
@Column(value = "tenant_id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 页面编码。
|
||||
*/
|
||||
@Column(value = "page_code")
|
||||
private String pageCode;
|
||||
|
||||
/**
|
||||
* 页面名称。
|
||||
*/
|
||||
@Column(value = "page_name")
|
||||
private String pageName;
|
||||
|
||||
/**
|
||||
* 页面类型。
|
||||
*/
|
||||
@Column(value = "page_type")
|
||||
private Integer pageType;
|
||||
|
||||
/**
|
||||
* 页面编辑状态。
|
||||
*/
|
||||
@Column(value = "status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否发布。
|
||||
*/
|
||||
@Column(value = "published")
|
||||
private Boolean published;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "pageType",
|
||||
constantDictClass = PageType.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> pageTypeDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "status",
|
||||
constantDictClass = PageStatus.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> statusDictMap;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 在线表单页面和数据源多对多关联实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_page_datasource")
|
||||
public class OnlinePageDatasource {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 页面主键Id。
|
||||
*/
|
||||
@Column(value = "page_id")
|
||||
private Long pageId;
|
||||
|
||||
/**
|
||||
* 数据源主键Id。
|
||||
*/
|
||||
@Column(value = "datasource_id")
|
||||
private Long datasourceId;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationConstDict;
|
||||
import com.orangeforms.common.online.model.constant.RuleType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单数据表字段验证规则实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_rule")
|
||||
public class OnlineRule {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "rule_id")
|
||||
private Long ruleId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 规则名称。
|
||||
*/
|
||||
@Column(value = "rule_name")
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型。
|
||||
*/
|
||||
@Column(value = "rule_type")
|
||||
private Integer ruleType;
|
||||
|
||||
/**
|
||||
* 内置规则标记。
|
||||
*/
|
||||
@Column(value = "builtin")
|
||||
private Boolean builtin;
|
||||
|
||||
/**
|
||||
* 自定义规则的正则表达式。
|
||||
*/
|
||||
@Column(value = "pattern")
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@Column(value = "deleted_flag", isLogicDelete = true)
|
||||
private Integer deletedFlag;
|
||||
|
||||
/**
|
||||
* ruleId 的多对多关联表数据对象。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private OnlineColumnRule onlineColumnRule;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "ruleType",
|
||||
constantDictClass = RuleType.class)
|
||||
@Column(ignore = true)
|
||||
private Map<String, Object> ruleTypeDictMap;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import com.orangeforms.common.core.annotation.RelationOneToMany;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单的数据表实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_table")
|
||||
public class OnlineTable {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "table_id")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 应用编码。为空时,表示非第三方应用接入。
|
||||
*/
|
||||
@Column(value = "app_code")
|
||||
private String appCode;
|
||||
|
||||
/**
|
||||
* 表名称。
|
||||
*/
|
||||
@Column(value = "table_name")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 实体名称。
|
||||
*/
|
||||
@Column(value = "model_name")
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 数据库链接Id。
|
||||
*/
|
||||
@Column(value = "dblink_id")
|
||||
private Long dblinkId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建者。
|
||||
*/
|
||||
@Column(value = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新者。
|
||||
*/
|
||||
@Column(value = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
@RelationOneToMany(
|
||||
masterIdField = "tableId",
|
||||
slaveModelClass = OnlineColumn.class,
|
||||
slaveIdField = "tableId")
|
||||
@Column(ignore = true)
|
||||
private List<OnlineColumn> columnList;
|
||||
|
||||
/**
|
||||
* 该字段会被缓存,因此在线表单执行操作时可以从缓存中读取该数据,并可基于columnId进行快速检索。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private Map<Long, OnlineColumn> columnMap;
|
||||
|
||||
/**
|
||||
* 当前表的主键字段,该字段仅仅用于动态表单运行时的SQL拼装。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private OnlineColumn primaryKeyColumn;
|
||||
|
||||
/**
|
||||
* 当前表的逻辑删除字段,该字段仅仅用于动态表单运行时的SQL拼装。
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private OnlineColumn logicDeleteColumn;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.orangeforms.common.online.model;
|
||||
|
||||
import com.mybatisflex.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 在线数据表虚拟字段实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "zz_online_virtual_column")
|
||||
public class OnlineVirtualColumn {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id(value = "virtual_column_id")
|
||||
private Long virtualColumnId;
|
||||
|
||||
/**
|
||||
* 所在表Id。
|
||||
*/
|
||||
@Column(value = "table_id")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* 字段名称。
|
||||
*/
|
||||
@Column(value = "object_field_name")
|
||||
private String objectFieldName;
|
||||
|
||||
/**
|
||||
* 属性类型。
|
||||
*/
|
||||
@Column(value = "object_field_type")
|
||||
private String objectFieldType;
|
||||
|
||||
/**
|
||||
* 字段提示名。
|
||||
*/
|
||||
@Column(value = "column_prompt")
|
||||
private String columnPrompt;
|
||||
|
||||
/**
|
||||
* 虚拟字段类型(0: 聚合)。
|
||||
*/
|
||||
@Column(value = "virtual_type")
|
||||
private Integer virtualType;
|
||||
|
||||
/**
|
||||
* 关联数据源Id。
|
||||
*/
|
||||
@Column(value = "datasource_id")
|
||||
private Long datasourceId;
|
||||
|
||||
/**
|
||||
* 关联Id。
|
||||
*/
|
||||
@Column(value = "relation_id")
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 聚合字段所在关联表Id。
|
||||
*/
|
||||
@Column(value = "aggregation_table_id")
|
||||
private Long aggregationTableId;
|
||||
|
||||
/**
|
||||
* 关联表聚合字段Id。
|
||||
*/
|
||||
@Column(value = "aggregation_column_id")
|
||||
private Long aggregationColumnId;
|
||||
|
||||
/**
|
||||
* 聚合类型(0: count 1: sum 2: avg 3: max 4:min)。
|
||||
*/
|
||||
@Column(value = "aggregation_type")
|
||||
private Integer aggregationType;
|
||||
|
||||
/**
|
||||
* 存储过滤条件的json。
|
||||
*/
|
||||
@Column(value = "where_clause_json")
|
||||
private String whereClauseJson;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字段过滤类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class FieldFilterType {
|
||||
|
||||
/**
|
||||
* 无过滤。
|
||||
*/
|
||||
public static final int NO_FILTER = 0;
|
||||
/**
|
||||
* 等于过滤。
|
||||
*/
|
||||
public static final int EQUAL_FILTER = 1;
|
||||
/**
|
||||
* 范围过滤。
|
||||
*/
|
||||
public static final int RANGE_FILTER = 2;
|
||||
/**
|
||||
* 模糊过滤。
|
||||
*/
|
||||
public static final int LIKE_FILTER = 3;
|
||||
/**
|
||||
* IN LIST列表过滤。
|
||||
*/
|
||||
public static final int IN_LIST_FILTER = 4;
|
||||
/**
|
||||
* 用OR连接的多个模糊查询。
|
||||
*/
|
||||
public static final int MULTI_LIKE = 5;
|
||||
/**
|
||||
* NOT IN LIST列表过滤。
|
||||
*/
|
||||
public static final int NOT_IN_LIST_FILTER = 6;
|
||||
/**
|
||||
* NOT IN LIST列表过滤。
|
||||
*/
|
||||
public static final int IS_NULL = 7;
|
||||
/**
|
||||
* NOT IN LIST列表过滤。
|
||||
*/
|
||||
public static final int IS_NOT_NULL = 8;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(9);
|
||||
static {
|
||||
DICT_MAP.put(NO_FILTER, "无过滤");
|
||||
DICT_MAP.put(EQUAL_FILTER, "等于过滤");
|
||||
DICT_MAP.put(RANGE_FILTER, "范围过滤");
|
||||
DICT_MAP.put(LIKE_FILTER, "模糊过滤");
|
||||
DICT_MAP.put(IN_LIST_FILTER, "IN LIST列表过滤");
|
||||
DICT_MAP.put(MULTI_LIKE, "用OR连接的多个模糊查询");
|
||||
DICT_MAP.put(NOT_IN_LIST_FILTER, "NOT IN LIST列表过滤");
|
||||
DICT_MAP.put(IS_NULL, "IS NULL");
|
||||
DICT_MAP.put(IS_NOT_NULL, "IS NOT NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private FieldFilterType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字段类别常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class FieldKind {
|
||||
|
||||
/**
|
||||
* 文件上传字段。
|
||||
*/
|
||||
public static final int UPLOAD = 1;
|
||||
/**
|
||||
* 图片上传字段。
|
||||
*/
|
||||
public static final int UPLOAD_IMAGE = 2;
|
||||
/**
|
||||
* 富文本字段。
|
||||
*/
|
||||
public static final int RICH_TEXT = 3;
|
||||
/**
|
||||
* 字典多选字段。
|
||||
*/
|
||||
public static final int DICT_MULTI_SELECT = 4;
|
||||
/**
|
||||
* 创建人部门Id。
|
||||
*/
|
||||
public static final int CREATE_DEPT_ID = 19;
|
||||
/**
|
||||
* 创建时间字段。
|
||||
*/
|
||||
public static final int CREATE_TIME = 20;
|
||||
/**
|
||||
* 创建人字段。
|
||||
*/
|
||||
public static final int CREATE_USER_ID = 21;
|
||||
/**
|
||||
* 更新时间字段。
|
||||
*/
|
||||
public static final int UPDATE_TIME = 22;
|
||||
/**
|
||||
* 更新人字段。
|
||||
*/
|
||||
public static final int UPDATE_USER_ID = 23;
|
||||
/**
|
||||
* 包含自动编码。
|
||||
*/
|
||||
public static final int AUTO_CODE = 24;
|
||||
/**
|
||||
* 流程最后审批状态。
|
||||
*/
|
||||
public static final int FLOW_APPROVAL_STATUS = 25;
|
||||
/**
|
||||
* 流程结束状态。
|
||||
*/
|
||||
public static final int FLOW_FINISHED_STATUS = 26;
|
||||
/**
|
||||
* 脱敏字段。
|
||||
*/
|
||||
public static final int MASK_FIELD = 27;
|
||||
/**
|
||||
* 租户过滤字段。
|
||||
*/
|
||||
public static final int TENANT_FILTER = 28;
|
||||
/**
|
||||
* 逻辑删除字段。
|
||||
*/
|
||||
public static final int LOGIC_DELETE = 31;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(9);
|
||||
static {
|
||||
DICT_MAP.put(UPLOAD, "文件上传字段");
|
||||
DICT_MAP.put(UPLOAD_IMAGE, "图片上传字段");
|
||||
DICT_MAP.put(RICH_TEXT, "富文本字段");
|
||||
DICT_MAP.put(DICT_MULTI_SELECT, "字典多选字段");
|
||||
DICT_MAP.put(CREATE_DEPT_ID, "创建人部门字段");
|
||||
DICT_MAP.put(CREATE_TIME, "创建时间字段");
|
||||
DICT_MAP.put(CREATE_USER_ID, "创建人字段");
|
||||
DICT_MAP.put(UPDATE_TIME, "更新时间字段");
|
||||
DICT_MAP.put(UPDATE_USER_ID, "更新人字段");
|
||||
DICT_MAP.put(AUTO_CODE, "自动编码字段");
|
||||
DICT_MAP.put(FLOW_APPROVAL_STATUS, "流程最后审批状态");
|
||||
DICT_MAP.put(FLOW_FINISHED_STATUS, "流程结束状态");
|
||||
DICT_MAP.put(MASK_FIELD, "脱敏字段");
|
||||
DICT_MAP.put(TENANT_FILTER, "租户过滤字段");
|
||||
DICT_MAP.put(LOGIC_DELETE, "逻辑删除字段");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private FieldKind() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 表单类别常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class FormKind {
|
||||
|
||||
/**
|
||||
* 弹框。
|
||||
*/
|
||||
public static final int DIALOG = 1;
|
||||
/**
|
||||
* 跳页。
|
||||
*/
|
||||
public static final int NEW_PAGE = 5;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
||||
static {
|
||||
DICT_MAP.put(DIALOG, "弹框列表");
|
||||
DICT_MAP.put(NEW_PAGE, "跳页类别");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private FormKind() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 表单类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class FormType {
|
||||
|
||||
/**
|
||||
* 查询表单。
|
||||
*/
|
||||
public static final int QUERY = 1;
|
||||
/**
|
||||
* 左树右表表单。
|
||||
*/
|
||||
public static final int ADVANCED_QUERY = 2;
|
||||
/**
|
||||
* 一对一关联数据查询。
|
||||
*/
|
||||
public static final int ONE_TO_ONE_QUERY = 3;
|
||||
/**
|
||||
* 编辑表单。
|
||||
*/
|
||||
public static final int EDIT_FORM = 5;
|
||||
/**
|
||||
* 流程表单。
|
||||
*/
|
||||
public static final int FLOW = 10;
|
||||
/**
|
||||
* 流程工单表单。
|
||||
*/
|
||||
public static final int FLOW_WORK_ORDER = 11;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
||||
static {
|
||||
DICT_MAP.put(QUERY, "查询表单");
|
||||
DICT_MAP.put(ADVANCED_QUERY, "左树右表表单");
|
||||
DICT_MAP.put(ONE_TO_ONE_QUERY, "一对一关联数据查询");
|
||||
DICT_MAP.put(EDIT_FORM, "编辑表单");
|
||||
DICT_MAP.put(FLOW, "流程表单");
|
||||
DICT_MAP.put(FLOW_WORK_ORDER, "流程工单表单");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private FormType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 页面状态常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class PageStatus {
|
||||
|
||||
/**
|
||||
* 编辑基础信息。
|
||||
*/
|
||||
public static final int BASIC = 0;
|
||||
/**
|
||||
* 编辑数据模型。
|
||||
*/
|
||||
public static final int DATASOURCE = 1;
|
||||
/**
|
||||
* 设计表单。
|
||||
*/
|
||||
public static final int FORM_DESIGN = 2;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(4);
|
||||
static {
|
||||
DICT_MAP.put(BASIC, "编辑基础信息");
|
||||
DICT_MAP.put(DATASOURCE, "编辑数据模型");
|
||||
DICT_MAP.put(FORM_DESIGN, "设计表单");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private PageStatus() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 页面类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class PageType {
|
||||
|
||||
/**
|
||||
* 业务页面。
|
||||
*/
|
||||
public static final int BIZ = 1;
|
||||
/**
|
||||
* 统计页面。
|
||||
*/
|
||||
public static final int STATS = 5;
|
||||
/**
|
||||
* 流程页面。
|
||||
*/
|
||||
public static final int FLOW = 10;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
||||
static {
|
||||
DICT_MAP.put(BIZ, "业务页面");
|
||||
DICT_MAP.put(STATS, "统计页面");
|
||||
DICT_MAP.put(FLOW, "流程页面");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private PageType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 关联类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class RelationType {
|
||||
|
||||
/**
|
||||
* 一对一关联。
|
||||
*/
|
||||
public static final int ONE_TO_ONE = 0;
|
||||
/**
|
||||
* 一对多关联。
|
||||
*/
|
||||
public static final int ONE_TO_MANY = 1;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
||||
static {
|
||||
DICT_MAP.put(ONE_TO_ONE, "一对一关联");
|
||||
DICT_MAP.put(ONE_TO_MANY, "一对多关联");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private RelationType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 验证规则类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class RuleType {
|
||||
|
||||
/**
|
||||
* 只允许整数。
|
||||
*/
|
||||
public static final int INTEGER_ONLY = 1;
|
||||
/**
|
||||
* 只允许数字。
|
||||
*/
|
||||
public static final int DIGITAL_ONLY = 2;
|
||||
/**
|
||||
* 只允许英文字符。
|
||||
*/
|
||||
public static final int LETTER_ONLY = 3;
|
||||
/**
|
||||
* 范围验证。
|
||||
*/
|
||||
public static final int RANGE = 4;
|
||||
/**
|
||||
* 邮箱格式验证。
|
||||
*/
|
||||
public static final int EMAIL = 5;
|
||||
/**
|
||||
* 手机格式验证。
|
||||
*/
|
||||
public static final int MOBILE = 6;
|
||||
/**
|
||||
* 自定义验证。
|
||||
*/
|
||||
public static final int CUSTOM = 100;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(7);
|
||||
static {
|
||||
DICT_MAP.put(INTEGER_ONLY, "只允许整数");
|
||||
DICT_MAP.put(DIGITAL_ONLY, "只允许数字");
|
||||
DICT_MAP.put(LETTER_ONLY, "只允许英文字符");
|
||||
DICT_MAP.put(RANGE, "范围验证");
|
||||
DICT_MAP.put(EMAIL, "邮箱格式验证");
|
||||
DICT_MAP.put(MOBILE, "手机格式验证");
|
||||
DICT_MAP.put(CUSTOM, "自定义验证");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private RuleType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.orangeforms.common.online.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 在线表单虚拟字段类型常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public final class VirtualType {
|
||||
|
||||
/**
|
||||
* 聚合。
|
||||
*/
|
||||
public static final int AGGREGATION = 0;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
||||
static {
|
||||
DICT_MAP.put(AGGREGATION, "聚合");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private VirtualType() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.orangeforms.common.online.object;
|
||||
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 表字段数据对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ColumnData {
|
||||
|
||||
/**
|
||||
* 在线表字段对象。
|
||||
*/
|
||||
private OnlineColumn column;
|
||||
|
||||
/**
|
||||
* 字段值。
|
||||
*/
|
||||
private Object columnValue;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.orangeforms.common.online.object;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单常量字典的数据结构。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
public class ConstDictInfo {
|
||||
|
||||
private List<ConstDictData> dictData;
|
||||
|
||||
@Data
|
||||
public static class ConstDictData {
|
||||
private String type;
|
||||
private Object id;
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.orangeforms.common.online.object;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 连接表信息对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Data
|
||||
public class JoinTableInfo {
|
||||
|
||||
/**
|
||||
* 是否左连接。
|
||||
*/
|
||||
private Boolean leftJoin;
|
||||
|
||||
/**
|
||||
* 连接表表名。
|
||||
*/
|
||||
private String joinTableName;
|
||||
|
||||
/**
|
||||
* 连接条件。
|
||||
*/
|
||||
private String joinCondition;
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.core.object.CallResult;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import com.orangeforms.common.online.model.OnlineColumnRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 字段数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineColumnService extends IBaseService<OnlineColumn, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增数据表字段列表。
|
||||
*
|
||||
* @param columnList 新增数据表字段对象列表。
|
||||
* @param onlineTableId 在线表对象的主键Id。
|
||||
* @return 插入的在线表字段数据。
|
||||
*/
|
||||
List<OnlineColumn> saveNewList(List<SqlTableColumn> columnList, Long onlineTableId);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineColumn 更新的对象。
|
||||
* @param originalOnlineColumn 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn);
|
||||
|
||||
/**
|
||||
* 刷新数据库表字段的数据到在线表字段。
|
||||
*
|
||||
* @param sqlTableColumn 源数据库表字段对象。
|
||||
* @param onlineColumn 被刷新的在线表字段对象。
|
||||
*/
|
||||
void refresh(SqlTableColumn sqlTableColumn, OnlineColumn onlineColumn);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param tableId 表Id。
|
||||
* @param columnId 字段Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long tableId, Long columnId);
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param onlineColumnRuleList 多对多关联表对象集合。
|
||||
* @param columnId 主表Id。
|
||||
*/
|
||||
void addOnlineColumnRuleList(List<OnlineColumnRule> onlineColumnRuleList, Long columnId);
|
||||
|
||||
/**
|
||||
* 更新中间表数据。
|
||||
*
|
||||
* @param onlineColumnRule 中间表对象。
|
||||
* @return 更新成功与否。
|
||||
*/
|
||||
boolean updateOnlineColumnRule(OnlineColumnRule onlineColumnRule);
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param columnId 主表Id。
|
||||
* @param ruleId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
OnlineColumnRule getOnlineColumnRule(Long columnId, Long ruleId);
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param columnId 主表Id。
|
||||
* @param ruleId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean removeOnlineColumnRule(Long columnId, Long ruleId);
|
||||
|
||||
/**
|
||||
* 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。
|
||||
*
|
||||
* @param tableId 主表主键Id。
|
||||
* @return 删除数量。
|
||||
*/
|
||||
int removeByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 删除指定数据表Id集合中的表字段。
|
||||
*
|
||||
* @param tableIdSet 待删除的数据表Id集合。
|
||||
*/
|
||||
void removeByTableIdSet(Set<Long> tableIdSet);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineColumn> getOnlineColumnList(OnlineColumn filter);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineColumn> getOnlineColumnListWithRelation(OnlineColumn filter);
|
||||
|
||||
/**
|
||||
* 获取指定数据表Id集合的字段对象列表。
|
||||
*
|
||||
* @param tableIdSet 指定的数据表Id集合。
|
||||
* @return 数据表Id集合所包含的字段对象列表。
|
||||
*/
|
||||
List<OnlineColumn> getOnlineColumnListByTableIds(Set<Long> tableIdSet);
|
||||
|
||||
/**
|
||||
* 根据表Id和字段列名获取指定字段。
|
||||
*
|
||||
* @param tableId 字段所在表Id。
|
||||
* @param columnName 字段名。
|
||||
* @return 查询出的字段对象。
|
||||
*/
|
||||
OnlineColumn getOnlineColumnByTableIdAndColumnName(Long tableId, String columnName);
|
||||
|
||||
/**
|
||||
* 验证主键是否正确。
|
||||
*
|
||||
* @param tableColumn 数据库导入的表字段对象。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
CallResult verifyPrimaryKey(SqlTableColumn tableColumn);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceRelation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据关联数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDatasourceRelationService extends IBaseService<OnlineDatasourceRelation, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param relation 新增对象。
|
||||
* @param slaveSqlTable 新增的关联从数据表对象。
|
||||
* @param slaveSqlColumn 新增的关联从数据表对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineDatasourceRelation saveNew(
|
||||
OnlineDatasourceRelation relation, SqlTable slaveSqlTable, SqlTableColumn slaveSqlColumn);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param relation 更新的对象。
|
||||
* @param originalRelation 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param relationId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long relationId);
|
||||
|
||||
/**
|
||||
* 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。
|
||||
*
|
||||
* @param datasourceId 主表主键Id。
|
||||
* @return 删除数量。
|
||||
*/
|
||||
int removeByDatasourceId(Long datasourceId);
|
||||
|
||||
/**
|
||||
* 查询指定数据源Id的数据源关联对象列表。
|
||||
* 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。
|
||||
*
|
||||
* @param datasourceIdSet 数据源Id集合。
|
||||
* @return 在线数据源关联对象列表。
|
||||
*/
|
||||
List<OnlineDatasourceRelation> getOnlineDatasourceRelationListFromCache(Set<Long> datasourceIdSet);
|
||||
|
||||
/**
|
||||
* 查询指定数据源关联对象。
|
||||
* 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @param relationId 数据源关联Id。
|
||||
* @return 在线数据源关联对象。
|
||||
*/
|
||||
OnlineDatasourceRelation getOnlineDatasourceRelationFromCache(Long datasourceId, Long relationId);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceRelationList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDatasourceRelation> getOnlineDatasourceRelationListWithRelation(
|
||||
OnlineDatasourceRelation filter, String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.online.model.OnlineDatasource;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceTable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据模型数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDatasourceService extends IBaseService<OnlineDatasource, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineDatasource 新增对象。
|
||||
* @param sqlTable 新增的数据表对象。
|
||||
* @param pageId 关联的页面Id。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineDatasource saveNew(OnlineDatasource onlineDatasource, SqlTable sqlTable, Long pageId);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineDatasource 更新的对象。
|
||||
* @param originalOnlineDatasource 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineDatasource onlineDatasource, OnlineDatasource originalOnlineDatasource);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param datasourceId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long datasourceId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineDatasourceListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceList(OnlineDatasource filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 查询指定数据源Id的数据源对象。
|
||||
* 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @return 在线数据源对象。
|
||||
*/
|
||||
OnlineDatasource getOnlineDatasourceFromCache(Long datasourceId);
|
||||
|
||||
/**
|
||||
* 查询指定数据源Id集合的数据源列表。
|
||||
* 从缓存中读取,如果不存在会从数据库中读取并同步到Redis中。
|
||||
*
|
||||
* @param datasourceIdSet 数据源Id集合。
|
||||
* @return 在线数据源对象集合。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceListFromCache(Set<Long> datasourceIdSet);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceListWithRelation(OnlineDatasource filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param pageId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceListByPageId(Long pageId, OnlineDatasource filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取指定数据源Id集合所关联的在线表关联数据。
|
||||
*
|
||||
* @param datasourceIdSet 数据源Id集合。
|
||||
* @return 数据源和数据表的多对多关联列表。
|
||||
*/
|
||||
List<OnlineDatasourceTable> getOnlineDatasourceTableList(Set<Long> datasourceIdSet);
|
||||
|
||||
/**
|
||||
* 根据在线表单Id集合,获取关联的在线数据源对象列表。
|
||||
*
|
||||
* @param readFormIdSet 在线表单Id集合。
|
||||
* @return 与参数表单Id关联的数据源列表。
|
||||
*/
|
||||
List<OnlineDatasource> getOnlineDatasourceListByFormIds(Set<Long> readFormIdSet);
|
||||
|
||||
/**
|
||||
* 根据主表Id获取在线表单数据源对象。
|
||||
*
|
||||
* @param masterTableId 主表Id。
|
||||
* @return 在线表单数据源对象。
|
||||
*/
|
||||
OnlineDatasource getOnlineDatasourceByMasterTableId(Long masterTableId);
|
||||
|
||||
/**
|
||||
* 判断指定数据源变量是否存在。
|
||||
* @param variableName 变量名。
|
||||
* @return true存在,否则false。
|
||||
*/
|
||||
boolean existByVariableName(String variableName);
|
||||
|
||||
/**
|
||||
* 获取在线表单页面和在线表单数据源变量名的映射关系。
|
||||
*
|
||||
* @param pageIds 页面Id集合。
|
||||
* @return 在线表单页面和在线表单数据源变量名的映射关系。
|
||||
*/
|
||||
Map<Long, String> getPageIdAndVariableNameMapByPageIds(Set<Long> pageIds);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.online.model.OnlineDblink;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库链接数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDblinkService extends IBaseService<OnlineDblink, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineDblink 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineDblink saveNew(OnlineDblink onlineDblink);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineDblink 更新的对象。
|
||||
* @param originalOnlineDblink 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineDblink onlineDblink, OnlineDblink originalOnlineDblink);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param dblinkId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long dblinkId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineDblinkListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDblink> getOnlineDblinkList(OnlineDblink filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDblinkList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDblink> getOnlineDblinkListWithRelation(OnlineDblink filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取指定DBLink下面的全部数据表。
|
||||
*
|
||||
* @param dblink 数据库链接对象。
|
||||
* @return 全部数据表列表。
|
||||
*/
|
||||
List<SqlTable> getDblinkTableList(OnlineDblink dblink);
|
||||
|
||||
/**
|
||||
* 获取指定DBLink下,指定表名的数据表对象,及其关联字段列表。
|
||||
*
|
||||
* @param dblink 数据库链接对象。
|
||||
* @param tableName 数据库中的数据表名。
|
||||
* @return 数据表对象。
|
||||
*/
|
||||
SqlTable getDblinkTable(OnlineDblink dblink, String tableName);
|
||||
|
||||
/**
|
||||
* 获取指定DBLink下,指定表名的字段列表。
|
||||
*
|
||||
* @param dblink 数据库链接对象。
|
||||
* @param tableName 数据库中的数据表名。
|
||||
* @return 表的字段列表。
|
||||
*/
|
||||
List<SqlTableColumn> getDblinkTableColumnList(OnlineDblink dblink, String tableName);
|
||||
|
||||
/**
|
||||
* 获取指定DBLink下,指定表的字段对象。
|
||||
*
|
||||
* @param dblink 数据库链接对象。
|
||||
* @param tableName 数据库中的数据表名。
|
||||
* @param columnName 数据库中的数据表的字段名。
|
||||
* @return 表的字段对象。
|
||||
*/
|
||||
SqlTableColumn getDblinkTableColumn(OnlineDblink dblink, String tableName, String columnName);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.online.model.OnlineDict;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 在线表单字典数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineDictService extends IBaseService<OnlineDict, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineDict 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineDict saveNew(OnlineDict onlineDict);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineDict 更新的对象。
|
||||
* @param originalOnlineDict 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineDict onlineDict, OnlineDict originalOnlineDict);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param dictId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long dictId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineDictListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDict> getOnlineDictList(OnlineDict filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDictList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineDict> getOnlineDictListWithRelation(OnlineDict filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 从缓存中获取字典数据。
|
||||
*
|
||||
* @param dictId 字典Id。
|
||||
* @return 在线字典对象。
|
||||
*/
|
||||
OnlineDict getOnlineDictFromCache(Long dictId);
|
||||
|
||||
/**
|
||||
* 从缓存中获取字典数据集合。
|
||||
*
|
||||
* @param dictIdSet 字典Id集合。
|
||||
* @return 在线字典对象集合。
|
||||
*/
|
||||
List<OnlineDict> getOnlineDictListFromCache(Set<Long> dictIdSet);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.online.model.OnlineForm;
|
||||
import com.orangeforms.common.online.model.OnlineFormDatasource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 在线表单数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineFormService extends IBaseService<OnlineForm, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineForm 新增对象。
|
||||
* @param datasourceIdSet 在线表单关联的数据源Id集合。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineForm saveNew(OnlineForm onlineForm, Set<Long> datasourceIdSet);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineForm 更新的对象。
|
||||
* @param originalOnlineForm 原有数据对象。
|
||||
* @param datasourceIdSet 在线表单关联的数据源Id集合。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineForm onlineForm, OnlineForm originalOnlineForm, Set<Long> datasourceIdSet);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param formId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long formId);
|
||||
|
||||
/**
|
||||
* 根据PageId,删除其所属的所有表单,以及表单关联的数据源数据。
|
||||
*
|
||||
* @param pageId 指定的pageId。
|
||||
* @return 删除数量。
|
||||
*/
|
||||
int removeByPageId(Long pageId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineFormListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormList(OnlineForm filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineFormList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormListWithRelation(OnlineForm filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取使用指定数据表的表单列表。
|
||||
*
|
||||
* @param tableId 数据表Id。
|
||||
* @return 使用该数据表的表单列表。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormListByTableId(Long tableId);
|
||||
|
||||
/**
|
||||
* 获取指定表单的数据源列表。
|
||||
* 从缓存中读取,如果缓存中不存在,从数据库读取后同步更新到缓存。
|
||||
*
|
||||
* @param formId 指定的表单。
|
||||
* @return 表单和数据源的多对多关联对象列表。
|
||||
*/
|
||||
List<OnlineFormDatasource> getFormDatasourceListFromCache(Long formId);
|
||||
|
||||
/**
|
||||
* 查询正在使用当前数据源的表单。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @return 正在使用当前数据源的表单列表。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormListByDatasourceId(Long datasourceId);
|
||||
|
||||
/**
|
||||
* 查询指定PageId集合的在线表单列表。
|
||||
*
|
||||
* @param pageIdSet 页面Id集合。
|
||||
* @return 在线表单集合。
|
||||
*/
|
||||
List<OnlineForm> getOnlineFormListByPageIds(Set<Long> pageIdSet);
|
||||
|
||||
/**
|
||||
* 从缓存中获取表单数据。
|
||||
*
|
||||
* @param formId 表单Id。
|
||||
* @return 在线表单对象。
|
||||
*/
|
||||
OnlineForm getOnlineFormFromCache(Long formId);
|
||||
|
||||
/**
|
||||
* 判断指定编码的表单是否存在。
|
||||
*
|
||||
* @param formCode 表单编码。
|
||||
* @return true存在,否则false。
|
||||
*/
|
||||
boolean existByFormCode(String formCode);
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orangeforms.common.core.object.MyPageData;
|
||||
import com.orangeforms.common.core.object.MyPageParam;
|
||||
import com.orangeforms.common.online.dto.OnlineFilterDto;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceRelation;
|
||||
import com.orangeforms.common.online.model.OnlineDict;
|
||||
import com.orangeforms.common.online.model.OnlineTable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 在线表单运行时操作的数据服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineOperationService {
|
||||
|
||||
/**
|
||||
* 待批量插入的所有表数据。
|
||||
*
|
||||
* @param table 在线表对象。
|
||||
* @param dataList 数据对象列表。
|
||||
*/
|
||||
void saveNewBatch(OnlineTable table, List<JSONObject> dataList);
|
||||
|
||||
/**
|
||||
* 待插入的所有表数据。
|
||||
*
|
||||
* @param table 在线表对象。
|
||||
* @param data 数据对象。
|
||||
* @return 主键值。由于自增主键不能获取插入后的主键值,因此返回NULL。
|
||||
*/
|
||||
Object saveNew(OnlineTable table, JSONObject data);
|
||||
|
||||
/**
|
||||
* 待插入的主表数据和多个从表数据。
|
||||
*
|
||||
* @param masterTable 主表在线表对象。
|
||||
* @param masterData 主表数据对象。
|
||||
* @param slaveDataListMap 多个从表的数据字段数据。
|
||||
* @return 主表的主键值。由于自增主键不能获取插入后的主键值,因此返回NULL。
|
||||
*/
|
||||
Object saveNewWithRelation(
|
||||
OnlineTable masterTable,
|
||||
JSONObject masterData,
|
||||
Map<OnlineDatasourceRelation, List<JSONObject>> slaveDataListMap);
|
||||
|
||||
/**
|
||||
* 更新表数据。
|
||||
*
|
||||
* @param table 在线表对象。
|
||||
* @param data 单条表数据。
|
||||
* @return true 更新成功,否则false。
|
||||
*/
|
||||
boolean update(OnlineTable table, JSONObject data);
|
||||
|
||||
/**
|
||||
* 更新流程字段的状态。
|
||||
*
|
||||
* @param table 数据表。
|
||||
* @param dataId 主键Id。
|
||||
* @param column 更新字段。
|
||||
* @param dataValue 新的数据值。
|
||||
* @return true 更新成功,否则false。
|
||||
*/
|
||||
<T> boolean updateColumn(OnlineTable table, String dataId, OnlineColumn column, T dataValue);
|
||||
|
||||
/**
|
||||
* 级联更新主表和从表数据。
|
||||
*
|
||||
* @param masterTable 主表对象。
|
||||
* @param masterData 主表数据。
|
||||
* @param datasourceId 主表数据源Id。
|
||||
* @param slaveDataListMap 关联从表数据。
|
||||
*/
|
||||
void updateWithRelation(
|
||||
OnlineTable masterTable,
|
||||
JSONObject masterData,
|
||||
Long datasourceId,
|
||||
Map<OnlineDatasourceRelation, List<JSONObject>> slaveDataListMap);
|
||||
|
||||
/**
|
||||
* 更新关联从表的数据。
|
||||
*
|
||||
* @param masterTable 主表对象。
|
||||
* @param masterData 主表数据。
|
||||
* @param masterDataId 主表主键Id。
|
||||
* @param datasourceId 主表数据源Id。
|
||||
* @param relationId 关联Id。
|
||||
* @param slaveDataList 从表数据。
|
||||
*/
|
||||
void updateRelationData(
|
||||
OnlineTable masterTable,
|
||||
Map<String, Object> masterData,
|
||||
String masterDataId,
|
||||
Long datasourceId,
|
||||
Long relationId,
|
||||
List<JSONObject> slaveDataList);
|
||||
|
||||
/**
|
||||
* 删除主表数据,及其需要级联删除的一对多关联从表数据。
|
||||
*
|
||||
* @param table 表对象。
|
||||
* @param relationList 一对多关联对象列表。
|
||||
* @param dataId 主表主键Id值。
|
||||
* @return true 删除成功,否则false。
|
||||
*/
|
||||
boolean delete(OnlineTable table, List<OnlineDatasourceRelation> relationList, String dataId);
|
||||
|
||||
/**
|
||||
* 删除一对多从表数据中的关联数据。
|
||||
* 删除所有字段为slaveColumn,数据值为columnValue,但是主键值不在keptIdSet中的从表关联数据。
|
||||
*
|
||||
* @param slaveTable 一对多从表。
|
||||
* @param slaveColumn 从表关联字段。
|
||||
* @param columnValue 关联字段的值。
|
||||
* @param keptIdSet 被保留从表数据的主键Id值。
|
||||
*/
|
||||
void deleteOneToManySlaveData(
|
||||
OnlineTable slaveTable, OnlineColumn slaveColumn, String columnValue, Set<String> keptIdSet);
|
||||
|
||||
/**
|
||||
* 根据主键判断当前数据是否存在。
|
||||
*
|
||||
* @param table 主表对象。
|
||||
* @param dataId 主表主键Id值。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
boolean existId(OnlineTable table, String dataId);
|
||||
|
||||
/**
|
||||
* 从数据源和一对一数据源关联中,动态获取数据。
|
||||
*
|
||||
* @param table 主表对象。
|
||||
* @param oneToOneRelationList 数据源一对一关联列表。
|
||||
* @param allRelationList 数据源全部关联列表。
|
||||
* @param dataId 主表主键Id值。
|
||||
* @return 查询结果。
|
||||
*/
|
||||
Map<String, Object> getMasterData(
|
||||
OnlineTable table,
|
||||
List<OnlineDatasourceRelation> oneToOneRelationList,
|
||||
List<OnlineDatasourceRelation> allRelationList,
|
||||
String dataId);
|
||||
|
||||
/**
|
||||
* 从一对多数据源关联中,动态获取数据。
|
||||
*
|
||||
* @param relation 一对多数据源关联对象。
|
||||
* @param dataId 一对多关联数据主键Id值。
|
||||
* @return 查询结果。
|
||||
*/
|
||||
Map<String, Object> getSlaveData(OnlineDatasourceRelation relation, String dataId);
|
||||
|
||||
/**
|
||||
* 从数据源和一对一数据源关联中,动态获取数据列表。
|
||||
*
|
||||
* @param table 主表对象。
|
||||
* @param oneToOneRelationList 数据源一对一关联列表。
|
||||
* @param allRelationList 数据源全部关联列表。
|
||||
* @param filterList 过滤参数列表。
|
||||
* @param orderBy 排序字符串。
|
||||
* @param pageParam 分页对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
MyPageData<Map<String, Object>> getMasterDataList(
|
||||
OnlineTable table,
|
||||
List<OnlineDatasourceRelation> oneToOneRelationList,
|
||||
List<OnlineDatasourceRelation> allRelationList,
|
||||
List<OnlineFilterDto> filterList,
|
||||
String orderBy,
|
||||
MyPageParam pageParam);
|
||||
|
||||
/**
|
||||
* 从一对多数据源关联中,动态获取数据列表。
|
||||
*
|
||||
* @param relation 一对多数据源关联对象。
|
||||
* @param filterList 过滤参数列表。
|
||||
* @param orderBy 排序字符串。
|
||||
* @param pageParam 分页对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
MyPageData<Map<String, Object>> getSlaveDataList(
|
||||
OnlineDatasourceRelation relation, List<OnlineFilterDto> filterList, String orderBy, MyPageParam pageParam);
|
||||
|
||||
/**
|
||||
* 从字典对象指向的数据表中查询数据,并根据参数进行数据过滤。
|
||||
*
|
||||
* @param dict 字典对象。
|
||||
* @param filterList 过滤参数列表。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Map<String, Object>> getDictDataList(OnlineDict dict, List<OnlineFilterDto> filterList);
|
||||
|
||||
/**
|
||||
* 为主表及其关联表数据绑定字典数据。
|
||||
*
|
||||
* @param masterTable 主表对象。
|
||||
* @param relationList 主表依赖的关联列表。
|
||||
* @param dataList 数据列表。
|
||||
*/
|
||||
void buildDataListWithDict(
|
||||
OnlineTable masterTable, List<OnlineDatasourceRelation> relationList, List<Map<String, Object>> dataList);
|
||||
|
||||
/**
|
||||
* 获取在线表单所关联的权限数据,包括权限字列表和权限资源列表。
|
||||
*
|
||||
* @param menuFormIds 菜单关联的表单Id集合。
|
||||
* @param viewFormIds 查询权限的表单Id集合。
|
||||
* @param editFormIds 编辑权限的表单Id集合。
|
||||
* @return 在线表单权限数据。
|
||||
*/
|
||||
Map<String, Object> calculatePermData(Set<Long> menuFormIds, Set<Long> viewFormIds, Set<Long> editFormIds);
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.online.model.OnlinePage;
|
||||
import com.orangeforms.common.online.model.OnlinePageDatasource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单页面数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlinePageService extends IBaseService<OnlinePage, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlinePage 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlinePage saveNew(OnlinePage onlinePage);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlinePage 更新的对象。
|
||||
* @param originalOnlinePage 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlinePage onlinePage, OnlinePage originalOnlinePage);
|
||||
|
||||
/**
|
||||
* 更新页面对象的发布状态。
|
||||
*
|
||||
* @param pageId 页面对象Id。
|
||||
* @param published 新的状态。
|
||||
*/
|
||||
void updatePublished(Long pageId, Boolean published);
|
||||
|
||||
/**
|
||||
* 删除指定数据,及其包含的表单和数据源等。
|
||||
*
|
||||
* @param pageId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long pageId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlinePageListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlinePage> getOnlinePageList(OnlinePage filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlinePageList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlinePage> getOnlinePageListWithRelation(OnlinePage filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param onlinePageDatasourceList 多对多关联表对象集合。
|
||||
* @param pageId 主表Id。
|
||||
*/
|
||||
void addOnlinePageDatasourceList(List<OnlinePageDatasource> onlinePageDatasourceList, Long pageId);
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param pageId 主表Id。
|
||||
* @param datasourceId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
OnlinePageDatasource getOnlinePageDatasource(Long pageId, Long datasourceId);
|
||||
|
||||
/**
|
||||
* 获取在线页面和数据源中间表数据列表。
|
||||
*
|
||||
* @param pageId 主表Id。
|
||||
* @return 在线页面和数据源中间表对象列表。
|
||||
*/
|
||||
List<OnlinePageDatasource> getOnlinePageDatasourceListByPageId(Long pageId);
|
||||
|
||||
/**
|
||||
* 根据数据源Id,返回使用该数据源的OnlinePage对象。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @return 使用该数据源的页面列表。
|
||||
*/
|
||||
List<OnlinePage> getOnlinePageListByDatasourceId(Long datasourceId);
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param pageId 主表Id。
|
||||
* @param datasourceId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean removeOnlinePageDatasource(Long pageId, Long datasourceId);
|
||||
|
||||
/**
|
||||
* 判断指定编码的页面是否存在。
|
||||
*
|
||||
* @param pageCode 页面编码。
|
||||
* @return true存在,否则false。
|
||||
*/
|
||||
boolean existByPageCode(String pageCode);
|
||||
|
||||
/**
|
||||
* 查询主键Id集合中不存在的,且租户Id为NULL的在线表单页面列表。
|
||||
*
|
||||
* @param pageIds 主键Id集合。
|
||||
* @param orderBy 排序字符串。
|
||||
* @return 在线表单页面列表。
|
||||
*/
|
||||
List<OnlinePage> getNotInListWithNonTenant(List<Long> pageIds, String orderBy);
|
||||
|
||||
/**
|
||||
* 查询主键Id集合中存在的,且租户Id为NULL的在线表单页面列表。
|
||||
*
|
||||
* @param pageIds 主键Id集合。
|
||||
* @param orderBy 排序字符串。
|
||||
* @return 在线表单页面列表。
|
||||
*/
|
||||
List<OnlinePage> getInListWithNonTenant(List<Long> pageIds, String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.online.model.OnlineColumnRule;
|
||||
import com.orangeforms.common.online.model.OnlineRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 验证规则数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineRuleService extends IBaseService<OnlineRule, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineRule 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineRule saveNew(OnlineRule onlineRule);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineRule 更新的对象。
|
||||
* @param originalOnlineRule 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineRule onlineRule, OnlineRule originalOnlineRule);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param ruleId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long ruleId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineRuleListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineRule> getOnlineRuleList(OnlineRule filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineRuleList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineRule> getOnlineRuleListWithRelation(OnlineRule filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param columnId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineRule> getNotInOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param columnId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineRule> getOnlineRuleListByColumnId(Long columnId, OnlineRule filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 返回指定字段Id列表关联的字段规则对象列表。
|
||||
*
|
||||
* @param columnIdSet 指定的字段Id列表。
|
||||
* @return 关联的字段规则对象列表。
|
||||
*/
|
||||
List<OnlineColumnRule> getOnlineColumnRuleListByColumnIds(Set<Long> columnIdSet);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import com.orangeforms.common.online.model.OnlineTable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据表数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineTableService extends IBaseService<OnlineTable, Long> {
|
||||
|
||||
/**
|
||||
* 基于数据库表保存新增对象。
|
||||
*
|
||||
* @param sqlTable 数据库表对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineTable saveNewFromSqlTable(SqlTable sqlTable);
|
||||
|
||||
/**
|
||||
* 删除指定表及其关联的字段数据。
|
||||
*
|
||||
* @param tableId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long tableId);
|
||||
|
||||
/**
|
||||
* 删除指定数据表Id集合中的表,及其关联字段。
|
||||
*
|
||||
* @param tableIdSet 待删除的数据表Id集合。
|
||||
*/
|
||||
void removeByTableIdSet(Set<Long> tableIdSet);
|
||||
|
||||
/**
|
||||
* 根据数据源Id,获取该数据源及其关联所引用的数据表列表。
|
||||
*
|
||||
* @param datasourceId 指定的数据源Id。
|
||||
* @return 该数据源及其关联所引用的数据表列表。
|
||||
*/
|
||||
List<OnlineTable> getOnlineTableListByDatasourceId(Long datasourceId);
|
||||
|
||||
/**
|
||||
* 从缓存中获取指定的表数据及其关联字段列表。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。
|
||||
* 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。
|
||||
*
|
||||
* @param tableId 表主键Id。
|
||||
* @return 查询后的在线表对象。
|
||||
*/
|
||||
OnlineTable getOnlineTableFromCache(Long tableId);
|
||||
|
||||
/**
|
||||
* 从缓存中获取指定的表字段。优先从缓存中读取,如果不存在则从数据库中读取,并同步到缓存。
|
||||
* 该接口方法仅仅用户在线表单的动态数据操作接口,而非在线表单的配置接口。
|
||||
*
|
||||
* @param tableId 表主键Id。
|
||||
* @param columnId 字段Id。
|
||||
* @return 查询后的在线表对象。
|
||||
*/
|
||||
OnlineColumn getOnlineColumnFromCache(Long tableId, Long columnId);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.orangeforms.common.online.service;
|
||||
|
||||
import com.orangeforms.common.core.base.service.IBaseService;
|
||||
import com.orangeforms.common.online.model.OnlineVirtualColumn;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 虚拟字段数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
public interface OnlineVirtualColumnService extends IBaseService<OnlineVirtualColumn, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineVirtualColumn 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
OnlineVirtualColumn saveNew(OnlineVirtualColumn onlineVirtualColumn);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineVirtualColumn 更新的对象。
|
||||
* @param originalOnlineVirtualColumn 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(OnlineVirtualColumn onlineVirtualColumn, OnlineVirtualColumn originalOnlineVirtualColumn);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param virtualColumnId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long virtualColumnId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineVirtualColumnListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineVirtualColumn> getOnlineVirtualColumnList(OnlineVirtualColumn filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineVirtualColumnList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<OnlineVirtualColumn> getOnlineVirtualColumnListWithRelation(OnlineVirtualColumn filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据数据表的集合,查询关联的虚拟字段数据列表。
|
||||
* @param tableIdSet 在线数据表Id集合。
|
||||
* @return 关联的虚拟字段数据列表。
|
||||
*/
|
||||
List<OnlineVirtualColumn> getOnlineVirtualColumnListByTableIds(Set<Long> tableIdSet);
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.constant.ObjectFieldType;
|
||||
import com.orangeforms.common.core.exception.MyRuntimeException;
|
||||
import com.orangeforms.common.core.object.CallResult;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.upload.UploadStoreTypeEnum;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.dbutil.provider.DataSourceProvider;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.util.OnlineDataSourceUtil;
|
||||
import com.orangeforms.common.online.util.OnlineRedisKeyUtil;
|
||||
import com.orangeforms.common.online.dao.OnlineColumnMapper;
|
||||
import com.orangeforms.common.online.dao.OnlineColumnRuleMapper;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import com.orangeforms.common.online.model.OnlineColumnRule;
|
||||
import com.orangeforms.common.online.model.constant.FieldFilterType;
|
||||
import com.orangeforms.common.online.service.OnlineColumnService;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 字段数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlineColumnService")
|
||||
public class OnlineColumnServiceImpl extends BaseService<OnlineColumn, Long> implements OnlineColumnService {
|
||||
|
||||
@Autowired
|
||||
private OnlineColumnMapper onlineColumnMapper;
|
||||
@Autowired
|
||||
private OnlineColumnRuleMapper onlineColumnRuleMapper;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private OnlineDataSourceUtil dataSourceUtil;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlineColumn> mapper() {
|
||||
return onlineColumnMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增数据表字段列表。
|
||||
*
|
||||
* @param columnList 新增数据表字段对象列表。
|
||||
* @param onlineTableId 在线表对象的主键Id。
|
||||
* @return 插入的在线表字段数据。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public List<OnlineColumn> saveNewList(List<SqlTableColumn> columnList, Long onlineTableId) {
|
||||
List<OnlineColumn> onlineColumnList = new LinkedList<>();
|
||||
if (CollUtil.isEmpty(columnList)) {
|
||||
return onlineColumnList;
|
||||
}
|
||||
this.evictTableCache(onlineTableId);
|
||||
for (SqlTableColumn column : columnList) {
|
||||
OnlineColumn onlineColumn = new OnlineColumn();
|
||||
BeanUtil.copyProperties(column, onlineColumn, false);
|
||||
onlineColumn.setColumnId(idGenerator.nextLongId());
|
||||
onlineColumn.setTableId(onlineTableId);
|
||||
this.setDefault(column, onlineColumn);
|
||||
onlineColumnMapper.insert(onlineColumn);
|
||||
onlineColumnList.add(onlineColumn);
|
||||
}
|
||||
return onlineColumnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineColumn 更新的对象。
|
||||
* @param originalOnlineColumn 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlineColumn onlineColumn, OnlineColumn originalOnlineColumn) {
|
||||
this.evictTableCache(onlineColumn.getTableId());
|
||||
onlineColumn.setUpdateTime(new Date());
|
||||
onlineColumn.setUpdateUserId(TokenData.takeFromRequest().getUserId());
|
||||
onlineColumn.setCreateTime(originalOnlineColumn.getCreateTime());
|
||||
onlineColumn.setCreateUserId(originalOnlineColumn.getCreateUserId());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return onlineColumnMapper.update(onlineColumn, false) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新数据库表字段的数据到在线表字段。
|
||||
*
|
||||
* @param sqlTableColumn 源数据库表字段对象。
|
||||
* @param onlineColumn 被刷新的在线表字段对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void refresh(SqlTableColumn sqlTableColumn, OnlineColumn onlineColumn) {
|
||||
this.evictTableCache(onlineColumn.getTableId());
|
||||
BeanUtil.copyProperties(sqlTableColumn, onlineColumn, false);
|
||||
String objectFieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, onlineColumn.getColumnName());
|
||||
onlineColumn.setObjectFieldName(objectFieldName);
|
||||
String objectFieldType = convertToJavaType(onlineColumn, sqlTableColumn.getDblinkType());
|
||||
onlineColumn.setObjectFieldType(objectFieldType);
|
||||
onlineColumnMapper.update(onlineColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param tableId 表Id。
|
||||
* @param columnId 字段Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long tableId, Long columnId) {
|
||||
this.evictTableCache(tableId);
|
||||
return onlineColumnMapper.deleteById(columnId) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。
|
||||
*
|
||||
* @param tableId 主表主键Id。
|
||||
* @return 删除数量。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int removeByTableId(Long tableId) {
|
||||
return onlineColumnMapper.deleteByQuery(new QueryWrapper().eq(OnlineColumn::getTableId, tableId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据表Id集合中的表字段。
|
||||
*
|
||||
* @param tableIdSet 待删除的数据表Id集合。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void removeByTableIdSet(Set<Long> tableIdSet) {
|
||||
onlineColumnMapper.deleteByQuery(new QueryWrapper().in(OnlineColumn::getTableId, tableIdSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineColumn> getOnlineColumnList(OnlineColumn filter) {
|
||||
return onlineColumnMapper.getOnlineColumnList(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineColumn> getOnlineColumnListWithRelation(OnlineColumn filter) {
|
||||
List<OnlineColumn> resultList = onlineColumnMapper.getOnlineColumnList(filter);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定数据表Id集合的字段对象列表。
|
||||
*
|
||||
* @param tableIdSet 指定的数据表Id集合。
|
||||
* @return 数据表Id集合所包含的字段对象列表。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineColumn> getOnlineColumnListByTableIds(Set<Long> tableIdSet) {
|
||||
return onlineColumnMapper.selectListByQuery(new QueryWrapper().in(OnlineColumn::getTableId, tableIdSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表Id和字段列名获取指定字段。
|
||||
*
|
||||
* @param tableId 字段所在表Id。
|
||||
* @param columnName 字段名。
|
||||
* @return 查询出的字段对象。
|
||||
*/
|
||||
@Override
|
||||
public OnlineColumn getOnlineColumnByTableIdAndColumnName(Long tableId, String columnName) {
|
||||
OnlineColumn filter = new OnlineColumn();
|
||||
filter.setTableId(tableId);
|
||||
filter.setColumnName(columnName);
|
||||
return onlineColumnMapper.selectOneByQuery(QueryWrapper.create(filter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallResult verifyPrimaryKey(SqlTableColumn tableColumn) {
|
||||
Assert.isTrue(tableColumn.getPrimaryKey());
|
||||
OnlineColumn onlineColumn = new OnlineColumn();
|
||||
BeanUtil.copyProperties(tableColumn, onlineColumn, false);
|
||||
String javaType = this.convertToJavaType(onlineColumn, tableColumn.getDblinkType());
|
||||
if (ObjectFieldType.INTEGER.equals(javaType)) {
|
||||
if (BooleanUtil.isFalse(onlineColumn.getAutoIncrement())) {
|
||||
return CallResult.error("字段验证失败,整型主键必须是自增主键!");
|
||||
}
|
||||
} else {
|
||||
if (!StrUtil.equalsAny(javaType, ObjectFieldType.LONG, ObjectFieldType.STRING)) {
|
||||
return CallResult.error("字段验证失败,不合法的主键类型 [" + tableColumn.getColumnType() + "]!");
|
||||
}
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param onlineColumnRuleList 多对多关联表对象集合。
|
||||
* @param columnId 主表Id。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addOnlineColumnRuleList(List<OnlineColumnRule> onlineColumnRuleList, Long columnId) {
|
||||
this.evictTableCacheByColumnId(columnId);
|
||||
for (OnlineColumnRule onlineColumnRule : onlineColumnRuleList) {
|
||||
onlineColumnRule.setColumnId(columnId);
|
||||
onlineColumnRuleMapper.insert(onlineColumnRule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新中间表数据。
|
||||
*
|
||||
* @param onlineColumnRule 中间表对象。
|
||||
* @return 更新成功与否。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean updateOnlineColumnRule(OnlineColumnRule onlineColumnRule) {
|
||||
this.evictTableCacheByColumnId(onlineColumnRule.getColumnId());
|
||||
OnlineColumnRule filter = new OnlineColumnRule();
|
||||
filter.setColumnId(onlineColumnRule.getColumnId());
|
||||
filter.setRuleId(onlineColumnRule.getRuleId());
|
||||
return onlineColumnRuleMapper.updateByQuery(onlineColumnRule, false, QueryWrapper.create(filter)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param columnId 主表Id。
|
||||
* @param ruleId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
@Override
|
||||
public OnlineColumnRule getOnlineColumnRule(Long columnId, Long ruleId) {
|
||||
OnlineColumnRule filter = new OnlineColumnRule();
|
||||
filter.setColumnId(columnId);
|
||||
filter.setRuleId(ruleId);
|
||||
return onlineColumnRuleMapper.selectOneByQuery(QueryWrapper.create(filter));
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param columnId 主表Id。
|
||||
* @param ruleId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean removeOnlineColumnRule(Long columnId, Long ruleId) {
|
||||
this.evictTableCacheByColumnId(columnId);
|
||||
OnlineColumnRule filter = new OnlineColumnRule();
|
||||
filter.setColumnId(columnId);
|
||||
filter.setRuleId(ruleId);
|
||||
return onlineColumnRuleMapper.deleteByQuery(QueryWrapper.create(filter)) > 0;
|
||||
}
|
||||
|
||||
private void setDefault(SqlTableColumn column, OnlineColumn onlineColumn) {
|
||||
String objectFieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, onlineColumn.getColumnName());
|
||||
onlineColumn.setObjectFieldName(objectFieldName);
|
||||
String objectFieldType = convertToJavaType(onlineColumn, column.getDblinkType());
|
||||
onlineColumn.setObjectFieldType(objectFieldType);
|
||||
onlineColumn.setFilterType(FieldFilterType.NO_FILTER);
|
||||
onlineColumn.setParentKey(false);
|
||||
onlineColumn.setDeptFilter(false);
|
||||
onlineColumn.setUserFilter(false);
|
||||
if (onlineColumn.getAutoIncrement() == null) {
|
||||
onlineColumn.setAutoIncrement(false);
|
||||
}
|
||||
onlineColumn.setUploadFileSystemType(UploadStoreTypeEnum.LOCAL_SYSTEM.ordinal());
|
||||
Date now = new Date();
|
||||
onlineColumn.setUpdateTime(now);
|
||||
onlineColumn.setCreateTime(now);
|
||||
onlineColumn.setCreateUserId(TokenData.takeFromRequest().getUserId());
|
||||
onlineColumn.setUpdateUserId(onlineColumn.getCreateUserId());
|
||||
}
|
||||
|
||||
private void evictTableCache(Long tableId) {
|
||||
String tableIdKey = OnlineRedisKeyUtil.makeOnlineTableKey(tableId);
|
||||
redissonClient.getBucket(tableIdKey).delete();
|
||||
}
|
||||
|
||||
private void evictTableCacheByColumnId(Long columnId) {
|
||||
OnlineColumn column = this.getById(columnId);
|
||||
if (column != null) {
|
||||
this.evictTableCache(column.getTableId());
|
||||
}
|
||||
}
|
||||
|
||||
private String convertToJavaType(OnlineColumn column, int dblinkType) {
|
||||
DataSourceProvider provider = dataSourceUtil.getProvider(dblinkType);
|
||||
if (provider == null) {
|
||||
throw new MyRuntimeException("Unsupported Data Type");
|
||||
}
|
||||
return provider.convertColumnTypeToJavaType(
|
||||
column.getColumnType(), column.getNumericPrecision(), column.getNumericScale());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.object.CallResult;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.redis.util.CommonRedisUtil;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.util.OnlineRedisKeyUtil;
|
||||
import com.orangeforms.common.online.dao.OnlineDatasourceRelationMapper;
|
||||
import com.orangeforms.common.online.dao.OnlineDatasourceTableMapper;
|
||||
import com.orangeforms.common.online.model.OnlineColumn;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceRelation;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceTable;
|
||||
import com.orangeforms.common.online.model.OnlineTable;
|
||||
import com.orangeforms.common.online.service.OnlineColumnService;
|
||||
import com.orangeforms.common.online.service.OnlineDatasourceRelationService;
|
||||
import com.orangeforms.common.online.service.OnlineDatasourceService;
|
||||
import com.orangeforms.common.online.service.OnlineTableService;
|
||||
import com.github.pagehelper.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 数据源关联数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlineDatasourceRelationService")
|
||||
public class OnlineDatasourceRelationServiceImpl
|
||||
extends BaseService<OnlineDatasourceRelation, Long> implements OnlineDatasourceRelationService {
|
||||
|
||||
@Autowired
|
||||
private OnlineDatasourceRelationMapper onlineDatasourceRelationMapper;
|
||||
@Autowired
|
||||
private OnlineDatasourceTableMapper onlineDatasourceTableMapper;
|
||||
@Autowired
|
||||
private OnlineDatasourceService onlineDatasourceService;
|
||||
@Autowired
|
||||
private OnlineColumnService onlineColumnService;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private CommonRedisUtil commonRedisUtil;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlineDatasourceRelation> mapper() {
|
||||
return onlineDatasourceRelationMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param relation 新增对象。
|
||||
* @param slaveSqlTable 新增的关联从数据表对象。
|
||||
* @param slaveSqlColumn 新增的关联从数据表对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OnlineDatasourceRelation saveNew(
|
||||
OnlineDatasourceRelation relation, SqlTable slaveSqlTable, SqlTableColumn slaveSqlColumn) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId()));
|
||||
// 查找数据源关联的数据表,判断当前关联的从表,是否已经存在于zz_online_datasource_table中了。
|
||||
// 对于同一个数据源及其关联,同一个数据表只会被创建一次,如果已经和当前数据源的其他Relation,
|
||||
// 作为从表绑定了,怎么就可以直接使用这个OnlineTable了,否则就会为这个SqlTable,创建对应的OnlineTable。
|
||||
List<OnlineTable> datasourceTableList =
|
||||
onlineTableService.getOnlineTableListByDatasourceId(relation.getDatasourceId());
|
||||
OnlineTable relationSlaveTable = null;
|
||||
OnlineColumn relationSlaveColumn = null;
|
||||
for (OnlineTable onlineTable : datasourceTableList) {
|
||||
if (onlineTable.getTableName().equals(slaveSqlTable.getTableName())) {
|
||||
relationSlaveTable = onlineTable;
|
||||
relationSlaveColumn = onlineColumnService.getOnlineColumnByTableIdAndColumnName(
|
||||
onlineTable.getTableId(), slaveSqlColumn.getColumnName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (relationSlaveTable == null) {
|
||||
relationSlaveTable = onlineTableService.saveNewFromSqlTable(slaveSqlTable);
|
||||
for (OnlineColumn onlineColumn : relationSlaveTable.getColumnList()) {
|
||||
if (onlineColumn.getColumnName().equals(slaveSqlColumn.getColumnName())) {
|
||||
relationSlaveColumn = onlineColumn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
relation.setRelationId(idGenerator.nextLongId());
|
||||
relation.setAppCode(tokenData.getAppCode());
|
||||
relation.setSlaveTableId(relationSlaveTable.getTableId());
|
||||
relation.setSlaveColumnId(relationSlaveColumn == null ? null : relationSlaveColumn.getColumnId());
|
||||
Date now = new Date();
|
||||
relation.setUpdateTime(now);
|
||||
relation.setCreateTime(now);
|
||||
relation.setCreateUserId(tokenData.getUserId());
|
||||
relation.setUpdateUserId(tokenData.getUserId());
|
||||
onlineDatasourceRelationMapper.insert(relation);
|
||||
OnlineDatasourceTable datasourceTable = new OnlineDatasourceTable();
|
||||
datasourceTable.setId(idGenerator.nextLongId());
|
||||
datasourceTable.setDatasourceId(relation.getDatasourceId());
|
||||
datasourceTable.setRelationId(relation.getRelationId());
|
||||
datasourceTable.setTableId(relation.getSlaveTableId());
|
||||
onlineDatasourceTableMapper.insert(datasourceTable);
|
||||
return relation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param relation 更新的对象。
|
||||
* @param originalRelation 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId()));
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
relation.setAppCode(tokenData.getAppCode());
|
||||
relation.setUpdateTime(new Date());
|
||||
relation.setUpdateUserId(tokenData.getUserId());
|
||||
relation.setCreateTime(originalRelation.getCreateTime());
|
||||
relation.setCreateUserId(originalRelation.getCreateUserId());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return onlineDatasourceRelationMapper.update(relation, false) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param relationId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long relationId) {
|
||||
OnlineDatasourceRelation relation = this.getById(relationId);
|
||||
if (relation != null) {
|
||||
commonRedisUtil.evictFormCache(
|
||||
OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(relation.getDatasourceId()));
|
||||
}
|
||||
if (onlineDatasourceRelationMapper.deleteById(relationId) != 1) {
|
||||
return false;
|
||||
}
|
||||
OnlineDatasourceTable filter = new OnlineDatasourceTable();
|
||||
filter.setRelationId(relationId);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create(filter);
|
||||
OnlineDatasourceTable datasourceTable = onlineDatasourceTableMapper.selectOneByQuery(queryWrapper);
|
||||
onlineDatasourceTableMapper.deleteByQuery(queryWrapper);
|
||||
filter = new OnlineDatasourceTable();
|
||||
filter.setDatasourceId(datasourceTable.getDatasourceId());
|
||||
filter.setTableId(datasourceTable.getTableId());
|
||||
// 不在有引用该表的时候,可以删除该数据源关联引用的从表了。
|
||||
if (onlineDatasourceTableMapper.selectCountByQuery(QueryWrapper.create(filter)) == 0) {
|
||||
onlineTableService.remove(datasourceTable.getTableId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前服务的支持表为从表,根据主表的主键Id,删除一对多的从表数据。
|
||||
*
|
||||
* @param datasourceId 主表主键Id。
|
||||
* @return 删除数量。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int removeByDatasourceId(Long datasourceId) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(datasourceId));
|
||||
return onlineDatasourceRelationMapper.deleteByQuery(
|
||||
new QueryWrapper().eq(OnlineDatasourceRelation::getDatasourceId, datasourceId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineDatasourceRelation> getOnlineDatasourceRelationListFromCache(Set<Long> datasourceIdSet) {
|
||||
List<OnlineDatasourceRelation> resultList = new LinkedList<>();
|
||||
datasourceIdSet.forEach(datasourceId -> {
|
||||
String key = OnlineRedisKeyUtil.makeOnlineDataSourceRelationKey(datasourceId);
|
||||
RBucket<String> bucket = redissonClient.getBucket(key);
|
||||
if (bucket.isExists()) {
|
||||
resultList.addAll(JSONArray.parseArray(bucket.get(), OnlineDatasourceRelation.class));
|
||||
} else {
|
||||
OnlineDatasourceRelation filter = new OnlineDatasourceRelation();
|
||||
filter.setDatasourceId(datasourceId);
|
||||
List<OnlineDatasourceRelation> relationList = this.getListByFilter(filter);
|
||||
if (CollUtil.isNotEmpty(relationList)) {
|
||||
resultList.addAll(relationList);
|
||||
bucket.set(JSONArray.toJSONString(relationList));
|
||||
}
|
||||
}
|
||||
});
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineDatasourceRelation getOnlineDatasourceRelationFromCache(Long datasourceId, Long relationId) {
|
||||
List<OnlineDatasourceRelation> relationList =
|
||||
this.getOnlineDatasourceRelationListFromCache(CollUtil.newHashSet(datasourceId));
|
||||
if (CollUtil.isEmpty(relationList)) {
|
||||
return null;
|
||||
}
|
||||
return relationList.stream().filter(r -> r.getRelationId().equals(relationId)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceRelationList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDatasourceRelation> getOnlineDatasourceRelationListWithRelation(
|
||||
OnlineDatasourceRelation filter, String orderBy) {
|
||||
if (filter == null) {
|
||||
filter = new OnlineDatasourceRelation();
|
||||
}
|
||||
filter.setAppCode(TokenData.takeFromRequest().getAppCode());
|
||||
List<OnlineDatasourceRelation> resultList =
|
||||
onlineDatasourceRelationMapper.getOnlineDatasourceRelationList(filter, orderBy);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param relation 最新数据对象。
|
||||
* @param originalRelation 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(
|
||||
OnlineDatasourceRelation relation, OnlineDatasourceRelation originalRelation) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getMasterColumnId)
|
||||
&& !onlineColumnService.existId(relation.getMasterColumnId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "主表关联字段Id"));
|
||||
}
|
||||
if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getSlaveTableId)
|
||||
&& !onlineTableService.existId(relation.getSlaveTableId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "从表Id"));
|
||||
}
|
||||
if (this.needToVerify(relation, originalRelation, OnlineDatasourceRelation::getSlaveColumnId)
|
||||
&& !onlineColumnService.existId(relation.getSlaveColumnId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "从表关联字段Id"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.redis.util.CommonRedisUtil;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.dao.OnlineDatasourceMapper;
|
||||
import com.orangeforms.common.online.dao.OnlineDatasourceTableMapper;
|
||||
import com.orangeforms.common.online.dao.OnlinePageDatasourceMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDatasource;
|
||||
import com.orangeforms.common.online.model.OnlineDatasourceTable;
|
||||
import com.orangeforms.common.online.model.OnlinePageDatasource;
|
||||
import com.orangeforms.common.online.model.OnlineTable;
|
||||
import com.orangeforms.common.online.service.OnlineDatasourceRelationService;
|
||||
import com.orangeforms.common.online.service.OnlineDatasourceService;
|
||||
import com.orangeforms.common.online.service.OnlineTableService;
|
||||
import com.orangeforms.common.online.util.OnlineRedisKeyUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据模型数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlineDatasourceService")
|
||||
public class OnlineDatasourceServiceImpl extends BaseService<OnlineDatasource, Long> implements OnlineDatasourceService {
|
||||
|
||||
@Autowired
|
||||
private OnlineDatasourceMapper onlineDatasourceMapper;
|
||||
@Autowired
|
||||
private OnlinePageDatasourceMapper onlinePageDatasourceMapper;
|
||||
@Autowired
|
||||
private OnlineDatasourceTableMapper onlineDatasourceTableMapper;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private OnlineDatasourceRelationService onlineDatasourceRelationService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private CommonRedisUtil commonRedisUtil;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlineDatasource> mapper() {
|
||||
return onlineDatasourceMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineDatasource 新增对象。
|
||||
* @param sqlTable 新增的数据表对象。
|
||||
* @param pageId 关联的页面Id。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OnlineDatasource saveNew(OnlineDatasource onlineDatasource, SqlTable sqlTable, Long pageId) {
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
OnlineTable onlineTable = onlineTableService.saveNewFromSqlTable(sqlTable);
|
||||
onlineDatasource.setDatasourceId(idGenerator.nextLongId());
|
||||
onlineDatasource.setAppCode(tokenData.getAppCode());
|
||||
onlineDatasource.setMasterTableId(onlineTable.getTableId());
|
||||
Date now = new Date();
|
||||
onlineDatasource.setUpdateTime(now);
|
||||
onlineDatasource.setCreateTime(now);
|
||||
onlineDatasource.setCreateUserId(tokenData.getUserId());
|
||||
onlineDatasource.setUpdateUserId(tokenData.getUserId());
|
||||
onlineDatasourceMapper.insert(onlineDatasource);
|
||||
OnlineDatasourceTable datasourceTable = new OnlineDatasourceTable();
|
||||
datasourceTable.setId(idGenerator.nextLongId());
|
||||
datasourceTable.setDatasourceId(onlineDatasource.getDatasourceId());
|
||||
datasourceTable.setTableId(onlineDatasource.getMasterTableId());
|
||||
onlineDatasourceTableMapper.insert(datasourceTable);
|
||||
OnlinePageDatasource onlinePageDatasource = new OnlinePageDatasource();
|
||||
onlinePageDatasource.setId(idGenerator.nextLongId());
|
||||
onlinePageDatasource.setPageId(pageId);
|
||||
onlinePageDatasource.setDatasourceId(onlineDatasource.getDatasourceId());
|
||||
onlinePageDatasourceMapper.insert(onlinePageDatasource);
|
||||
return onlineDatasource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineDatasource 更新的对象。
|
||||
* @param originalOnlineDatasource 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlineDatasource onlineDatasource, OnlineDatasource originalOnlineDatasource) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceKey(onlineDatasource.getDatasourceId()));
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlineDatasource.setAppCode(tokenData.getAppCode());
|
||||
onlineDatasource.setUpdateTime(new Date());
|
||||
onlineDatasource.setUpdateUserId(tokenData.getUserId());
|
||||
onlineDatasource.setCreateTime(originalOnlineDatasource.getCreateTime());
|
||||
onlineDatasource.setCreateUserId(originalOnlineDatasource.getCreateUserId());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return onlineDatasourceMapper.update(onlineDatasource, false) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param datasourceId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long datasourceId) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDataSourceKey(datasourceId));
|
||||
if (onlineDatasourceMapper.deleteById(datasourceId) == 0) {
|
||||
return false;
|
||||
}
|
||||
onlineDatasourceRelationService.removeByDatasourceId(datasourceId);
|
||||
// 开始删除多对多父表的关联
|
||||
OnlinePageDatasource onlinePageDatasource = new OnlinePageDatasource();
|
||||
onlinePageDatasource.setDatasourceId(datasourceId);
|
||||
onlinePageDatasourceMapper.deleteByQuery(QueryWrapper.create(onlinePageDatasource));
|
||||
OnlineDatasourceTable filter = new OnlineDatasourceTable();
|
||||
filter.setDatasourceId(datasourceId);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create(filter);
|
||||
List<OnlineDatasourceTable> datasourceTableList = onlineDatasourceTableMapper.selectListByQuery(queryWrapper);
|
||||
onlineDatasourceTableMapper.deleteByQuery(queryWrapper);
|
||||
Set<Long> tableIdSet = datasourceTableList.stream()
|
||||
.map(OnlineDatasourceTable::getTableId).collect(Collectors.toSet());
|
||||
onlineTableService.removeByTableIdSet(tableIdSet);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineDatasourceListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDatasource> getOnlineDatasourceList(OnlineDatasource filter, String orderBy) {
|
||||
if (filter == null) {
|
||||
filter = new OnlineDatasource();
|
||||
}
|
||||
filter.setAppCode(TokenData.takeFromRequest().getAppCode());
|
||||
return onlineDatasourceMapper.getOnlineDatasourceList(filter, orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineDatasource getOnlineDatasourceFromCache(Long datasourceId) {
|
||||
String key = OnlineRedisKeyUtil.makeOnlineDataSourceKey(datasourceId);
|
||||
return commonRedisUtil.getFromCache(key, datasourceId, this::getById, OnlineDatasource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineDatasource> getOnlineDatasourceListFromCache(Set<Long> datasourceIdSet) {
|
||||
List<OnlineDatasource> resultList = new LinkedList<>();
|
||||
datasourceIdSet.forEach(datasourceId -> resultList.add(this.getOnlineDatasourceFromCache(datasourceId)));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDatasourceList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDatasource> getOnlineDatasourceListWithRelation(OnlineDatasource filter, String orderBy) {
|
||||
List<OnlineDatasource> resultList = this.getOnlineDatasourceList(filter, orderBy);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param pageId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDatasource> getOnlineDatasourceListByPageId(Long pageId, OnlineDatasource filter, String orderBy) {
|
||||
List<OnlineDatasource> resultList =
|
||||
onlineDatasourceMapper.getOnlineDatasourceListByPageId(pageId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定数据源Id集合所关联的在线表关联数据。
|
||||
*
|
||||
* @param datasourceIdSet 数据源Id集合。
|
||||
* @return 数据源和数据表的多对多关联列表。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDatasourceTable> getOnlineDatasourceTableList(Set<Long> datasourceIdSet) {
|
||||
return onlineDatasourceTableMapper.selectListByQuery(
|
||||
new QueryWrapper().in(OnlineDatasourceTable::getDatasourceId, datasourceIdSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据在线表单Id集合,获取关联的在线数据源对象列表。
|
||||
*
|
||||
* @param formIdSet 在线表单Id集合。
|
||||
* @return 与参数表单Id关联的数据源列表。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDatasource> getOnlineDatasourceListByFormIds(Set<Long> formIdSet) {
|
||||
return onlineDatasourceMapper.getOnlineDatasourceListByFormIds(formIdSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineDatasource getOnlineDatasourceByMasterTableId(Long masterTableId) {
|
||||
return onlineDatasourceMapper.selectOneByQuery(
|
||||
new QueryWrapper().eq(OnlineDatasource::getMasterTableId, masterTableId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existByVariableName(String variableName) {
|
||||
OnlineDatasource filter = new OnlineDatasource();
|
||||
filter.setVariableName(variableName);
|
||||
return CollUtil.isNotEmpty(this.getOnlineDatasourceList(filter, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getPageIdAndVariableNameMapByPageIds(Set<Long> pageIds) {
|
||||
String ids = CollUtil.join(pageIds, ",");
|
||||
List<Map<String, Object>> dataList = onlineDatasourceMapper.getPageIdAndVariableNameMapByPageIds(ids);
|
||||
return dataList.stream()
|
||||
.collect(Collectors.toMap(c -> (Long) c.get("page_id"), c -> (String) c.get("variable_name")));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.dbutil.constant.DblinkType;
|
||||
import com.orangeforms.common.dbutil.object.SqlTable;
|
||||
import com.orangeforms.common.dbutil.object.SqlTableColumn;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.config.OnlineProperties;
|
||||
import com.orangeforms.common.online.dao.OnlineDblinkMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDblink;
|
||||
import com.orangeforms.common.online.service.OnlineDblinkService;
|
||||
import com.orangeforms.common.online.util.OnlineDataSourceUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据库链接数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlineDblinkService")
|
||||
public class OnlineDblinkServiceImpl extends BaseService<OnlineDblink, Long> implements OnlineDblinkService {
|
||||
|
||||
@Autowired
|
||||
private OnlineDblinkMapper onlineDblinkMapper;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private OnlineProperties onlineProperties;
|
||||
@Autowired
|
||||
private OnlineDataSourceUtil dataSourceUtil;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlineDblink> mapper() {
|
||||
return onlineDblinkMapper;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OnlineDblink saveNew(OnlineDblink onlineDblink) {
|
||||
onlineDblinkMapper.insert(this.buildDefaultValue(onlineDblink));
|
||||
return onlineDblink;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlineDblink onlineDblink, OnlineDblink originalOnlineDblink) {
|
||||
if (!StrUtil.equals(onlineDblink.getConfiguration(), originalOnlineDblink.getConfiguration())) {
|
||||
dataSourceUtil.removeDataSource(onlineDblink.getDblinkId());
|
||||
}
|
||||
onlineDblink.setAppCode(TokenData.takeFromRequest().getAppCode());
|
||||
onlineDblink.setCreateUserId(originalOnlineDblink.getCreateUserId());
|
||||
onlineDblink.setUpdateUserId(TokenData.takeFromRequest().getUserId());
|
||||
onlineDblink.setCreateTime(originalOnlineDblink.getCreateTime());
|
||||
onlineDblink.setUpdateTime(new Date());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return onlineDblinkMapper.update(onlineDblink, false) == 1;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long dblinkId) {
|
||||
dataSourceUtil.removeDataSource(dblinkId);
|
||||
return onlineDblinkMapper.deleteById(dblinkId) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineDblink> getOnlineDblinkList(OnlineDblink filter, String orderBy) {
|
||||
if (filter == null) {
|
||||
filter = new OnlineDblink();
|
||||
}
|
||||
filter.setAppCode(TokenData.takeFromRequest().getAppCode());
|
||||
return onlineDblinkMapper.getOnlineDblinkList(filter, orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineDblink> getOnlineDblinkListWithRelation(OnlineDblink filter, String orderBy) {
|
||||
List<OnlineDblink> resultList = this.getOnlineDblinkList(filter, orderBy);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SqlTable> getDblinkTableList(OnlineDblink dblink) {
|
||||
List<SqlTable> resultList = dataSourceUtil.getTableList(dblink.getDblinkId(), null);
|
||||
if (StrUtil.isNotBlank(onlineProperties.getTablePrefix())) {
|
||||
resultList = resultList.stream()
|
||||
.filter(t -> StrUtil.startWith(t.getTableName(), onlineProperties.getTablePrefix()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
resultList.forEach(t -> t.setDblinkId(dblink.getDblinkId()));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTable getDblinkTable(OnlineDblink dblink, String tableName) {
|
||||
SqlTable sqlTable = dataSourceUtil.getTable(dblink.getDblinkId(), tableName);
|
||||
sqlTable.setDblinkId(dblink.getDblinkId());
|
||||
sqlTable.setColumnList(getDblinkTableColumnList(dblink, tableName));
|
||||
return sqlTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SqlTableColumn> getDblinkTableColumnList(OnlineDblink dblink, String tableName) {
|
||||
List<SqlTableColumn> columnList = dataSourceUtil.getTableColumnList(dblink.getDblinkId(), tableName);
|
||||
columnList.forEach(c -> this.makeupSqlTableColumn(c, dblink.getDblinkType()));
|
||||
return columnList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTableColumn getDblinkTableColumn(OnlineDblink dblink, String tableName, String columnName) {
|
||||
List<SqlTableColumn> columnList = dataSourceUtil.getTableColumnList(dblink.getDblinkId(), tableName);
|
||||
SqlTableColumn sqlTableColumn = columnList.stream()
|
||||
.filter(c -> c.getColumnName().equals(columnName)).findFirst().orElse(null);
|
||||
if (sqlTableColumn != null) {
|
||||
this.makeupSqlTableColumn(sqlTableColumn, dblink.getDblinkType());
|
||||
}
|
||||
return sqlTableColumn;
|
||||
}
|
||||
|
||||
private void makeupSqlTableColumn(SqlTableColumn sqlTableColumn, int dblinkType) {
|
||||
sqlTableColumn.setDblinkType(dblinkType);
|
||||
switch (dblinkType) {
|
||||
case DblinkType.POSTGRESQL:
|
||||
case DblinkType.OPENGAUSS:
|
||||
if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "char", "varchar")) {
|
||||
sqlTableColumn.setFullColumnType(
|
||||
sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")");
|
||||
} else {
|
||||
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType());
|
||||
}
|
||||
break;
|
||||
case DblinkType.MYSQL:
|
||||
sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra()));
|
||||
break;
|
||||
case DblinkType.ORACLE:
|
||||
if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR")) {
|
||||
sqlTableColumn.setFullColumnType(
|
||||
sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")");
|
||||
} else if (StrUtil.equals(sqlTableColumn.getColumnType(), "NUMBER")) {
|
||||
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType() +
|
||||
"(" + sqlTableColumn.getNumericPrecision() + "," + sqlTableColumn.getNumericScale() + ")");
|
||||
} else {
|
||||
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType());
|
||||
}
|
||||
break;
|
||||
case DblinkType.DAMENG:
|
||||
case DblinkType.KINGBASE:
|
||||
if (StrUtil.equalsAnyIgnoreCase(sqlTableColumn.getColumnType(), "VARCHAR", "VARCHAR2", "CHAR")) {
|
||||
sqlTableColumn.setFullColumnType(
|
||||
sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")");
|
||||
} else if (StrUtil.equals(sqlTableColumn.getColumnType(), "NUMBER")) {
|
||||
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType() +
|
||||
"(" + sqlTableColumn.getNumericPrecision() + "," + sqlTableColumn.getNumericScale() + ")");
|
||||
} else {
|
||||
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private OnlineDblink buildDefaultValue(OnlineDblink onlineDblink) {
|
||||
onlineDblink.setDblinkId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlineDblink.setCreateUserId(tokenData.getUserId());
|
||||
onlineDblink.setUpdateUserId(tokenData.getUserId());
|
||||
Date now = new Date();
|
||||
onlineDblink.setCreateTime(now);
|
||||
onlineDblink.setUpdateTime(now);
|
||||
onlineDblink.setAppCode(tokenData.getAppCode());
|
||||
return onlineDblink;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.object.CallResult;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.redis.util.CommonRedisUtil;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.util.OnlineRedisKeyUtil;
|
||||
import com.orangeforms.common.online.dao.OnlineDictMapper;
|
||||
import com.orangeforms.common.online.model.OnlineDict;
|
||||
import com.orangeforms.common.online.service.OnlineDblinkService;
|
||||
import com.orangeforms.common.online.service.OnlineDictService;
|
||||
import com.github.pagehelper.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 在线表单字典数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlineDictService")
|
||||
public class OnlineDictServiceImpl extends BaseService<OnlineDict, Long> implements OnlineDictService {
|
||||
|
||||
@Autowired
|
||||
private OnlineDictMapper onlineDictMapper;
|
||||
@Autowired
|
||||
private OnlineDblinkService dblinkService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private CommonRedisUtil commonRedisUtil;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlineDict> mapper() {
|
||||
return onlineDictMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineDict 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OnlineDict saveNew(OnlineDict onlineDict) {
|
||||
onlineDict.setDictId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlineDict.setAppCode(tokenData.getAppCode());
|
||||
Date now = new Date();
|
||||
onlineDict.setUpdateTime(now);
|
||||
onlineDict.setCreateTime(now);
|
||||
onlineDict.setCreateUserId(tokenData.getUserId());
|
||||
onlineDict.setUpdateUserId(tokenData.getUserId());
|
||||
onlineDictMapper.insert(onlineDict);
|
||||
return onlineDict;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineDict 更新的对象。
|
||||
* @param originalOnlineDict 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlineDict onlineDict, OnlineDict originalOnlineDict) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDictKey(onlineDict.getDictId()));
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlineDict.setAppCode(tokenData.getAppCode());
|
||||
onlineDict.setUpdateTime(new Date());
|
||||
onlineDict.setUpdateUserId(tokenData.getUserId());
|
||||
onlineDict.setCreateTime(originalOnlineDict.getCreateTime());
|
||||
onlineDict.setCreateUserId(originalOnlineDict.getCreateUserId());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return onlineDictMapper.update(onlineDict, false) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param dictId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long dictId) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineDictKey(dictId));
|
||||
return onlineDictMapper.deleteById(dictId) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineDictListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDict> getOnlineDictList(OnlineDict filter, String orderBy) {
|
||||
if (filter == null) {
|
||||
filter = new OnlineDict();
|
||||
}
|
||||
filter.setAppCode(TokenData.takeFromRequest().getAppCode());
|
||||
return onlineDictMapper.getOnlineDictList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineDictList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineDict> getOnlineDictListWithRelation(OnlineDict filter, String orderBy) {
|
||||
List<OnlineDict> resultList = this.getOnlineDictList(filter, orderBy);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineDict getOnlineDictFromCache(Long dictId) {
|
||||
String key = OnlineRedisKeyUtil.makeOnlineDictKey(dictId);
|
||||
return commonRedisUtil.getFromCache(key, dictId, this::getById, OnlineDict.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineDict> getOnlineDictListFromCache(Set<Long> dictIdSet) {
|
||||
List<OnlineDict> dictList = new LinkedList<>();
|
||||
dictIdSet.forEach(dictId -> {
|
||||
OnlineDict dict = this.getOnlineDictFromCache(dictId);
|
||||
if (dict != null) {
|
||||
dictList.add(dict);
|
||||
}
|
||||
});
|
||||
return dictList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param onlineDict 最新数据对象。
|
||||
* @param originalOnlineDict 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(OnlineDict onlineDict, OnlineDict originalOnlineDict) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(onlineDict, originalOnlineDict, OnlineDict::getDblinkId)
|
||||
&& !dblinkService.existId(onlineDict.getDblinkId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "数据库链接主键id"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.object.CallResult;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.redis.util.CommonRedisUtil;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.dao.OnlineFormDatasourceMapper;
|
||||
import com.orangeforms.common.online.dao.OnlineFormMapper;
|
||||
import com.orangeforms.common.online.model.OnlineForm;
|
||||
import com.orangeforms.common.online.model.OnlineFormDatasource;
|
||||
import com.orangeforms.common.online.service.OnlineFormService;
|
||||
import com.orangeforms.common.online.service.OnlinePageService;
|
||||
import com.orangeforms.common.online.service.OnlineTableService;
|
||||
import com.orangeforms.common.online.util.OnlineRedisKeyUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 在线表单数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlineFormService")
|
||||
public class OnlineFormServiceImpl extends BaseService<OnlineForm, Long> implements OnlineFormService {
|
||||
|
||||
@Autowired
|
||||
private OnlineFormMapper onlineFormMapper;
|
||||
@Autowired
|
||||
private OnlineFormDatasourceMapper onlineFormDatasourceMapper;
|
||||
@Autowired
|
||||
private OnlineTableService onlineTableService;
|
||||
@Autowired
|
||||
private OnlinePageService onlinePageService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private CommonRedisUtil commonRedisUtil;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlineForm> mapper() {
|
||||
return onlineFormMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlineForm 新增对象。
|
||||
* @param datasourceIdSet 在线表单关联的数据源Id集合。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OnlineForm saveNew(OnlineForm onlineForm, Set<Long> datasourceIdSet) {
|
||||
onlineForm.setFormId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlineForm.setAppCode(tokenData.getAppCode());
|
||||
onlineForm.setTenantId(tokenData.getTenantId());
|
||||
Date now = new Date();
|
||||
onlineForm.setUpdateTime(now);
|
||||
onlineForm.setCreateTime(now);
|
||||
onlineForm.setCreateUserId(tokenData.getUserId());
|
||||
onlineForm.setUpdateUserId(tokenData.getUserId());
|
||||
onlineFormMapper.insert(onlineForm);
|
||||
if (CollUtil.isNotEmpty(datasourceIdSet)) {
|
||||
for (Long datasourceId : datasourceIdSet) {
|
||||
OnlineFormDatasource onlineFormDatasource = new OnlineFormDatasource();
|
||||
onlineFormDatasource.setId(idGenerator.nextLongId());
|
||||
onlineFormDatasource.setFormId(onlineForm.getFormId());
|
||||
onlineFormDatasource.setDatasourceId(datasourceId);
|
||||
onlineFormDatasourceMapper.insert(onlineFormDatasource);
|
||||
}
|
||||
}
|
||||
return onlineForm;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlineForm 更新的对象。
|
||||
* @param originalOnlineForm 原有数据对象。
|
||||
* @param datasourceIdSet 在线表单关联的数据源Id集合。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlineForm onlineForm, OnlineForm originalOnlineForm, Set<Long> datasourceIdSet) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(onlineForm.getFormId()));
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(onlineForm.getFormId()));
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlineForm.setAppCode(tokenData.getAppCode());
|
||||
onlineForm.setTenantId(tokenData.getTenantId());
|
||||
onlineForm.setUpdateTime(new Date());
|
||||
onlineForm.setUpdateUserId(tokenData.getUserId());
|
||||
onlineForm.setCreateTime(originalOnlineForm.getCreateTime());
|
||||
onlineForm.setCreateUserId(originalOnlineForm.getCreateUserId());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
if (onlineFormMapper.update(onlineForm, false) != 1) {
|
||||
return false;
|
||||
}
|
||||
OnlineFormDatasource formDatasourceFilter = new OnlineFormDatasource();
|
||||
formDatasourceFilter.setFormId(onlineForm.getFormId());
|
||||
onlineFormDatasourceMapper.deleteByQuery(QueryWrapper.create(formDatasourceFilter));
|
||||
if (CollUtil.isNotEmpty(datasourceIdSet)) {
|
||||
for (Long datasourceId : datasourceIdSet) {
|
||||
OnlineFormDatasource onlineFormDatasource = new OnlineFormDatasource();
|
||||
onlineFormDatasource.setId(idGenerator.nextLongId());
|
||||
onlineFormDatasource.setFormId(onlineForm.getFormId());
|
||||
onlineFormDatasource.setDatasourceId(datasourceId);
|
||||
onlineFormDatasourceMapper.insert(onlineFormDatasource);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param formId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long formId) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(formId));
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId));
|
||||
if (onlineFormMapper.deleteById(formId) != 1) {
|
||||
return false;
|
||||
}
|
||||
OnlineFormDatasource formDatasourceFilter = new OnlineFormDatasource();
|
||||
formDatasourceFilter.setFormId(formId);
|
||||
onlineFormDatasourceMapper.deleteByQuery(QueryWrapper.create(formDatasourceFilter));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据PageId,删除其所属的所有表单,以及表单关联的数据源数据。
|
||||
*
|
||||
* @param pageId 指定的pageId。
|
||||
* @return 删除数量。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int removeByPageId(Long pageId) {
|
||||
OnlineForm filter = new OnlineForm();
|
||||
filter.setPageId(pageId);
|
||||
List<OnlineForm> formList = onlineFormMapper.selectListByQuery(QueryWrapper.create(filter));
|
||||
Set<Long> formIdSet = formList.stream().map(OnlineForm::getFormId).collect(Collectors.toSet());
|
||||
if (CollUtil.isNotEmpty(formIdSet)) {
|
||||
onlineFormDatasourceMapper.deleteByQuery(new QueryWrapper().in(OnlineFormDatasource::getFormId, formIdSet));
|
||||
for (Long formId : formIdSet) {
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormKey(formId));
|
||||
commonRedisUtil.evictFormCache(OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId));
|
||||
}
|
||||
}
|
||||
return onlineFormMapper.deleteByQuery(QueryWrapper.create(filter));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlineFormListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineForm> getOnlineFormList(OnlineForm filter, String orderBy) {
|
||||
if (filter == null) {
|
||||
filter = new OnlineForm();
|
||||
}
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
filter.setTenantId(tokenData.getTenantId());
|
||||
filter.setAppCode(tokenData.getAppCode());
|
||||
return onlineFormMapper.getOnlineFormList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlineFormList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineForm> getOnlineFormListWithRelation(OnlineForm filter, String orderBy) {
|
||||
List<OnlineForm> resultList = this.getOnlineFormList(filter, orderBy);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取使用指定数据表的表单列表。
|
||||
*
|
||||
* @param tableId 数据表Id。
|
||||
* @return 使用该数据表的表单列表。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineForm> getOnlineFormListByTableId(Long tableId) {
|
||||
OnlineForm filter = new OnlineForm();
|
||||
filter.setMasterTableId(tableId);
|
||||
return this.getOnlineFormList(filter, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineFormDatasource> getFormDatasourceListFromCache(Long formId) {
|
||||
String key = OnlineRedisKeyUtil.makeOnlineFormDatasourceKey(formId);
|
||||
RBucket<String> bucket = redissonClient.getBucket(key);
|
||||
if (bucket.isExists()) {
|
||||
return JSONArray.parseArray(bucket.get(), OnlineFormDatasource.class);
|
||||
}
|
||||
QueryWrapper queryWrapper = new QueryWrapper().eq(OnlineFormDatasource::getFormId, formId);
|
||||
List<OnlineFormDatasource> resultList = onlineFormDatasourceMapper.selectListByQuery(queryWrapper);
|
||||
bucket.set(JSONArray.toJSONString(resultList));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询正在使用当前数据源的表单。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @return 正在使用当前数据源的表单列表。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlineForm> getOnlineFormListByDatasourceId(Long datasourceId) {
|
||||
OnlineForm filter = new OnlineForm();
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
filter.setTenantId(tokenData.getTenantId());
|
||||
filter.setAppCode(tokenData.getAppCode());
|
||||
return onlineFormMapper.getOnlineFormListByDatasourceId(datasourceId, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnlineForm getOnlineFormFromCache(Long formId) {
|
||||
String key = OnlineRedisKeyUtil.makeOnlineFormKey(formId);
|
||||
return commonRedisUtil.getFromCache(key, formId, this::getById, OnlineForm.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existByFormCode(String formCode) {
|
||||
OnlineForm filter = new OnlineForm();
|
||||
filter.setFormCode(formCode);
|
||||
return CollUtil.isNotEmpty(this.getOnlineFormList(filter, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineForm> getOnlineFormListByPageIds(Set<Long> pageIdSet) {
|
||||
return onlineFormMapper.selectListByQuery(new QueryWrapper().eq(OnlineForm::getPageId, pageIdSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param onlineForm 最新数据对象。
|
||||
* @param originalOnlineForm 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(OnlineForm onlineForm, OnlineForm originalOnlineForm) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(onlineForm, originalOnlineForm, OnlineForm::getMasterTableId)
|
||||
&& !onlineTableService.existId(onlineForm.getMasterTableId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "表单主表id"));
|
||||
}
|
||||
//这里是一对多的验证
|
||||
if (this.needToVerify(onlineForm, originalOnlineForm, OnlineForm::getPageId)
|
||||
&& !onlinePageService.existId(onlineForm.getPageId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "页面id"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,295 @@
|
||||
package com.orangeforms.common.online.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
|
||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orangeforms.common.core.base.service.BaseService;
|
||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
||||
import com.orangeforms.common.core.object.MyRelationParam;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import com.orangeforms.common.core.util.MyModelUtil;
|
||||
import com.orangeforms.common.core.util.DefaultDataSourceResolver;
|
||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orangeforms.common.online.dao.OnlinePageDatasourceMapper;
|
||||
import com.orangeforms.common.online.dao.OnlinePageMapper;
|
||||
import com.orangeforms.common.online.model.OnlinePage;
|
||||
import com.orangeforms.common.online.model.OnlinePageDatasource;
|
||||
import com.orangeforms.common.online.model.constant.PageStatus;
|
||||
import com.orangeforms.common.online.service.OnlineDatasourceService;
|
||||
import com.orangeforms.common.online.service.OnlineFormService;
|
||||
import com.orangeforms.common.online.service.OnlinePageService;
|
||||
import com.github.pagehelper.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 在线表单页面数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2024-07-02
|
||||
*/
|
||||
@Slf4j
|
||||
@MyDataSourceResolver(
|
||||
resolver = DefaultDataSourceResolver.class,
|
||||
intArg = ApplicationConstant.COMMON_FLOW_AND_ONLINE_DATASOURCE_TYPE)
|
||||
@Service("onlinePageService")
|
||||
public class OnlinePageServiceImpl extends BaseService<OnlinePage, Long> implements OnlinePageService {
|
||||
|
||||
@Autowired
|
||||
private OnlinePageMapper onlinePageMapper;
|
||||
@Autowired
|
||||
private OnlinePageDatasourceMapper onlinePageDatasourceMapper;
|
||||
@Autowired
|
||||
private OnlineFormService onlineFormService;
|
||||
@Autowired
|
||||
private OnlineDatasourceService onlineDatasourceService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<OnlinePage> mapper() {
|
||||
return onlinePageMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param onlinePage 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OnlinePage saveNew(OnlinePage onlinePage) {
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlinePage.setPageId(idGenerator.nextLongId());
|
||||
onlinePage.setAppCode(tokenData.getAppCode());
|
||||
onlinePage.setTenantId(tokenData.getTenantId());
|
||||
Date now = new Date();
|
||||
onlinePage.setUpdateTime(now);
|
||||
onlinePage.setCreateTime(now);
|
||||
onlinePage.setCreateUserId(tokenData.getUserId());
|
||||
onlinePage.setUpdateUserId(tokenData.getUserId());
|
||||
onlinePage.setPublished(false);
|
||||
MyModelUtil.setDefaultValue(onlinePage, "status", PageStatus.BASIC);
|
||||
onlinePageMapper.insert(onlinePage);
|
||||
return onlinePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param onlinePage 更新的对象。
|
||||
* @param originalOnlinePage 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(OnlinePage onlinePage, OnlinePage originalOnlinePage) {
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
onlinePage.setAppCode(tokenData.getAppCode());
|
||||
onlinePage.setTenantId(tokenData.getTenantId());
|
||||
onlinePage.setUpdateTime(new Date());
|
||||
onlinePage.setUpdateUserId(tokenData.getUserId());
|
||||
onlinePage.setCreateTime(originalOnlinePage.getCreateTime());
|
||||
onlinePage.setCreateUserId(originalOnlinePage.getCreateUserId());
|
||||
onlinePage.setPublished(originalOnlinePage.getPublished());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return onlinePageMapper.update(onlinePage, false) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新页面对象的发布状态。
|
||||
*
|
||||
* @param pageId 页面对象Id。
|
||||
* @param published 新的状态。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updatePublished(Long pageId, Boolean published) {
|
||||
OnlinePage onlinePage = new OnlinePage();
|
||||
onlinePage.setPageId(pageId);
|
||||
onlinePage.setPublished(published);
|
||||
onlinePage.setUpdateTime(new Date());
|
||||
onlinePage.setUpdateUserId(TokenData.takeFromRequest().getUserId());
|
||||
onlinePageMapper.update(onlinePage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据,及其包含的表单和数据源等。
|
||||
*
|
||||
* @param pageId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long pageId) {
|
||||
if (onlinePageMapper.deleteById(pageId) == 0) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除关联表单。
|
||||
onlineFormService.removeByPageId(pageId);
|
||||
// 先获取出关联的表单和数据源。
|
||||
OnlinePageDatasource pageDatasourceFilter = new OnlinePageDatasource();
|
||||
pageDatasourceFilter.setPageId(pageId);
|
||||
List<OnlinePageDatasource> pageDatasourceList =
|
||||
onlinePageDatasourceMapper.selectListByQuery(QueryWrapper.create(pageDatasourceFilter));
|
||||
if (CollUtil.isNotEmpty(pageDatasourceList)) {
|
||||
for (OnlinePageDatasource pageDatasource : pageDatasourceList) {
|
||||
onlineDatasourceService.remove(pageDatasource.getDatasourceId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getOnlinePageListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlinePage> getOnlinePageList(OnlinePage filter, String orderBy) {
|
||||
if (filter == null) {
|
||||
filter = new OnlinePage();
|
||||
}
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
filter.setTenantId(tokenData.getTenantId());
|
||||
filter.setAppCode(tokenData.getAppCode());
|
||||
return onlinePageMapper.getOnlinePageList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getOnlinePageList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlinePage> getOnlinePageListWithRelation(OnlinePage filter, String orderBy) {
|
||||
List<OnlinePage> resultList = this.getOnlinePageList(filter, orderBy);
|
||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param onlinePageDatasourceList 多对多关联表对象集合。
|
||||
* @param pageId 主表Id。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addOnlinePageDatasourceList(List<OnlinePageDatasource> onlinePageDatasourceList, Long pageId) {
|
||||
for (OnlinePageDatasource onlinePageDatasource : onlinePageDatasourceList) {
|
||||
onlinePageDatasource.setPageId(pageId);
|
||||
onlinePageDatasourceMapper.insert(onlinePageDatasource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param pageId 主表Id。
|
||||
* @param datasourceId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
@Override
|
||||
public OnlinePageDatasource getOnlinePageDatasource(Long pageId, Long datasourceId) {
|
||||
OnlinePageDatasource filter = new OnlinePageDatasource();
|
||||
filter.setPageId(pageId);
|
||||
filter.setDatasourceId(datasourceId);
|
||||
return onlinePageDatasourceMapper.selectOneByQuery(QueryWrapper.create(filter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlinePageDatasource> getOnlinePageDatasourceListByPageId(Long pageId) {
|
||||
return onlinePageDatasourceMapper.selectListByQuery(
|
||||
new QueryWrapper().eq(OnlinePageDatasource::getPageId, pageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数据源Id,返回使用该数据源的OnlinePage对象。
|
||||
*
|
||||
* @param datasourceId 数据源Id。
|
||||
* @return 使用该数据源的页面列表。
|
||||
*/
|
||||
@Override
|
||||
public List<OnlinePage> getOnlinePageListByDatasourceId(Long datasourceId) {
|
||||
OnlinePage filter = new OnlinePage();
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
filter.setTenantId(tokenData.getTenantId());
|
||||
filter.setAppCode(tokenData.getAppCode());
|
||||
return onlinePageMapper.getOnlinePageListByDatasourceId(datasourceId, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param pageId 主表Id。
|
||||
* @param datasourceId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean removeOnlinePageDatasource(Long pageId, Long datasourceId) {
|
||||
OnlinePageDatasource filter = new OnlinePageDatasource();
|
||||
filter.setPageId(pageId);
|
||||
filter.setDatasourceId(datasourceId);
|
||||
return onlinePageDatasourceMapper.deleteByQuery(QueryWrapper.create(filter)) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existByPageCode(String pageCode) {
|
||||
OnlinePage filter = new OnlinePage();
|
||||
filter.setPageCode(pageCode);
|
||||
return CollUtil.isNotEmpty(this.getOnlinePageList(filter, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlinePage> getNotInListWithNonTenant(List<Long> pageIds, String orderBy) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (CollUtil.isNotEmpty(pageIds)) {
|
||||
queryWrapper.notIn(OnlinePage::getPageId, pageIds);
|
||||
}
|
||||
queryWrapper.isNull(OnlinePage::getTenantId);
|
||||
if (StrUtil.isNotBlank(orderBy)) {
|
||||
queryWrapper.orderBy(orderBy);
|
||||
}
|
||||
return onlinePageMapper.selectListByQuery(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlinePage> getInListWithNonTenant(List<Long> pageIds, String orderBy) {
|
||||
if (CollUtil.isEmpty(pageIds)) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.in(OnlinePage::getPageId, pageIds);
|
||||
queryWrapper.isNull(OnlinePage::getTenantId);
|
||||
if (StrUtil.isNotBlank(orderBy)) {
|
||||
queryWrapper.orderBy(orderBy);
|
||||
}
|
||||
return onlinePageMapper.selectListByQuery(queryWrapper);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user