feat():规则引擎功能完成
parent
9fad001ad6
commit
e0fbb445a1
|
@ -0,0 +1,98 @@
|
|||
package com.muyu.ruleEngine.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.ruleEngine.domain.req.EngineConfigEditReq;
|
||||
import com.muyu.ruleEngine.domain.req.EngineConfigQueryReq;
|
||||
import com.muyu.ruleEngine.domain.req.EngineConfigSaveReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.function.Supplier;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 引擎规则配置对象 engine_config
|
||||
*
|
||||
* @author HuFangMing
|
||||
* @ClassName: EngineConfig
|
||||
* @createTime: 2024/5/4 15:25
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("engine_config")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "EngineConfig", description = "引擎规则配置")
|
||||
public class EngineConfig extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 版本编码 */
|
||||
@Excel(name = "版本编码")
|
||||
@ApiModelProperty(name = "版本编码", value = "版本编码", required = true)
|
||||
private String versionCode;
|
||||
|
||||
/** 规则内容 */
|
||||
@Excel(name = "规则内容")
|
||||
@ApiModelProperty(name = "规则内容", value = "规则内容", required = true)
|
||||
private String ruleContent;
|
||||
|
||||
/** 引擎维护编号 */
|
||||
@Excel(name = "引擎维护编号")
|
||||
@ApiModelProperty(name = "引擎维护编号", value = "引擎维护编号", required = true)
|
||||
private Long engineMaintenanceId;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static EngineConfig queryBuild( EngineConfigQueryReq engineConfigQueryReq){
|
||||
return EngineConfig.builder()
|
||||
.versionCode(engineConfigQueryReq.getVersionCode())
|
||||
.ruleContent(engineConfigQueryReq.getRuleContent())
|
||||
.engineMaintenanceId(engineConfigQueryReq.getEngineMaintenanceId())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static EngineConfig saveBuild(EngineConfigSaveReq engineConfigSaveReq,Supplier<String> createBy){
|
||||
return EngineConfig.builder()
|
||||
.versionCode(engineConfigSaveReq.getVersionCode())
|
||||
.ruleContent(engineConfigSaveReq.getRuleContent())
|
||||
.engineMaintenanceId(engineConfigSaveReq.getEngineMaintenanceId())
|
||||
.remark(engineConfigSaveReq.getRemark())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static EngineConfig editBuild(Long id, EngineConfigEditReq engineConfigEditReq, Supplier<String> updateBy){
|
||||
return EngineConfig.builder()
|
||||
.id(id)
|
||||
.versionCode(engineConfigEditReq.getVersionCode())
|
||||
.ruleContent(engineConfigEditReq.getRuleContent())
|
||||
.engineMaintenanceId(engineConfigEditReq.getEngineMaintenanceId())
|
||||
.remark(engineConfigEditReq.getRemark())
|
||||
.updateBy(updateBy.get())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.ruleEngine.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 引擎规则配置对象 engine_config
|
||||
*
|
||||
* @author HuFangMing
|
||||
* @ClassName: EngineConfigSaveReq
|
||||
* @createTime: 2024/5/4 15:42
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "EngineConfigSaveReq", description = "引擎规则配置")
|
||||
public class EngineConfigSaveReq extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 编号 */
|
||||
|
||||
@ApiModelProperty(name = "编号", value = "编号")
|
||||
private Long id;
|
||||
|
||||
/** 版本编码 */
|
||||
|
||||
@ApiModelProperty(name = "版本编码", value = "版本编码", required = true)
|
||||
private String versionCode;
|
||||
|
||||
/** 规则内容 */
|
||||
|
||||
@ApiModelProperty(name = "规则内容", value = "规则内容", required = true)
|
||||
private String ruleContent;
|
||||
|
||||
/** 引擎维护编号 */
|
||||
|
||||
@ApiModelProperty(name = "引擎维护编号", value = "引擎维护编号", required = true)
|
||||
private Long engineMaintenanceId;
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
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.EngineConfig;
|
||||
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.resp.EngineConfigScopeResp;
|
||||
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||
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 gtl
|
||||
* @date 2024-05-02
|
||||
*/
|
||||
@Api(tags = "引擎配置")
|
||||
@RestController
|
||||
@RequestMapping("/config")
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询引擎规则配置列表
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue