fix:修复规则引擎版本信息无法查找id的bug
parent
6935d5556f
commit
5ebca27b6d
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.ruleEngine.domain.resp;
|
||||
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 引擎版本
|
||||
*
|
||||
* @author HuFangMing
|
||||
* @ClassName: EngineVersionListResp
|
||||
* @createTime: 2024/5/9 14:21
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EngineVersionListResp {
|
||||
/**编号*/
|
||||
private Long id;
|
||||
/**名称*/
|
||||
private String name;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Long type;
|
||||
/**作用域*/
|
||||
private Integer scope;
|
||||
/**
|
||||
* 引擎编码
|
||||
*
|
||||
*/
|
||||
private String engineCode;
|
||||
/**
|
||||
* 是否激活
|
||||
*/
|
||||
private String isActivate;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 规则引擎版本列表
|
||||
*/
|
||||
private List<EngineVersion> engineVersionList;
|
||||
}
|
|
@ -43,35 +43,8 @@ public class EngineConfigController extends BaseController {
|
|||
@Autowired
|
||||
private EngineConfigService engineConfigService;
|
||||
|
||||
/**
|
||||
* 获取引擎配置作用域列表
|
||||
*/
|
||||
@ApiOperation("获取引擎配置作用域列表")
|
||||
@RequiresPermissions("rule_engine:config:list")
|
||||
@GetMapping("/getScopeList")
|
||||
public Result<List<EngineConfigScopeResp>> getScopeList() {
|
||||
return Result.success(engineConfigService.getScopeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
*/
|
||||
@ApiOperation("通过引擎作用域编号获取引擎配置作用域信息")
|
||||
@RequiresPermissions("rule_engine:config:list")
|
||||
@GetMapping("/getScopeInfo/{id}")
|
||||
public Result<EngineConfigScopeResp> getScopeInfoById(@PathVariable Integer id) {
|
||||
return Result.success(engineConfigService.getScopeInfoById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成引擎版本类并返回规则模版
|
||||
*/
|
||||
@PostMapping("/createVersionClass")
|
||||
@RequiresPermissions("ruleEngine:config:createVersionClass")
|
||||
public Result<VersionClassCreateResp> createVersionClass(@RequestBody VersionClassCreateReq versionClassCreateReq) {
|
||||
return Result.success(engineConfigService.createVersionClass(versionClassCreateReq));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.ruleEngine.controller;
|
||||
|
||||
import com.muyu.ruleEngine.domain.resp.EngineVersionListResp;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
|
@ -132,4 +133,14 @@ public class EngineMaintenanceController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(engineMaintenanceService.removeBatchEngineMaintenanceByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询规则引擎版本列表
|
||||
*/
|
||||
@RequiresPermissions("rule_engine:maintenance:edit")
|
||||
@PutMapping("/getRuleEngineInfo/{id}")
|
||||
public Result getRuleEngineInfo(@PathVariable Long id){
|
||||
EngineVersionListResp engineConfigListResp=engineMaintenanceService.getRuleEngineInfo(id);
|
||||
return Result.success(engineConfigListResp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.muyu.ruleEngine.domain.req.EngineConfigEditReq;
|
|||
import com.muyu.ruleEngine.domain.req.EngineConfigQueryReq;
|
||||
import com.muyu.ruleEngine.domain.req.EngineConfigSaveReq;
|
||||
import com.muyu.ruleEngine.domain.req.VersionClassCreateReq;
|
||||
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||
import com.muyu.ruleEngine.domain.resp.VersionClassCreateResp;
|
||||
import com.muyu.ruleEngine.service.EngineVersionService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -108,4 +109,23 @@ public class EngineVersionController extends BaseController {
|
|||
return toAjax(engineVersionService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取引擎配置作用域列表
|
||||
*/
|
||||
@ApiOperation("获取引擎配置作用域列表")
|
||||
@RequiresPermissions("rule_engine:config:list")
|
||||
@GetMapping("/getScopeList")
|
||||
public Result<List<EngineConfigScopeResp>> getScopeList() {
|
||||
return Result.success(engineVersionService.getScopeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
*/
|
||||
@ApiOperation("通过引擎作用域编号获取引擎配置作用域信息")
|
||||
@RequiresPermissions("rule_engine:config:list")
|
||||
@GetMapping("/getScopeInfo/{id}")
|
||||
public Result<EngineConfigScopeResp> getScopeInfoById(@PathVariable Integer id) {
|
||||
return Result.success(engineVersionService.getScopeInfoById(id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,23 +15,9 @@ import java.util.List;
|
|||
* @date 2024-05-02
|
||||
*/
|
||||
public interface EngineConfigService {
|
||||
/**
|
||||
* 查询引擎配置作用域列表
|
||||
*
|
||||
* @return 引擎规则作用域集合
|
||||
*/
|
||||
public List<EngineConfigScopeResp> getScopeList();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
* @param id 引擎作用域编号
|
||||
* @return 引擎配置作用域信息
|
||||
*/
|
||||
EngineConfigScopeResp getScopeInfoById(Integer id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.ruleEngine.service;
|
||||
|
||||
import com.muyu.ruleEngine.domain.resp.EngineVersionListResp;
|
||||
import java.util.List;
|
||||
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -38,4 +39,6 @@ public interface EngineMaintenanceService extends IService<EngineMaintenance> {
|
|||
* @param id 引擎维护编号
|
||||
*/
|
||||
void updateCloseStatus(Long id);
|
||||
|
||||
EngineVersionListResp getRuleEngineInfo(Long id);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
import com.muyu.ruleEngine.domain.model.TestData;
|
||||
import com.muyu.ruleEngine.domain.req.VersionClassCreateReq;
|
||||
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||
import com.muyu.ruleEngine.domain.resp.VersionClassCreateResp;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -37,4 +38,20 @@ public interface EngineVersionService extends IService<EngineVersion> {
|
|||
* @return 版本创建响应类
|
||||
*/
|
||||
VersionClassCreateResp createVersionClass(VersionClassCreateReq req);
|
||||
|
||||
/**
|
||||
* 查询引擎配置作用域列表
|
||||
*
|
||||
* @return 引擎规则作用域集合
|
||||
*/
|
||||
public List<EngineConfigScopeResp> getScopeList();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
* @param id 引擎作用域编号
|
||||
* @return 引擎配置作用域信息
|
||||
*/
|
||||
EngineConfigScopeResp getScopeInfoById(Integer id);
|
||||
}
|
||||
|
|
|
@ -36,56 +36,9 @@ import java.util.Map;
|
|||
@Service
|
||||
public class EngineConfigServiceImpl implements EngineConfigService {
|
||||
|
||||
/**
|
||||
* 查询引擎配置作用域列表
|
||||
*
|
||||
* @return 引擎规则作用域集合
|
||||
*/
|
||||
@Override
|
||||
public List<EngineConfigScopeResp> getScopeList() {
|
||||
List<EngineConfigScopeResp> list=new ArrayList<>();
|
||||
try {
|
||||
int index=0;
|
||||
for (String scope : ConfigCodeConstants.CONFIG_FILE_NAME_ARRAY) {
|
||||
if(index==0){
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
String path=ConfigCodeConstants.BASE_FILE_PATH+scope;
|
||||
String code = Files.readString(Paths.get(path));
|
||||
String type=ConfigCodeConstants.CONFIG_FILE_TYPE_ARRAY[index++];
|
||||
list.add(EngineConfigScopeResp.builder().type(type).name(scope).code(code).build());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
* @param id 引擎作用域编号
|
||||
* @return 引擎配置作用域信息
|
||||
*/
|
||||
@Override
|
||||
public EngineConfigScopeResp getScopeInfoById(Integer id) {
|
||||
String scope=ConfigCodeConstants.CONFIG_FILE_NAME_ARRAY[id];
|
||||
String type=ConfigCodeConstants.CONFIG_FILE_TYPE_ARRAY[id];
|
||||
String path=ConfigCodeConstants.BASE_FILE_PATH+scope;
|
||||
String code = null;
|
||||
try {
|
||||
code = Files.readString(Paths.get(path));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return EngineConfigScopeResp.builder().type(type).name(scope).code(code).build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VersionClassCreateResp createVersionClass(VersionClassCreateReq versionClassCreateReq) {
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
import com.muyu.ruleEngine.domain.resp.EngineVersionListResp;
|
||||
import com.muyu.ruleEngine.mapper.EngineMaintenanceMapper;
|
||||
import com.muyu.ruleEngine.service.EngineMaintenanceService;
|
||||
|
||||
|
@ -99,5 +100,27 @@ public class EngineMaintenanceServiceImpl extends ServiceImpl<EngineMaintenanceM
|
|||
.set(EngineMaintenance::getIsActivate,"N"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EngineVersionListResp getRuleEngineInfo(Long id) {
|
||||
EngineMaintenance engineMaintenance = this.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(EngineMaintenance::getId, id);
|
||||
}});
|
||||
List<EngineVersion> engineVersions = engineVersionService.list();
|
||||
List<EngineVersion> engineVersionList = engineVersions.stream().filter(engineVersion ->
|
||||
engineVersion.getEngineMaintenanceId().equals(engineMaintenance.getId())
|
||||
).toList();
|
||||
return EngineVersionListResp.builder()
|
||||
.id(engineMaintenance.getId())
|
||||
.name(engineMaintenance.getName())
|
||||
.type(engineMaintenance.getType())
|
||||
.scope(engineMaintenance.getScope())
|
||||
.engineCode(engineMaintenance.getEngineCode())
|
||||
.isActivate(engineMaintenance.getIsActivate())
|
||||
.status(engineMaintenance.getStatus())
|
||||
.description(engineMaintenance.getDescription())
|
||||
.engineVersionList(engineVersionList)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.ruleEngine.constant.ConfigCodeConstants;
|
||||
import com.muyu.ruleEngine.constant.EngineVersionConstants;
|
||||
import com.muyu.ruleEngine.constant.RuleOperationConstants;
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
|
@ -15,6 +16,10 @@ import com.muyu.ruleEngine.dynamicLoad.DynamicLoader;
|
|||
import com.muyu.ruleEngine.mapper.EngineVersionMapper;
|
||||
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||
import com.muyu.ruleEngine.service.EngineVersionService;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -33,7 +38,7 @@ import java.util.Map;
|
|||
public class EngineVersionServiceImpl extends ServiceImpl<EngineVersionMapper, EngineVersion> implements EngineVersionService {
|
||||
|
||||
@Autowired
|
||||
private EngineConfigService engineConfigService;
|
||||
private EngineVersionService engineVersionService;
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
|
@ -102,7 +107,7 @@ public class EngineVersionServiceImpl extends ServiceImpl<EngineVersionMapper, E
|
|||
@Override
|
||||
public VersionClassCreateResp createVersionClass(VersionClassCreateReq req) {
|
||||
String versionClass = EngineVersionConstants.VERSION_CLASS_SUFFIX + req.getEngineCode() + EngineVersionConstants.VERSION_SEPARATOR + req.getVersionCode();
|
||||
EngineConfigScopeResp scopeResp = engineConfigService.getScopeInfoById(0);
|
||||
EngineConfigScopeResp scopeResp = engineVersionService.getScopeInfoById(0);
|
||||
String ruleContent = scopeResp.getCode().replaceAll(EngineVersionConstants.DEFAULT_SCOPE_ENGINE, EngineVersionConstants.SCOPE_ENGINE[req.getScope() - 1])
|
||||
.replaceAll(EngineVersionConstants.VERSION_CODE, req.getVersionCode())
|
||||
.replaceAll(EngineVersionConstants.DEFAULT_VERSION_CLASS, versionClass);
|
||||
|
@ -111,6 +116,53 @@ public class EngineVersionServiceImpl extends ServiceImpl<EngineVersionMapper, E
|
|||
.ruleContent(ruleContent)
|
||||
.build();
|
||||
}
|
||||
/**
|
||||
* 查询引擎配置作用域列表
|
||||
*
|
||||
* @return 引擎规则作用域集合
|
||||
*/
|
||||
@Override
|
||||
public List<EngineConfigScopeResp> getScopeList() {
|
||||
List<EngineConfigScopeResp> list=new ArrayList<>();
|
||||
try {
|
||||
int index=0;
|
||||
for (String scope : ConfigCodeConstants.CONFIG_FILE_NAME_ARRAY) {
|
||||
if(index==0){
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
String path=ConfigCodeConstants.BASE_FILE_PATH+scope;
|
||||
String code = Files.readString(Paths.get(path));
|
||||
String type=ConfigCodeConstants.CONFIG_FILE_TYPE_ARRAY[index++];
|
||||
list.add(EngineConfigScopeResp.builder().type(type).name(scope).code(code).build());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
* @param id 引擎作用域编号
|
||||
* @return 引擎配置作用域信息
|
||||
*/
|
||||
@Override
|
||||
public EngineConfigScopeResp getScopeInfoById(Integer id) {
|
||||
String scope=ConfigCodeConstants.CONFIG_FILE_NAME_ARRAY[id];
|
||||
String type=ConfigCodeConstants.CONFIG_FILE_TYPE_ARRAY[id];
|
||||
String path=ConfigCodeConstants.BASE_FILE_PATH+scope;
|
||||
String code = null;
|
||||
try {
|
||||
code = Files.readString(Paths.get(path));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return EngineConfigScopeResp.builder().type(type).name(scope).code(code).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue