feat:完善规则引擎版本信息
parent
db59d7edc8
commit
6935d5556f
|
@ -14,11 +14,11 @@ public class ConfigCodeConstants {
|
|||
/**
|
||||
* 文件基础路径
|
||||
*/
|
||||
public final static String BASE_FILE_PATH="D:/workspace/gtl-muyu-server/muyu-modules/muyu-rule_engine/muyu-rule_engine-server/src/main/java/com/muyu/ruleEngine/scope/";
|
||||
public final static String BASE_FILE_PATH="D:\\2108A\\cloud-server_test\\muyu-modules\\muyu-rule_engine\\muyu-rule_engine-common\\src\\main\\java\\com\\muyu\\ruleEngine\\context\\";
|
||||
/**
|
||||
* 配置文件名数组
|
||||
*/
|
||||
public final static String[] CONFIG_FILE_NAME_ARRAY=new String[]{"TestClass.txt","TaskContextHolder.java","DataSetContextHolder.java","RecordContextHolder.java","DataModelContextHolder.java"};
|
||||
public final static String[] CONFIG_FILE_NAME_ARRAY=new String[]{"engine_custom.txt","TaskContextHolder.java","DataSetContextHolder.java","RecordContextHolder.java","DataModelContextHolder.java"};
|
||||
/**
|
||||
* 配置文件类型数组
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.ruleEngine.constant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 引擎版本常量
|
||||
*
|
||||
* @author HuFangMing
|
||||
* @ClassName: EngineVersionConstants
|
||||
* @createTime: 2024/5/7 20:09
|
||||
*/
|
||||
|
||||
|
||||
public class EngineVersionConstants {
|
||||
/**
|
||||
* 版本前缀
|
||||
*/
|
||||
public final static String VERSION_CLASS_SUFFIX=EngineVersionConstants.DEFAULT_VERSION_CLASS+EngineVersionConstants.VERSION_SEPARATOR;
|
||||
|
||||
/**
|
||||
* 版本前缀
|
||||
*/
|
||||
public final static String VERSION_SEPARATOR="_";
|
||||
|
||||
/**
|
||||
* 默认版本名
|
||||
*/
|
||||
public final static String DEFAULT_VERSION_CLASS="engine_custom";
|
||||
|
||||
/**
|
||||
* 默认版本号
|
||||
*/
|
||||
public final static String VERSION_CODE="version_code";
|
||||
|
||||
/**
|
||||
* 作用域引擎
|
||||
*/
|
||||
public final static String DEFAULT_SCOPE_ENGINE="scope_engine";
|
||||
|
||||
/**
|
||||
* 作用域引擎数组
|
||||
*/
|
||||
public final static String[] SCOPE_ENGINE=new String[]{"TaskEngine","DataSetEngine","RecordEngine","DataModelEngine"};
|
||||
}
|
|
@ -7,7 +7,7 @@ import lombok.experimental.SuperBuilder;
|
|||
/**
|
||||
* 数据模型上下文
|
||||
* @ClassName DataModelContextHolder
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.experimental.SuperBuilder;
|
|||
/**
|
||||
* 数据集上下文
|
||||
* @ClassName DataSetContextHolder
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.experimental.SuperBuilder;
|
|||
/**
|
||||
* 记录上下文
|
||||
* @ClassName RecordContextHolder
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class TestClass {
|
||||
public static String ruleTest(List<String> list) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import com.muyu.ruleEngine.engine.scope.scope_engine;
|
||||
|
||||
/**
|
||||
* 自定义引擎
|
||||
* @ClassName engine_custom
|
||||
* @Author: hufangming
|
||||
* @Version: version_code
|
||||
*/
|
||||
public class engine_custom extends scope_engine{
|
||||
@Override
|
||||
public void execution () {
|
||||
|
||||
}
|
||||
}
|
|
@ -30,10 +30,10 @@ import lombok.experimental.SuperBuilder;
|
|||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("engine_config")
|
||||
@TableName("engine_version")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "EngineConfig", description = "引擎规则配置")
|
||||
public class EngineConfig extends BaseEntity {
|
||||
@ApiModel(value = "EngineVersion", description = "引擎规则版本")
|
||||
public class EngineVersion extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
|
@ -90,8 +90,8 @@ public class EngineConfig extends BaseEntity {
|
|||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static EngineConfig queryBuild( EngineConfigQueryReq engineConfigQueryReq){
|
||||
return EngineConfig.builder()
|
||||
public static EngineVersion queryBuild( EngineConfigQueryReq engineConfigQueryReq){
|
||||
return EngineVersion.builder()
|
||||
.versionCode(engineConfigQueryReq.getVersionCode())
|
||||
.ruleContent(engineConfigQueryReq.getRuleContent())
|
||||
.engineMaintenanceId(engineConfigQueryReq.getEngineMaintenanceId())
|
||||
|
@ -106,8 +106,8 @@ public class EngineConfig extends BaseEntity {
|
|||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static EngineConfig saveBuild(EngineConfigSaveReq engineConfigSaveReq,Supplier<String> createBy){
|
||||
return EngineConfig.builder()
|
||||
public static EngineVersion saveBuild(EngineConfigSaveReq engineConfigSaveReq,Supplier<String> createBy){
|
||||
return EngineVersion.builder()
|
||||
.versionCode(engineConfigSaveReq.getVersionCode())
|
||||
.ruleContent(engineConfigSaveReq.getRuleContent())
|
||||
.engineMaintenanceId(engineConfigSaveReq.getEngineMaintenanceId())
|
||||
|
@ -125,8 +125,8 @@ public class EngineConfig extends BaseEntity {
|
|||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static EngineConfig editBuild(Long id, EngineConfigEditReq engineConfigEditReq, Supplier<String> updateBy){
|
||||
return EngineConfig.builder()
|
||||
public static EngineVersion editBuild(Long id, EngineConfigEditReq engineConfigEditReq, Supplier<String> updateBy){
|
||||
return EngineVersion.builder()
|
||||
.id(id)
|
||||
.versionCode(engineConfigEditReq.getVersionCode())
|
||||
.ruleContent(engineConfigEditReq.getRuleContent())
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.ruleEngine.domain.req;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -20,7 +21,15 @@ import lombok.experimental.SuperBuilder;
|
|||
@SuperBuilder
|
||||
@ApiModel(value = "VersionClassCreateReq", description = "引擎版本")
|
||||
public class VersionClassCreateReq {
|
||||
/** 引擎编码 */
|
||||
@ApiModelProperty(name = "引擎编码", value = "引擎编码", required = true)
|
||||
private String engineCode;
|
||||
|
||||
/** 作用域编号 */
|
||||
@ApiModelProperty(name = "作用域编号", value = "作用域编号", required = true)
|
||||
private Integer scope;
|
||||
|
||||
/** 版本编码 */
|
||||
@ApiModelProperty(name = "版本编码", value = "版本编码", required = true)
|
||||
private String versionCode;
|
||||
private String scope;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@ import lombok.experimental.SuperBuilder;
|
|||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class VersionClassCreateResp {
|
||||
|
||||
/**
|
||||
* 版本类名
|
||||
*/
|
||||
private String versionClass;
|
||||
/**
|
||||
* 规则内容
|
||||
*/
|
||||
private String ruleContent;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.ruleEngine.engine;
|
|||
/**
|
||||
* 引擎
|
||||
* @ClassName Engine
|
||||
* @Author: 森静若林
|
||||
* @Author: hufangming
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public interface Engine<V> {
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.ruleEngine.engine.action;
|
|||
/**
|
||||
* 丢弃动作
|
||||
* @ClassName ActionDiscard
|
||||
* @Author: 森静若林
|
||||
* @Author: hufangming
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public class ActionDiscard extends RuntimeException{
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.ruleEngine.engine.scope.DataModelEngine;
|
|||
/**
|
||||
* 不为空自定义引擎
|
||||
* @ClassName IsNotNullEngineCustom
|
||||
* @Author: 森静若林
|
||||
* @Author: hufangming
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public class IsNotNullEngineCustom extends DataModelEngine {
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.muyu.ruleEngine.context.DataModelContextHolder;
|
|||
/**
|
||||
* 数据模型引擎
|
||||
* @ClassName DataModelEngine
|
||||
* @Author: 森静若林
|
||||
* @Author: hufangming
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
/**
|
||||
* 数据集引擎
|
||||
* @ClassName DataSetEngine
|
||||
* @Author: 森静若林
|
||||
* @Author: hufangming
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
/**
|
||||
* 记录引擎
|
||||
* @ClassName RecordEngine
|
||||
* @Author: 森静若林
|
||||
* @Author: hufangming
|
||||
* @Date: 2024/5/6 13:48
|
||||
*/
|
||||
public abstract class RecordEngine implements Engine<RecordProcessModel> {
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.experimental.SuperBuilder;
|
|||
/**
|
||||
* 数据模型
|
||||
* @ClassName DataModel
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
/**
|
||||
* 数据集模型
|
||||
* @ClassName DataSetModel
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* 记录模型
|
||||
* @ClassName RecordModel
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/5 18:48
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||
/**
|
||||
* 数据模型处理模型
|
||||
* @ClassName DataModelProcessModel
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* 数据集处理模型
|
||||
* @ClassName DataSetProcessModel
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||
/**
|
||||
* 记录处理模型
|
||||
* @ClassName RecordProcessModel
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/5 18:37
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
/**
|
||||
* 作用域上下文工具
|
||||
* @ClassName ScopeContextHolderUtil
|
||||
* @Author 森静若林
|
||||
* @Author hufangming
|
||||
* @Date 2024/5/6 20:51
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.common.log.annotation.Log;
|
|||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
import com.muyu.ruleEngine.domain.model.TestData;
|
||||
import com.muyu.ruleEngine.domain.req.EngineConfigEditReq;
|
||||
import com.muyu.ruleEngine.domain.req.EngineConfigQueryReq;
|
||||
|
@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
/**
|
||||
* 引擎配置Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@Api(tags = "引擎配置")
|
||||
|
@ -63,83 +63,7 @@ public class EngineConfigController extends BaseController {
|
|||
return Result.success(engineConfigService.getScopeInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*/
|
||||
@ApiOperation("获取引擎规则配置列表")
|
||||
@RequiresPermissions("ruleEngine:config:list")
|
||||
@GetMapping("/list")
|
||||
public Result<List<EngineConfig>> list(EngineConfigQueryReq engineConfigQueryReq) {
|
||||
return Result.success(engineConfigService.list(EngineConfig.queryBuild(engineConfigQueryReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试引擎规则配置
|
||||
*/
|
||||
@ApiOperation("测试引擎规则配置")
|
||||
@RequiresPermissions("ruleEngine:config:add")
|
||||
@PostMapping(value = "/test")
|
||||
public Result<Object> ruleTest(@RequestBody TestData testData) {
|
||||
return Result.success(engineConfigService.ruleTest(testData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增引擎规则配置
|
||||
*/
|
||||
@RequiresPermissions("ruleEngine:config:add")
|
||||
@Log(title = "引擎规则配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增引擎规则配置")
|
||||
public Result<String> add(@RequestBody EngineConfigSaveReq engineConfigSaveReq) {
|
||||
return toAjax(engineConfigService.save(EngineConfig.saveBuild(engineConfigSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改引擎规则配置
|
||||
*/
|
||||
@RequiresPermissions("ruleEngine:config:edit")
|
||||
@Log(title = "引擎规则配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改引擎规则配置")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody EngineConfigEditReq engineConfigEditReq) {
|
||||
return toAjax(engineConfigService.updateById(EngineConfig.editBuild(id,engineConfigEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除引擎规则配置
|
||||
*/
|
||||
@RequiresPermissions("ruleEngine:config:remove")
|
||||
@Log(title = "引擎规则配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除引擎规则配置")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(engineConfigService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过引擎维护编号激活引擎
|
||||
*/
|
||||
@PutMapping("/activate/{id}")
|
||||
@RequiresPermissions("ruleEngine:config:activate")
|
||||
@Log(title = "激活引擎", businessType = BusinessType.UPDATE)
|
||||
public Result updateActivateStatus(@PathVariable Long id) {
|
||||
|
||||
engineConfigService.updateActivateStatus(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过引擎维护编号关闭引擎
|
||||
*/
|
||||
@PutMapping("/close/{id}")
|
||||
@RequiresPermissions("ruleEngine:config:close")
|
||||
@Log(title = "关闭引擎" , businessType = BusinessType.UPDATE)
|
||||
public Result updateCloseStatus(@PathVariable Long id) {
|
||||
|
||||
engineConfigService.updateCloseStatus(id);
|
||||
return Result.success();
|
||||
}
|
||||
/**
|
||||
* 生成引擎版本类并返回规则模版
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.muyu.ruleEngine.domain.req.EngineMaintenanceEditReq;
|
|||
/**
|
||||
* 引擎维护Controller
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@Api(tags = "引擎维护")
|
||||
|
@ -84,7 +84,7 @@ public class EngineMaintenanceController extends BaseController {
|
|||
@PostMapping
|
||||
@ApiOperation("新增引擎维护")
|
||||
public Result<String> add(@RequestBody EngineMaintenanceSaveReq engineMaintenanceSaveReq) {
|
||||
return toAjax(engineMaintenanceService.saveEngineMaintenance(EngineMaintenance.saveBuild(engineMaintenanceSaveReq, SecurityUtils::getUsername)));
|
||||
return toAjax(engineMaintenanceService.save(EngineMaintenance.saveBuild(engineMaintenanceSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,6 +97,29 @@ public class EngineMaintenanceController extends BaseController {
|
|||
public Result<String> edit(@PathVariable Long id, @RequestBody EngineMaintenanceEditReq engineMaintenanceEditReq) {
|
||||
return toAjax(engineMaintenanceService.updateById(EngineMaintenance.editBuild(id,engineMaintenanceEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
/**
|
||||
* 通过引擎维护编号激活引擎
|
||||
*/
|
||||
@PutMapping("/activate/{id}")
|
||||
// @RequiresPermissions("ruleEngine:config:activate")
|
||||
@Log(title = "激活引擎", businessType = BusinessType.UPDATE)
|
||||
public Result updateActivateStatus(@PathVariable Long id) {
|
||||
|
||||
engineMaintenanceService.updateActivateStatus(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过引擎维护编号关闭引擎
|
||||
*/
|
||||
@PutMapping("/close/{id}")
|
||||
// @RequiresPermissions("ruleEngine:config:close")
|
||||
@Log(title = "关闭引擎" , businessType = BusinessType.UPDATE)
|
||||
public Result updateCloseStatus(@PathVariable Long id) {
|
||||
|
||||
engineMaintenanceService.updateCloseStatus(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除引擎维护
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package com.muyu.ruleEngine.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
import com.muyu.ruleEngine.domain.model.TestData;
|
||||
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.VersionClassCreateResp;
|
||||
import com.muyu.ruleEngine.service.EngineVersionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 引擎版本Controller
|
||||
*
|
||||
* @author HuFangMing
|
||||
* @ClassName: EngineVersionController
|
||||
* @createTime: 2024/5/7 21:11
|
||||
*/
|
||||
|
||||
@Api(tags = "引擎版本")
|
||||
@RestController
|
||||
@RequestMapping("/version")
|
||||
public class EngineVersionController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private EngineVersionService engineVersionService;
|
||||
|
||||
/**
|
||||
* 查询引擎规则版本列表
|
||||
*/
|
||||
@ApiOperation("查询引擎规则版本列表")
|
||||
@RequiresPermissions("ruleEngine:version:list")
|
||||
@GetMapping("/list")
|
||||
public Result<List<EngineVersion>> list(EngineConfigQueryReq engineConfigQueryReq) {
|
||||
return Result.success(engineVersionService.list(EngineVersion.queryBuild(engineConfigQueryReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成引擎版本类并返回规则模版
|
||||
*/
|
||||
@ApiOperation("生成引擎版本类并返回规则模版")
|
||||
// @RequiresPermissions("ruleEngine:version:query")
|
||||
@PostMapping(value = "/createVersionClass")
|
||||
public Result<VersionClassCreateResp> createVersionClass(@RequestBody VersionClassCreateReq req) {
|
||||
return Result.success(engineVersionService.createVersionClass(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试引擎规则版本
|
||||
*/
|
||||
@ApiOperation("测试引擎规则配置")
|
||||
@RequiresPermissions("ruleEngine:version:add")
|
||||
@PostMapping(value = "/test")
|
||||
public Result<Object> ruleTest(@RequestBody TestData testData) {
|
||||
return Result.success(engineVersionService.ruleTest(testData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增引擎规则版本
|
||||
*/
|
||||
@RequiresPermissions("ruleEngine:version:add")
|
||||
@Log(title = "引擎规则配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增引擎规则配置")
|
||||
public Result<String> add(@RequestBody EngineConfigSaveReq engineConfigSaveReq) {
|
||||
return toAjax(engineVersionService.save(EngineVersion.saveBuild(engineConfigSaveReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改引擎规则版本
|
||||
*/
|
||||
@RequiresPermissions("ruleEngine:version:edit")
|
||||
@Log(title = "引擎规则配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改引擎规则配置")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody EngineConfigEditReq engineConfigEditReq) {
|
||||
return toAjax(engineVersionService.updateById(EngineVersion.editBuild(id,engineConfigEditReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除引擎规则版本
|
||||
*/
|
||||
@RequiresPermissions("ruleEngine:version:remove")
|
||||
@Log(title = "引擎规则配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除引擎规则配置")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(engineVersionService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu.ruleEngine.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||
|
||||
/**
|
||||
* 引擎规则配置Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
public interface EngineConfigMapper extends BaseMapper<EngineConfig> {
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import com.muyu.ruleEngine.domain.EngineMaintenance;
|
|||
/**
|
||||
* 引擎维护Mapper接口
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
public interface EngineMaintenanceMapper extends BaseMapper<EngineMaintenance> {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.ruleEngine.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
|
||||
/**
|
||||
* 引擎规则配置版本Mapper接口
|
||||
*
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
public interface EngineVersionMapper extends BaseMapper<EngineVersion> {
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.muyu.ruleEngine.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||
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;
|
||||
|
@ -11,10 +11,10 @@ import java.util.List;
|
|||
/**
|
||||
* 引擎配置Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
public interface EngineConfigService extends IService<EngineConfig> {
|
||||
public interface EngineConfigService {
|
||||
/**
|
||||
* 查询引擎配置作用域列表
|
||||
*
|
||||
|
@ -22,13 +22,7 @@ public interface EngineConfigService extends IService<EngineConfig> {
|
|||
*/
|
||||
public List<EngineConfigScopeResp> getScopeList();
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*
|
||||
* @param engineConfig 引擎规则配置
|
||||
* @return 引擎规则配置集合
|
||||
*/
|
||||
public List<EngineConfig> list(EngineConfig engineConfig);
|
||||
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
|
@ -37,15 +31,9 @@ public interface EngineConfigService extends IService<EngineConfig> {
|
|||
*/
|
||||
EngineConfigScopeResp getScopeInfoById(Integer id);
|
||||
|
||||
/**
|
||||
* 规则测试
|
||||
* @param testData 规则配置版本编号
|
||||
*/
|
||||
Object ruleTest(TestData testData);
|
||||
|
||||
void updateActivateStatus(Long id);
|
||||
|
||||
void updateCloseStatus(Long id);
|
||||
|
||||
|
||||
VersionClassCreateResp createVersionClass(VersionClassCreateReq versionClassCreateReq);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 引擎维护Service接口
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
public interface EngineMaintenanceService extends IService<EngineMaintenance> {
|
||||
|
@ -19,12 +19,6 @@ public interface EngineMaintenanceService extends IService<EngineMaintenance> {
|
|||
*/
|
||||
public List<EngineMaintenance> list(EngineMaintenance engineMaintenance);
|
||||
|
||||
/**
|
||||
* 新增引擎维护
|
||||
* @param engineMaintenance 引擎维护对象
|
||||
* @return 是否
|
||||
*/
|
||||
boolean saveEngineMaintenance(EngineMaintenance engineMaintenance);
|
||||
|
||||
/**
|
||||
* 批量删除引擎维护
|
||||
|
@ -32,4 +26,16 @@ public interface EngineMaintenanceService extends IService<EngineMaintenance> {
|
|||
* @return 是否
|
||||
*/
|
||||
boolean removeBatchEngineMaintenanceByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 激活引擎
|
||||
* @param id 引擎维护编号
|
||||
*/
|
||||
void updateActivateStatus(Long id);
|
||||
|
||||
/**
|
||||
* 关闭引擎
|
||||
* @param id 引擎维护编号
|
||||
*/
|
||||
void updateCloseStatus(Long id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.ruleEngine.service;
|
||||
|
||||
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.VersionClassCreateResp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*
|
||||
* @author HuFangMing
|
||||
* @ClassName: EngineVersionService
|
||||
* @createTime: 2024/5/7 21:21
|
||||
*/
|
||||
|
||||
|
||||
public interface EngineVersionService extends IService<EngineVersion> {
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*
|
||||
* @param engineConfig 引擎规则配置
|
||||
* @return 引擎规则配置集合
|
||||
*/
|
||||
public List<EngineVersion> list(EngineVersion engineConfig);
|
||||
|
||||
/**
|
||||
* 规则测试
|
||||
* @param testData 规则配置版本编号
|
||||
*/
|
||||
Object ruleTest(TestData testData);
|
||||
|
||||
/**
|
||||
* 生成引擎版本类并返回规则模版
|
||||
* @param req 版本创建请求参数类
|
||||
* @return 版本创建响应类
|
||||
*/
|
||||
VersionClassCreateResp createVersionClass(VersionClassCreateReq req);
|
||||
}
|
|
@ -8,13 +8,13 @@ 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.RuleOperationConstants;
|
||||
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||
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 com.muyu.ruleEngine.dynamicLoad.DynamicLoader;
|
||||
import com.muyu.ruleEngine.mapper.EngineConfigMapper;
|
||||
import com.muyu.ruleEngine.mapper.EngineVersionMapper;
|
||||
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -29,12 +29,12 @@ import java.util.Map;
|
|||
/**
|
||||
* 引擎配置Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EngineConfigServiceImpl extends ServiceImpl<EngineConfigMapper, EngineConfig> implements EngineConfigService {
|
||||
public class EngineConfigServiceImpl implements EngineConfigService {
|
||||
|
||||
/**
|
||||
* 查询引擎配置作用域列表
|
||||
|
@ -62,36 +62,10 @@ public class EngineConfigServiceImpl extends ServiceImpl<EngineConfigMapper, Eng
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*
|
||||
* @param engineConfig 引擎规则配置
|
||||
* @return 引擎规则配置
|
||||
*/
|
||||
@Override
|
||||
public List<EngineConfig> list(EngineConfig engineConfig) {
|
||||
LambdaQueryWrapper<EngineConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(engineConfig.getVersionCode())){
|
||||
queryWrapper.eq(EngineConfig::getVersionCode, engineConfig.getVersionCode());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(engineConfig.getRuleContent())){
|
||||
queryWrapper.eq(EngineConfig::getRuleContent, engineConfig.getRuleContent());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(engineConfig.getEngineMaintenanceId())){
|
||||
queryWrapper.eq(EngineConfig::getEngineMaintenanceId, engineConfig.getEngineMaintenanceId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||
* @param id 引擎作用域编号
|
||||
|
@ -111,50 +85,6 @@ public class EngineConfigServiceImpl extends ServiceImpl<EngineConfigMapper, Eng
|
|||
return EngineConfigScopeResp.builder().type(type).name(scope).code(code).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则测试
|
||||
* @param testData 规则配置版本编号
|
||||
*/
|
||||
@Override
|
||||
public Object ruleTest(TestData testData) {
|
||||
Object invoke=null;
|
||||
try {
|
||||
EngineConfig config = this.getById(testData.getId());
|
||||
String content = config.getRuleContent().replaceAll("\r\n", "");
|
||||
// 对source进行编译生成class文件存放在Map中,这里用bytecode接收
|
||||
Map<String, byte[]> bytecode = DynamicLoader.compile(RuleOperationConstants.CLASS_NAME + RuleOperationConstants.FILE_SUFFIX,content );
|
||||
|
||||
// 加载class文件到虚拟机中,然后通过反射执行
|
||||
@SuppressWarnings("resource")
|
||||
DynamicLoader.MemoryClassLoader classLoader = new DynamicLoader.MemoryClassLoader(
|
||||
bytecode);
|
||||
Class<?> clazz = classLoader.loadClass(RuleOperationConstants.CLASS_NAME);
|
||||
|
||||
// 调用ruleTest方法
|
||||
Method mainMethod = clazz.getDeclaredMethod(RuleOperationConstants.METHOD_NAME, List.class);
|
||||
invoke = mainMethod.invoke(null, testData.getList());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("测试失败");
|
||||
}
|
||||
return invoke;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivateStatus(Long id) {
|
||||
this.update(new UpdateWrapper<>(){{
|
||||
eq("engineMaintenanceId",id);
|
||||
set("isActivate", "Y");
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCloseStatus(Long id) {
|
||||
this.update(new LambdaUpdateWrapper<>(){{
|
||||
eq(EngineConfig::getEngineMaintenanceId,id);
|
||||
set(EngineConfig::getIsActivate,"N");
|
||||
}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionClassCreateResp createVersionClass(VersionClassCreateReq versionClassCreateReq) {
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
package com.muyu.ruleEngine.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
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.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||
import com.muyu.ruleEngine.domain.EngineVersion;
|
||||
import com.muyu.ruleEngine.mapper.EngineMaintenanceMapper;
|
||||
import com.muyu.ruleEngine.service.EngineMaintenanceService;
|
||||
|
||||
import com.muyu.ruleEngine.service.EngineVersionService;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.ruleEngine.mapper.EngineMaintenanceMapper;
|
||||
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||
import com.muyu.ruleEngine.service.EngineMaintenanceService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 引擎维护Service业务层处理
|
||||
*
|
||||
* @author gtl
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -26,7 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
public class EngineMaintenanceServiceImpl extends ServiceImpl<EngineMaintenanceMapper, EngineMaintenance> implements EngineMaintenanceService {
|
||||
|
||||
@Autowired
|
||||
private EngineConfigService engineConfigService;
|
||||
private EngineVersionService engineVersionService;
|
||||
|
||||
/**
|
||||
* 查询引擎维护列表
|
||||
|
@ -62,27 +63,10 @@ public class EngineMaintenanceServiceImpl extends ServiceImpl<EngineMaintenanceM
|
|||
if (ObjUtils.notNull(engineMaintenance.getStatus())){
|
||||
queryWrapper.eq(EngineMaintenance::getStatus, engineMaintenance.getStatus());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增引擎维护
|
||||
* @param engineMaintenance 引擎维护对象
|
||||
* @return 是否
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean saveEngineMaintenance(EngineMaintenance engineMaintenance) {
|
||||
boolean save = this.save(engineMaintenance);
|
||||
EngineConfigScopeResp scopeInfo = engineConfigService.getScopeInfoById(0);
|
||||
engineConfigService.save(EngineConfig.builder().versionCode("1.0").ruleContent(scopeInfo.getCode()).engineMaintenanceId(engineMaintenance.getId()).build());
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除引擎维护
|
||||
|
@ -93,13 +77,27 @@ public class EngineMaintenanceServiceImpl extends ServiceImpl<EngineMaintenanceM
|
|||
@Transactional
|
||||
public boolean removeBatchEngineMaintenanceByIds(List<Long> ids) {
|
||||
boolean removed = this.removeBatchByIds(ids);
|
||||
List<EngineConfig> engineConfigs = engineConfigService.list(new LambdaQueryWrapper<EngineConfig>()
|
||||
.in(EngineConfig::getEngineMaintenanceId, ids));
|
||||
List<EngineVersion> engineConfigs = engineVersionService.list(new LambdaQueryWrapper<EngineVersion>()
|
||||
.in(EngineVersion::getEngineMaintenanceId, ids));
|
||||
if(!engineConfigs.isEmpty()){
|
||||
engineConfigService.removeBatchByIds(engineConfigs.stream().map(EngineConfig::getId).toList());
|
||||
engineVersionService.removeBatchByIds(engineConfigs.stream().map(EngineVersion::getId).toList());
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivateStatus(Long id) {
|
||||
this.update(new LambdaUpdateWrapper<EngineMaintenance>()
|
||||
.eq(EngineMaintenance::getId,id)
|
||||
.set(EngineMaintenance::getIsActivate,"Y"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCloseStatus(Long id) {
|
||||
this.update(new LambdaUpdateWrapper<EngineMaintenance>()
|
||||
.eq(EngineMaintenance::getId,id)
|
||||
.set(EngineMaintenance::getIsActivate,"N"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
package com.muyu.ruleEngine.service.impl;
|
||||
|
||||
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.EngineVersionConstants;
|
||||
import com.muyu.ruleEngine.constant.RuleOperationConstants;
|
||||
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 com.muyu.ruleEngine.dynamicLoad.DynamicLoader;
|
||||
import com.muyu.ruleEngine.mapper.EngineVersionMapper;
|
||||
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||
import com.muyu.ruleEngine.service.EngineVersionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 引擎配置Service业务层处理
|
||||
*
|
||||
* @author hufangming
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EngineVersionServiceImpl extends ServiceImpl<EngineVersionMapper, EngineVersion> implements EngineVersionService {
|
||||
|
||||
@Autowired
|
||||
private EngineConfigService engineConfigService;
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*
|
||||
* @param engineConfig 引擎规则配置
|
||||
* @return 引擎规则配置
|
||||
*/
|
||||
@Override
|
||||
public List<EngineVersion> list(EngineVersion engineConfig) {
|
||||
LambdaQueryWrapper<EngineVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(engineConfig.getVersionCode())){
|
||||
queryWrapper.eq(EngineVersion::getVersionCode, engineConfig.getVersionCode());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(engineConfig.getRuleContent())){
|
||||
queryWrapper.eq(EngineVersion::getRuleContent, engineConfig.getRuleContent());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(engineConfig.getEngineMaintenanceId())){
|
||||
queryWrapper.eq(EngineVersion::getEngineMaintenanceId, engineConfig.getEngineMaintenanceId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则测试
|
||||
* @param testData 规则配置版本编号
|
||||
*/
|
||||
@Override
|
||||
public Object ruleTest(TestData testData) {
|
||||
Object invoke=null;
|
||||
try {
|
||||
EngineVersion config = this.getById(testData.getId());
|
||||
String content = config.getRuleContent().replaceAll("\r\n", "");
|
||||
// 对source进行编译生成class文件存放在Map中,这里用bytecode接收
|
||||
Map<String, byte[]> bytecode = DynamicLoader.compile(RuleOperationConstants.CLASS_NAME + RuleOperationConstants.FILE_SUFFIX,content );
|
||||
|
||||
// 加载class文件到虚拟机中,然后通过反射执行
|
||||
@SuppressWarnings("resource")
|
||||
DynamicLoader.MemoryClassLoader classLoader = new DynamicLoader.MemoryClassLoader(
|
||||
bytecode);
|
||||
Class<?> clazz = classLoader.loadClass(RuleOperationConstants.CLASS_NAME);
|
||||
|
||||
// 调用ruleTest方法
|
||||
Method mainMethod = clazz.getDeclaredMethod(RuleOperationConstants.METHOD_NAME, List.class);
|
||||
invoke = mainMethod.invoke(null, testData.getList());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("测试失败");
|
||||
}
|
||||
return invoke;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成引擎版本类并返回规则模版
|
||||
* @param req 版本创建请求参数类
|
||||
* @return 版本创建响应类
|
||||
*/
|
||||
@Override
|
||||
public VersionClassCreateResp createVersionClass(VersionClassCreateReq req) {
|
||||
String versionClass = EngineVersionConstants.VERSION_CLASS_SUFFIX + req.getEngineCode() + EngineVersionConstants.VERSION_SEPARATOR + req.getVersionCode();
|
||||
EngineConfigScopeResp scopeResp = engineConfigService.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);
|
||||
return VersionClassCreateResp.builder()
|
||||
.versionClass(versionClass)
|
||||
.ruleContent(ruleContent)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
/**
|
||||
* 用户公告控制层
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
@RestController
|
||||
|
|
|
@ -11,7 +11,7 @@ import lombok.experimental.SuperBuilder;
|
|||
/**
|
||||
* 用户通知公告中间表
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* 公告
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.experimental.SuperBuilder;
|
|||
/**
|
||||
* 公告数量
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.Date;
|
|||
/**
|
||||
* 公告响应
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
/**
|
||||
* 用户公告mapper层
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
public interface AsUserDeptMapper {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
/**
|
||||
* 用户公告中间接口
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
public interface IAsUserDeptService {
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
/**
|
||||
* 业务层处理
|
||||
*
|
||||
* @author CHX
|
||||
* @author hufangming
|
||||
* on 2024/4/14 星期日
|
||||
*/
|
||||
@Service
|
||||
|
|
Loading…
Reference in New Issue