feat(): 规则维护页面,列表,添加功能
parent
4b62c4c7ab
commit
866b3835cb
|
@ -29,13 +29,13 @@ public class EngineRule extends BaseEntity {
|
|||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Excel(name = "规则名称")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package com.etl.data.rule.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.etl.common.core.annotation.Excel;
|
||||
import com.etl.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 引擎规则版本对象 engine_rule_version
|
||||
*
|
||||
* @author Chao
|
||||
* @date 2024-05-07
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("engine_rule_version")
|
||||
public class EngineRuleVersion extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则id
|
||||
*/
|
||||
@Excel(name = "规则id")
|
||||
private Long engineRuleId;
|
||||
|
||||
/**
|
||||
* 版本类
|
||||
*/
|
||||
@Excel(name = "版本类")
|
||||
private String versionClass;
|
||||
|
||||
/**
|
||||
* 版本名
|
||||
*/
|
||||
@Excel(name = "版本名")
|
||||
private String versionName;
|
||||
|
||||
/**
|
||||
* 版本编码
|
||||
*/
|
||||
@Excel(name = "版本编码")
|
||||
private String versionCode;
|
||||
|
||||
/**
|
||||
* 状态( 1- 初始化 2- 待发布 3-已发布 4-其他)
|
||||
*/
|
||||
@Excel(name = "状态( 1- 初始化 2- 待发布 3-已发布 4-其他)")
|
||||
private Long versionType;
|
||||
|
||||
/**
|
||||
* 是否激活(Y - 激活 N- 未激活)
|
||||
*/
|
||||
@Excel(name = "是否激活(Y - 激活 N- 未激活)")
|
||||
private String activatedOrNot;
|
||||
|
||||
/**
|
||||
* 是否测试(Y - 测试通过 N - 通过不了 D - 待测试)
|
||||
*/
|
||||
@Excel(name = "是否测试(Y - 测试通过 N - 通过不了 D - 待测试)")
|
||||
private String yesNoTest;
|
||||
|
||||
/**
|
||||
* 引擎编码
|
||||
*/
|
||||
@Excel(name = "引擎编码")
|
||||
private String codeText;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "描述")
|
||||
private String description;
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.etl.data.rule.domain.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.etl.data.rule.domain.EngineRule;
|
||||
import com.etl.data.rule.domain.EngineRuleVersion;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 引擎维护和引擎规则版本返回类
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: EngineRuleAndEngineRuleVersionResp 引擎维护和引擎规则版本返回类
|
||||
* @CreateTime: 2024/5/7 下午8:17
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EngineRuleAndEngineRuleVersionResp {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规则类型(1-规则模板 2-自定义模板)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 规则作用域(1-数据字段 2-数据集 3-记录)
|
||||
*/
|
||||
private Long scope;
|
||||
|
||||
/**
|
||||
* 引擎编码
|
||||
*/
|
||||
private String encoding;
|
||||
|
||||
/**
|
||||
* 是否激活(Y-激活 N-未激活)
|
||||
*/
|
||||
private String activatedOrNot;
|
||||
|
||||
/**
|
||||
* 规则状态(Y-正常 N-停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 编辑代码文本
|
||||
*/
|
||||
private String codeText;
|
||||
|
||||
/**
|
||||
* 规则版本列表
|
||||
*/
|
||||
private List<EngineRuleVersion> engineRuleVersionList;
|
||||
|
||||
public static EngineRuleAndEngineRuleVersionResp engineRuleAndEngineRuleVersionBuild(EngineRule engineRule, List<EngineRuleVersion> ruleVersionList) {
|
||||
return EngineRuleAndEngineRuleVersionResp.builder()
|
||||
.id(engineRule.getId())
|
||||
.name(engineRule.getName())
|
||||
.type(engineRule.getType())
|
||||
.scope(engineRule.getScope())
|
||||
.encoding(engineRule.getEncoding())
|
||||
.activatedOrNot(engineRule.getActivatedOrNot())
|
||||
.status(engineRule.getStatus())
|
||||
.description(engineRule.getDescription())
|
||||
.codeText(engineRule.getCodeText())
|
||||
.engineRuleVersionList(ruleVersionList)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import com.etl.common.log.annotation.Log;
|
|||
import com.etl.common.log.enums.BusinessType;
|
||||
import com.etl.common.security.annotation.RequiresPermissions;
|
||||
import com.etl.data.rule.domain.EngineRule;
|
||||
import com.etl.data.rule.domain.resp.EngineRuleAndEngineRuleVersionResp;
|
||||
import com.etl.data.rule.service.IEngineRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -90,6 +91,39 @@ public class EngineRuleController extends BaseController {
|
|||
return toAjax(engineRuleService.deleteEngineRuleByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改引擎维护激活
|
||||
*/
|
||||
@RequiresPermissions("data:engine:editActivatedOrNot")
|
||||
@Log(title = "引擎维护", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/editActivatedOrNot")
|
||||
public Result editActivatedOrNot(@RequestBody EngineRule engineRule) {
|
||||
return success(engineRuleService.editEngineRuleActivatedOrNot(engineRule));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改引擎维护激活
|
||||
*/
|
||||
@RequiresPermissions("data:engine:editStatus")
|
||||
@Log(title = "引擎维护", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/editStatus")
|
||||
public Result editStatus(@RequestBody EngineRule engineRule) {
|
||||
return toAjax(engineRuleService.editStatus(engineRule));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取引擎维护详细信息和版本列表
|
||||
*/
|
||||
@RequiresPermissions("data:engine:queryEngineAndEngineVersion")
|
||||
@GetMapping(value = "queryEngineAndEngineVersion/{id}")
|
||||
public Result<EngineRuleAndEngineRuleVersionResp> queryEngineAndEngineVersion(@PathVariable("id") Long id) {
|
||||
return Result.success(engineRuleService.queryEngineAndEngineVersion(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化规则引擎类
|
||||
* @param engineRule
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.etl.data.rule.controller;
|
||||
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.common.log.annotation.Log;
|
||||
import com.etl.common.log.enums.BusinessType;
|
||||
import com.etl.common.security.annotation.RequiresPermissions;
|
||||
import com.etl.data.rule.domain.EngineRuleVersion;
|
||||
import com.etl.data.rule.service.IEngineRuleVersionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 引擎维护版本Controller
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: EngineRuleVersionController 引擎维护版本Controller
|
||||
* @CreateTime: 2024/5/7 下午6:46
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/engineVersion")
|
||||
public class EngineRuleVersionController {
|
||||
|
||||
@Autowired
|
||||
private IEngineRuleVersionService engineRuleVersionService;
|
||||
|
||||
|
||||
/**
|
||||
* 新增引擎维护
|
||||
*/
|
||||
@RequiresPermissions("data:engineVersion:add")
|
||||
@Log(title = "引擎维护", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody EngineRuleVersion engineRuleVersion) {
|
||||
return Result.success(engineRuleVersionService.saveEngineRuleVersion(engineRuleVersion));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.etl.data.rule.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.data.rule.domain.EngineRuleVersion;
|
||||
|
||||
/**
|
||||
* 引擎维护Mapper接口
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: EngineRuleVersionMapper 引擎维护Mapper接口
|
||||
* @CreateTime: 2024/5/7 下午6:44
|
||||
*/
|
||||
public interface EngineRuleVersionMapper extends BaseMapper<EngineRuleVersion> {
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.etl.data.rule.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.data.rule.domain.EngineRule;
|
||||
import com.etl.data.rule.domain.resp.EngineRuleAndEngineRuleVersionResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -64,4 +65,27 @@ public interface IEngineRuleService extends IService<EngineRule> {
|
|||
Result initializeRuleMaintenance(EngineRule engineRule);
|
||||
|
||||
Result testMethod(String code);
|
||||
|
||||
/**
|
||||
* 修改引擎维护是否激活
|
||||
*
|
||||
* @param engineRule 引擎维护
|
||||
* @return 结果
|
||||
*/
|
||||
boolean editEngineRuleActivatedOrNot(EngineRule engineRule);
|
||||
|
||||
/**
|
||||
* 修改引擎维护状态
|
||||
*
|
||||
* @param engineRule
|
||||
* @return
|
||||
*/
|
||||
boolean editStatus(EngineRule engineRule);
|
||||
|
||||
/**
|
||||
* 查询引擎维护和版本
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
EngineRuleAndEngineRuleVersionResp queryEngineAndEngineVersion(Long id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.etl.data.rule.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.data.rule.domain.EngineRuleVersion;
|
||||
|
||||
/**
|
||||
* 引擎维护版本Service接口
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: IEngineRuleVersionService 引擎维护版本Service接口
|
||||
* @CreateTime: 2024/5/7 下午6:42
|
||||
*/
|
||||
public interface IEngineRuleVersionService extends IService<EngineRuleVersion> {
|
||||
/**
|
||||
* 保存引擎维护版本
|
||||
*
|
||||
* @param engineRuleVersion
|
||||
* @return
|
||||
*/
|
||||
boolean saveEngineRuleVersion(EngineRuleVersion engineRuleVersion);
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
package com.etl.data.rule.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.common.core.domain.Result;
|
||||
import com.etl.common.core.utils.DateUtils;
|
||||
import com.etl.data.rule.domain.EngineRule;
|
||||
import com.etl.data.rule.domain.EngineRuleVersion;
|
||||
import com.etl.data.rule.domain.resp.EngineRuleAndEngineRuleVersionResp;
|
||||
import com.etl.data.rule.mapper.EngineRuleMapper;
|
||||
import com.etl.data.rule.service.IEngineRuleService;
|
||||
import com.etl.data.rule.service.IEngineRuleVersionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -21,6 +26,7 @@ import java.net.URLClassLoader;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 引擎维护Service业务层处理
|
||||
|
@ -33,6 +39,9 @@ public class EngineRuleServiceImpl extends ServiceImpl<EngineRuleMapper, EngineR
|
|||
@Autowired
|
||||
private EngineRuleMapper engineRuleMapper;
|
||||
|
||||
@Autowired
|
||||
private IEngineRuleVersionService engineRuleVersionService;
|
||||
|
||||
/**
|
||||
* 查询引擎维护
|
||||
*
|
||||
|
@ -187,6 +196,72 @@ public class EngineRuleServiceImpl extends ServiceImpl<EngineRuleMapper, EngineR
|
|||
return Result.success(null, "测试成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改引擎维护激活
|
||||
*
|
||||
* @param engineRule 引擎维护
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean editEngineRuleActivatedOrNot(EngineRule engineRule) {
|
||||
String activateOrNot = null;
|
||||
if ("Y".equals(engineRule.getStatus())) {
|
||||
if ("Y".equals(engineRule.getActivatedOrNot())) {
|
||||
activateOrNot = "N";
|
||||
} else if ("N".equals(engineRule.getActivatedOrNot())) {
|
||||
activateOrNot = "Y";
|
||||
}
|
||||
return this.update(
|
||||
new LambdaUpdateWrapper<EngineRule>()
|
||||
.eq(EngineRule::getId, engineRule.getId())
|
||||
.set(EngineRule::getActivatedOrNot, activateOrNot)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改引擎维护状态
|
||||
*
|
||||
* @param engineRule
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean editStatus(EngineRule engineRule) {
|
||||
String status = null;
|
||||
if ("Y".equals(engineRule.getStatus())) {
|
||||
status = "N";
|
||||
} else if ("N".equals(engineRule.getStatus())) {
|
||||
status = "Y";
|
||||
}
|
||||
return this.update(
|
||||
new LambdaUpdateWrapper<EngineRule>()
|
||||
.eq(EngineRule::getId, engineRule.getId())
|
||||
.set(EngineRule::getStatus, status)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询引擎维护和引擎版本
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public EngineRuleAndEngineRuleVersionResp queryEngineAndEngineVersion(Long id) {
|
||||
// 引擎维护
|
||||
EngineRule engineRule = this.getOne(
|
||||
new LambdaQueryWrapper<EngineRule>()
|
||||
.eq(EngineRule::getId, id)
|
||||
);
|
||||
List<EngineRuleVersion> engineRuleVersionList = engineRuleVersionService.list();
|
||||
List<EngineRuleVersion> ruleVersionList = engineRuleVersionList.stream()
|
||||
.filter(
|
||||
engineRuleVersion -> engineRuleVersion.getEngineRuleId().equals(engineRule.getId())
|
||||
).collect(Collectors.toList());
|
||||
return EngineRuleAndEngineRuleVersionResp.engineRuleAndEngineRuleVersionBuild(engineRule, ruleVersionList);
|
||||
}
|
||||
|
||||
public String getTypeCodeText(EngineRule engineRule) {
|
||||
String className = Character.toUpperCase(engineRule.getEncoding().charAt(0)) + engineRule.getEncoding().substring(1);
|
||||
switch (engineRule.getType()) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.etl.data.rule.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.data.rule.domain.EngineRuleVersion;
|
||||
import com.etl.data.rule.mapper.EngineRuleVersionMapper;
|
||||
import com.etl.data.rule.service.IEngineRuleVersionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* 引擎维护版本Service业务层处理
|
||||
*
|
||||
* @author Chao
|
||||
* @ClassName: EngineRuleVersionServiceImpl 引擎维护版本Service业务层
|
||||
* @CreateTime: 2024/5/7 下午6:43
|
||||
*/
|
||||
@Service
|
||||
public class EngineRuleVersionServiceImpl extends ServiceImpl<EngineRuleVersionMapper, EngineRuleVersion> implements IEngineRuleVersionService {
|
||||
|
||||
/**
|
||||
* 保存引擎维护版本
|
||||
*
|
||||
* @param engineRuleVersion
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean saveEngineRuleVersion(EngineRuleVersion engineRuleVersion) {
|
||||
engineRuleVersion.setYesNoTest("D");
|
||||
return this.save(engineRuleVersion);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue