feat(): 规则维护页面,列表,添加功能

dev
chao 2024-05-07 21:18:36 +08:00
parent 4b62c4c7ab
commit 866b3835cb
10 changed files with 421 additions and 1 deletions

View File

@ -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;
/**

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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

View File

@ -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));
}
}

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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()) {

View File

@ -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);
}
}