feat: 规则引擎
parent
55c4dc4838
commit
fbbe3eb251
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-kvt</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-kvt-client</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -19,7 +19,7 @@ public class DataStructure {
|
|||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
|
||||
private String tableName;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.muyu.kvt.permissions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 权限表 Permissions
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class PermissionsUser {
|
||||
/*
|
||||
主键
|
||||
*/
|
||||
private Integer id;
|
||||
/*
|
||||
用户id
|
||||
*/
|
||||
private Long userId;
|
||||
/*
|
||||
数据源id
|
||||
*/
|
||||
private Integer kvtId;
|
||||
/*
|
||||
表名
|
||||
*/
|
||||
private String tbaleName;
|
||||
/*
|
||||
部门
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -22,6 +22,5 @@ import java.sql.*;
|
|||
public class MuyuApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MuyuApplication.class);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.kvt.controller;
|
||||
|
||||
import java.security.Permissions;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,6 +22,7 @@ import com.muyu.kvt.domain.*;
|
|||
import com.muyu.kvt.domain.req.KvtEditReq;
|
||||
import com.muyu.kvt.domain.req.KvtQueryReq;
|
||||
import com.muyu.kvt.domain.req.KvtSaveReq;
|
||||
import com.muyu.kvt.permissions.PermissionsUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -265,4 +267,25 @@ public class KvtController extends BaseController {
|
|||
List<DataDisplay> list= kvtService.selectDataDisplayName(name);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
//添加权限表
|
||||
@PostMapping("/permissionsUserAdd")
|
||||
public Result permissionsUserAdd(@RequestBody PermissionsUser permissionsUser){
|
||||
kvtService.permissionsUserAdd(permissionsUser);
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
|
||||
//删除权限表
|
||||
@PostMapping("/permissionsUserDel")
|
||||
public Result permissionsUserDel(@RequestBody PermissionsUser permissionsUser){
|
||||
kvtService.permissionsUserDel(permissionsUser);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
//查询权限表
|
||||
@PostMapping("/selectPermission")
|
||||
public Result<List<PermissionsUser>> selectPermission(){
|
||||
List<PermissionsUser> list= kvtService.selectPermission();
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.muyu.kvt.dictionary.Diction;
|
|||
import com.muyu.kvt.dictionary.DictionaryType;
|
||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||
import com.muyu.kvt.domain.*;
|
||||
import com.muyu.kvt.permissions.PermissionsUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -94,4 +95,12 @@ public interface KvtMapper extends BaseMapper<Kvt> {
|
|||
List<DataDisplay> listResult();
|
||||
|
||||
List<DataDisplay> selectDataDisplayName(@Param("name") String name);
|
||||
|
||||
void permissionsUserAdd(PermissionsUser build);
|
||||
|
||||
void permissionsUserDel(PermissionsUser permissionsUser);
|
||||
|
||||
List<PermissionsUser> selectPermission();
|
||||
|
||||
List<PermissionsUser> permissionsUserSelect(PermissionsUser build);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.muyu.kvt.dictionary.Diction;
|
|||
import com.muyu.kvt.dictionary.DictionaryType;
|
||||
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||
import com.muyu.kvt.domain.*;
|
||||
import com.muyu.kvt.permissions.PermissionsUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
@ -68,4 +69,12 @@ public interface KvtService extends IService<Kvt> {
|
|||
List<DataDisplay> listResult();
|
||||
|
||||
List<DataDisplay> selectDataDisplayName(String name);
|
||||
|
||||
void permissionsUserAdd(PermissionsUser permissionsUser);
|
||||
|
||||
void permissionsUserDel(PermissionsUser permissionsUser);
|
||||
|
||||
List<PermissionsUser> selectPermission();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.kvt.service.impl;
|
|||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
||||
|
@ -21,6 +23,7 @@ import com.muyu.kvt.dictionary.DictionaryType;
|
|||
import com.muyu.kvt.dictionary.Dictionaryy;
|
||||
import com.muyu.kvt.domain.*;
|
||||
|
||||
import com.muyu.kvt.permissions.PermissionsUser;
|
||||
import com.muyu.kvt.remote.RemoteUserSer;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -166,7 +169,10 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
List<ChildrenList> list = baseMapper.selectDepartment(databaseName);
|
||||
// Kvt kvt = baseMapper.selectType(databaseName);
|
||||
List<ChildrenList> childrenLists = new ArrayList<>();
|
||||
|
||||
|
||||
for (ChildrenList childrenList : list) {
|
||||
|
||||
ChildrenList build = ChildrenList.builder()
|
||||
.name(childrenList.getName())
|
||||
.dataTotal(childrenList.getDataTotal())
|
||||
|
@ -191,9 +197,13 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
|
||||
@Override
|
||||
public List<DataStructure> selectDataStur(String tableName) {
|
||||
return baseMapper.selectDataStur(tableName);
|
||||
List<DataStructure> list = baseMapper.selectDataStur(tableName);
|
||||
return list;
|
||||
}
|
||||
public void user(){
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public Child selectChild(String tableName) {
|
||||
return baseMapper.selectChild(tableName);
|
||||
|
@ -201,7 +211,22 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
|
||||
@Override
|
||||
public List<DataStructure> selectChildAll() {
|
||||
return baseMapper.selectChildAll();
|
||||
Result<SysUser> sysUserResult = remoteUserSer.selectUserId(SecurityUtils.getUserId());
|
||||
SysUser data = sysUserResult.getData();
|
||||
List<PermissionsUser> permissionsUsers = this.selectPermission();
|
||||
// ...(你可能不需要SysUser对象,除非后续有使用)
|
||||
|
||||
Set<String> tableNameSet = permissionsUsers.stream()
|
||||
.map(PermissionsUser::getTbaleName) // 确保使用正确的方法名getTableName
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<DataStructure> list = baseMapper.selectChildAll();
|
||||
List<DataStructure> notContainingCollect = list.stream()
|
||||
.filter(dataStructure -> !tableNameSet.contains(dataStructure.getTableName())) // 使用!进行否定
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// notContainingCollect现在包含了不包含在permissionsUsers中tableName的DataStructure对象列表
|
||||
return notContainingCollect; // 返回不包含符合条件的数据的列表
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -665,6 +690,35 @@ public class KvtServiceImpl extends ServiceImpl<KvtMapper, Kvt> implements KvtSe
|
|||
return baseMapper.selectDataDisplayName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void permissionsUserAdd(PermissionsUser permissionsUser) {
|
||||
|
||||
PermissionsUser build = PermissionsUser.builder()
|
||||
.userId(permissionsUser.getUserId())
|
||||
.kvtId(permissionsUser.getKvtId())
|
||||
.deptId(permissionsUser.getDeptId())
|
||||
.tbaleName(permissionsUser.getTbaleName())
|
||||
.build();
|
||||
//先查询表中是否有这条数据
|
||||
if (baseMapper.permissionsUserSelect(build)!=null) {
|
||||
baseMapper.permissionsUserAdd(build);
|
||||
}else {
|
||||
baseMapper.permissionsUserDel(build);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void permissionsUserDel(PermissionsUser permissionsUser) {
|
||||
baseMapper.permissionsUserDel(permissionsUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionsUser> selectPermission() {
|
||||
return baseMapper.selectPermission();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 根据库名跟表名查询字段信息
|
||||
* @return
|
||||
|
|
|
@ -65,6 +65,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<delete id="del">
|
||||
truncate table #{tableName}
|
||||
</delete>
|
||||
<delete id="permissionsUserDel">
|
||||
delete from permissions_user where user_id = #{userId}
|
||||
and kvt_id = #{kvtId}
|
||||
and tbale_name = #{tbaleName}
|
||||
and dept_id = #{deptId}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="dataTypeList" resultType="com.muyu.kvt.domain.DataType">
|
||||
|
@ -202,6 +208,15 @@ SELECT
|
|||
<select id="selectDataDisplayName" resultType="com.muyu.kvt.datadisplay.DataDisplay">
|
||||
SELECT * FROM data_display WHERE war_name LIKE CONCAT('%', #{name}, '%');
|
||||
</select>
|
||||
<select id="selectPermission" resultType="com.muyu.kvt.permissions.PermissionsUser">
|
||||
SELECT * FROM permissions_user
|
||||
</select>
|
||||
<select id="permissionsUserSelect" resultType="com.muyu.kvt.permissions.PermissionsUser">
|
||||
select * from permissions_user where user_id = #{userId}
|
||||
and kvt_id = #{kvtId}
|
||||
and tbale_name = #{tbaleName}
|
||||
and dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="synchronizationAdd">
|
||||
|
@ -287,5 +302,9 @@ SELECT
|
|||
(#{dataDisplays.warName}, #{dataDisplays.type}, #{dataDisplays.value})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="permissionsUserAdd">
|
||||
INSERT INTO `data_basete`.`permissions_user` ( `user_id`, `kvt_id`, `tbale_name`, `dept_id`)
|
||||
values (#{userId},#{kvtId},#{tbaleName},#{deptId})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<module>muyu-kvt-common</module>
|
||||
<module>muyu-kvt-remote</module>
|
||||
<module>muyu-kvt-server</module>
|
||||
<module>muyu-kvt-client</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
package com.muyu.engine.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.engine.domain.req.RuleEngineEditReq;
|
||||
import com.muyu.engine.domain.req.RuleEngineQueryReq;
|
||||
import com.muyu.engine.domain.req.RuleEngineSaveReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 规则引擎对象 rule_engine
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("rule_engine")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "RuleEngine", description = "规则引擎")
|
||||
public class RuleEngine extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "id", value = "id")
|
||||
private Long id;
|
||||
|
||||
/** 规则名称 */
|
||||
@Excel(name = "规则名称")
|
||||
@ApiModelProperty(name = "规则名称", value = "规则名称")
|
||||
private String name;
|
||||
|
||||
/** 规则类型 */
|
||||
@Excel(name = "规则类型")
|
||||
@ApiModelProperty(name = "规则类型", value = "规则类型")
|
||||
private String type;
|
||||
|
||||
/** 规则编码 */
|
||||
@Excel(name = "规则编码")
|
||||
@ApiModelProperty(name = "规则编码", value = "规则编码")
|
||||
private String code;
|
||||
|
||||
/** 规则级别 */
|
||||
@Excel(name = "规则级别")
|
||||
@ApiModelProperty(name = "规则级别", value = "规则级别")
|
||||
private String level;
|
||||
|
||||
/** 是否激活 */
|
||||
@Excel(name = "是否激活")
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
|
||||
/** 规则状态 */
|
||||
@Excel(name = "规则状态")
|
||||
@ApiModelProperty(name = "规则状态", value = "规则状态")
|
||||
private String status;
|
||||
|
||||
/** 编写文件名称 */
|
||||
@Excel(name = "编写文件名称")
|
||||
@ApiModelProperty(name = "编写文件名称", value = "编写文件名称")
|
||||
private String writeCode;
|
||||
|
||||
/** 引擎编码 */
|
||||
@Excel(name = "引擎编码")
|
||||
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||
private String engineCode;
|
||||
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static RuleEngine queryBuild( RuleEngineQueryReq ruleEngineQueryReq){
|
||||
return RuleEngine.builder()
|
||||
.name(ruleEngineQueryReq.getName())
|
||||
.type(ruleEngineQueryReq.getType())
|
||||
.code(ruleEngineQueryReq.getCode())
|
||||
.level(ruleEngineQueryReq.getLevel())
|
||||
.isActivate(ruleEngineQueryReq.getIsActivate())
|
||||
.status(ruleEngineQueryReq.getStatus())
|
||||
.writeCode(ruleEngineQueryReq.getWriteCode())
|
||||
.engineCode(ruleEngineQueryReq.getEngineCode())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static RuleEngine saveBuild(RuleEngineSaveReq ruleEngineSaveReq){
|
||||
return RuleEngine.builder()
|
||||
.name(ruleEngineSaveReq.getName())
|
||||
.type(ruleEngineSaveReq.getType())
|
||||
.code(ruleEngineSaveReq.getCode())
|
||||
.level(ruleEngineSaveReq.getLevel())
|
||||
.isActivate(ruleEngineSaveReq.getIsActivate())
|
||||
.status(ruleEngineSaveReq.getStatus())
|
||||
.writeCode(ruleEngineSaveReq.getWriteCode())
|
||||
.engineCode(ruleEngineSaveReq.getEngineCode())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static RuleEngine editBuild(Long id, RuleEngineEditReq ruleEngineEditReq){
|
||||
return RuleEngine.builder()
|
||||
.id(id)
|
||||
.name(ruleEngineEditReq.getName())
|
||||
.type(ruleEngineEditReq.getType())
|
||||
.code(ruleEngineEditReq.getCode())
|
||||
.level(ruleEngineEditReq.getLevel())
|
||||
.isActivate(ruleEngineEditReq.getIsActivate())
|
||||
.status(ruleEngineEditReq.getStatus())
|
||||
.writeCode(ruleEngineEditReq.getWriteCode())
|
||||
.engineCode(ruleEngineEditReq.getEngineCode())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.muyu.engine.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineVersion;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 前台传的 RuleEngines
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/4
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class RuleEngines {
|
||||
|
||||
|
||||
/** $column.columnComment */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 规则名称 */
|
||||
@Excel(name = "规则名称")
|
||||
private String name;
|
||||
|
||||
/** 规则类型 */
|
||||
@Excel(name = "规则类型")
|
||||
private String type;
|
||||
|
||||
/** 规则编码 */
|
||||
@Excel(name = "规则编码")
|
||||
private String code;
|
||||
|
||||
/** 规则级别 */
|
||||
@Excel(name = "规则级别")
|
||||
private String level;
|
||||
|
||||
/** 是否激活 */
|
||||
@Excel(name = "是否激活")
|
||||
private String isActivate;
|
||||
|
||||
/** 规则状态 */
|
||||
@Excel(name = "规则状态")
|
||||
private String status;
|
||||
|
||||
/** 编写文件名称 */
|
||||
@Excel(name = "编写文件名称")
|
||||
private String writeCode;
|
||||
|
||||
/** 引擎编码 */
|
||||
@Excel(name = "引擎编码")
|
||||
private String engineCode;
|
||||
|
||||
private String sql;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.engine.domain.req;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 规则引擎对象 rule_engine
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "RuleEngineEditReq", description = "规则引擎")
|
||||
public class RuleEngineEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 规则名称 */
|
||||
@ApiModelProperty(name = "规则名称", value = "规则名称")
|
||||
private String name;
|
||||
|
||||
/** 规则类型 */
|
||||
@ApiModelProperty(name = "规则类型", value = "规则类型")
|
||||
private String type;
|
||||
|
||||
/** 规则编码 */
|
||||
@ApiModelProperty(name = "规则编码", value = "规则编码")
|
||||
private String code;
|
||||
|
||||
/** 规则级别 */
|
||||
@ApiModelProperty(name = "规则级别", value = "规则级别")
|
||||
private String level;
|
||||
|
||||
/** 是否激活 */
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
|
||||
/** 规则状态 */
|
||||
@ApiModelProperty(name = "规则状态", value = "规则状态")
|
||||
private String status;
|
||||
|
||||
/** 编写文件名称 */
|
||||
@Excel(name = "编写文件名称")
|
||||
@ApiModelProperty(name = "编写文件名称", value = "编写文件名称")
|
||||
private String writeCode;
|
||||
/** 引擎编码 */
|
||||
@Excel(name = "引擎编码")
|
||||
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||
private String engineCode;
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.engine.domain.req;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 规则引擎对象 rule_engine
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "RuleEngineQueryReq", description = "规则引擎")
|
||||
public class RuleEngineQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 规则名称 */
|
||||
@ApiModelProperty(name = "规则名称", value = "规则名称")
|
||||
private String name;
|
||||
|
||||
/** 规则类型 */
|
||||
@ApiModelProperty(name = "规则类型", value = "规则类型")
|
||||
private String type;
|
||||
|
||||
/** 规则编码 */
|
||||
@ApiModelProperty(name = "规则编码", value = "规则编码")
|
||||
private String code;
|
||||
|
||||
/** 规则级别 */
|
||||
@ApiModelProperty(name = "规则级别", value = "规则级别")
|
||||
private String level;
|
||||
|
||||
/** 是否激活 */
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
|
||||
/** 规则状态 */
|
||||
@ApiModelProperty(name = "规则状态", value = "规则状态")
|
||||
private String status;
|
||||
|
||||
/** 编写文件名称 */
|
||||
@Excel(name = "编写文件名称")
|
||||
@ApiModelProperty(name = "编写文件名称", value = "编写文件名称")
|
||||
private String writeCode;
|
||||
/** 引擎编码 */
|
||||
@Excel(name = "引擎编码")
|
||||
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||
private String engineCode;
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.muyu.engine.domain.req;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 规则引擎对象 rule_engine
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "RuleEngineSaveReq", description = "规则引擎")
|
||||
public class RuleEngineSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
|
||||
@ApiModelProperty(name = "${column.columnComment}", value = "${column.columnComment}")
|
||||
private Long id;
|
||||
|
||||
/** 规则名称 */
|
||||
|
||||
@ApiModelProperty(name = "规则名称", value = "规则名称")
|
||||
private String name;
|
||||
|
||||
/** 规则类型 */
|
||||
|
||||
@ApiModelProperty(name = "规则类型", value = "规则类型")
|
||||
private String type;
|
||||
|
||||
/** 规则编码 */
|
||||
|
||||
@ApiModelProperty(name = "规则编码", value = "规则编码")
|
||||
private String code;
|
||||
|
||||
/** 规则级别 */
|
||||
|
||||
@ApiModelProperty(name = "规则级别", value = "规则级别")
|
||||
private String level;
|
||||
|
||||
/** 是否激活 */
|
||||
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
|
||||
/** 规则状态 */
|
||||
|
||||
@ApiModelProperty(name = "规则状态", value = "规则状态")
|
||||
private String status;
|
||||
|
||||
/** 编写文件名称 */
|
||||
@Excel(name = "编写文件名称")
|
||||
@ApiModelProperty(name = "编写文件名称", value = "编写文件名称")
|
||||
private String writeCode;
|
||||
|
||||
/** 引擎编码 */
|
||||
@Excel(name = "引擎编码")
|
||||
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||
private String engineCode;
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.muyu.engine.domain.rule_engine_version;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 引擎维护版本 RuleEngine
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class RuleEngineList {
|
||||
/** $column.columnComment */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "id", value = "id")
|
||||
private Long id;
|
||||
|
||||
/** 规则名称 */
|
||||
@Excel(name = "规则名称")
|
||||
@ApiModelProperty(name = "规则名称", value = "规则名称")
|
||||
private String name;
|
||||
|
||||
/** 规则类型 */
|
||||
@Excel(name = "规则类型")
|
||||
@ApiModelProperty(name = "规则类型", value = "规则类型")
|
||||
private String type;
|
||||
|
||||
/** 规则编码 */
|
||||
@Excel(name = "规则编码")
|
||||
@ApiModelProperty(name = "规则编码", value = "规则编码")
|
||||
private String code;
|
||||
|
||||
/** 规则级别 */
|
||||
@Excel(name = "规则级别")
|
||||
@ApiModelProperty(name = "规则级别", value = "规则级别")
|
||||
private String level;
|
||||
|
||||
/** 是否激活 */
|
||||
@Excel(name = "是否激活")
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
|
||||
/** 规则状态 */
|
||||
@Excel(name = "规则状态")
|
||||
@ApiModelProperty(name = "规则状态", value = "规则状态")
|
||||
private String status;
|
||||
|
||||
/** 编写文件名称 */
|
||||
@Excel(name = "编写文件名称")
|
||||
@ApiModelProperty(name = "编写文件名称", value = "编写文件名称")
|
||||
private String writeCode;
|
||||
|
||||
/** 引擎编码 */
|
||||
@Excel(name = "引擎编码")
|
||||
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||
private String engineCode;
|
||||
/*
|
||||
是否测试
|
||||
*/
|
||||
@Excel(name = "是否测试")
|
||||
@ApiModelProperty(name = "是否测试", value = "是否测试")
|
||||
private String isTest;
|
||||
|
||||
// 关联 版本
|
||||
private List<RuleEngineVersion> ruleEngineVersionList;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package com.muyu.engine.domain.rule_engine_version;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.domain.req.RuleEngineQueryReq;
|
||||
import com.muyu.engine.domain.rule_engine_version.req.RuleEngineVersionQueryReq;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 规则引擎版本 RuleEngineVersion
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleEngineVersion extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
主键
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "id", value = "id")
|
||||
private Integer id;
|
||||
/*
|
||||
规则id
|
||||
*/
|
||||
@Excel(name = "规则id")
|
||||
@ApiModelProperty(name = "规则id", value = "规则id")
|
||||
private Integer ruleEngineId;
|
||||
/*
|
||||
版本类
|
||||
*/
|
||||
@Excel(name = "版本类")
|
||||
@ApiModelProperty(name = "版本类", value = "版本类")
|
||||
private String versionCode;
|
||||
/*
|
||||
版本名称
|
||||
*/
|
||||
@Excel(name = "版本名称")
|
||||
@ApiModelProperty(name = "版本名称", value = "版本名称")
|
||||
private String name;
|
||||
/*
|
||||
版本CODE
|
||||
*/
|
||||
@Excel(name = "版本CODE")
|
||||
@ApiModelProperty(name = "版本CODE", value = "版本CODE")
|
||||
private String code;
|
||||
/*
|
||||
是否激活
|
||||
*/
|
||||
@Excel(name = "是否激活")
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
/*
|
||||
版本状态
|
||||
*/
|
||||
@Excel(name = "版本状态")
|
||||
@ApiModelProperty(name = "版本状态", value = "版本状态")
|
||||
private String status;
|
||||
/*
|
||||
版本说明
|
||||
*/
|
||||
@Excel(name = "版本说明")
|
||||
@ApiModelProperty(name = "版本说明", value = "版本说明")
|
||||
private String description;
|
||||
/*
|
||||
文件名称
|
||||
*/
|
||||
@Excel(name = "文件名称")
|
||||
@ApiModelProperty(name = "文件名称", value = "文件名称")
|
||||
private String writeCode;
|
||||
/*
|
||||
编码
|
||||
*/
|
||||
@Excel(name = "编码")
|
||||
@ApiModelProperty(name = "编码", value = "编码")
|
||||
private String codeIng;
|
||||
/*
|
||||
是否测试
|
||||
*/
|
||||
@Excel(name = "是否测试")
|
||||
@ApiModelProperty(name = "是否测试", value = "是否测试")
|
||||
private String isTest;
|
||||
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static RuleEngineVersion queryBuild(RuleEngineVersionQueryReq ruleEngineVersionQueryReq){
|
||||
return RuleEngineVersion.builder()
|
||||
.ruleEngineId(ruleEngineVersionQueryReq.getRuleEngineId())
|
||||
.versionCode(ruleEngineVersionQueryReq.getVersionCode())
|
||||
.name(ruleEngineVersionQueryReq.getName())
|
||||
.code(ruleEngineVersionQueryReq.getCode())
|
||||
.isActivate(ruleEngineVersionQueryReq.getIsActivate())
|
||||
.status(ruleEngineVersionQueryReq.getStatus())
|
||||
.description(ruleEngineVersionQueryReq.getDescription())
|
||||
.codeIng(ruleEngineVersionQueryReq.getCodeIng())
|
||||
.writeCode(ruleEngineVersionQueryReq.getWriteCode())
|
||||
.isTest(ruleEngineVersionQueryReq.getIsTest())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.muyu.engine.domain.rule_engine_version.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
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.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 查询规则引擎版本 RuleEngineVersion
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "RuleEngineQueryReq", description = "规则引擎版本")
|
||||
public class RuleEngineVersionQueryReq extends BaseEntity {
|
||||
|
||||
|
||||
/*
|
||||
规则id
|
||||
*/
|
||||
@Excel(name = "规则id")
|
||||
@ApiModelProperty(name = "规则id", value = "规则id")
|
||||
private Integer ruleEngineId;
|
||||
/*
|
||||
版本类
|
||||
*/
|
||||
@Excel(name = "版本类")
|
||||
@ApiModelProperty(name = "版本类", value = "版本类")
|
||||
private String versionCode;
|
||||
/*
|
||||
版本名称
|
||||
*/
|
||||
@Excel(name = "版本名称")
|
||||
@ApiModelProperty(name = "版本名称", value = "版本名称")
|
||||
private String name;
|
||||
/*
|
||||
版本CODE
|
||||
*/
|
||||
@Excel(name = "版本CODE")
|
||||
@ApiModelProperty(name = "版本CODE", value = "版本CODE")
|
||||
private String code;
|
||||
/*
|
||||
是否激活
|
||||
*/
|
||||
@Excel(name = "是否激活")
|
||||
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||
private String isActivate;
|
||||
/*
|
||||
版本状态
|
||||
*/
|
||||
@Excel(name = "版本状态")
|
||||
@ApiModelProperty(name = "版本状态", value = "版本状态")
|
||||
private String status;
|
||||
/*
|
||||
版本说明
|
||||
*/
|
||||
@Excel(name = "版本说明")
|
||||
@ApiModelProperty(name = "版本说明", value = "版本说明")
|
||||
private String description;
|
||||
/*
|
||||
文件名称
|
||||
*/
|
||||
@Excel(name = "文件名称")
|
||||
@ApiModelProperty(name = "文件名称", value = "文件名称")
|
||||
private String writeCode;
|
||||
|
||||
/*
|
||||
编码
|
||||
*/
|
||||
@Excel(name = "编码")
|
||||
@ApiModelProperty(name = "编码", value = "编码")
|
||||
private String codeIng;
|
||||
/*
|
||||
是否测试
|
||||
*/
|
||||
@Excel(name = "是否测试")
|
||||
@ApiModelProperty(name = "是否测试", value = "是否测试")
|
||||
private String isTest;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.engine;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* RuleEngineApplication
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/1
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class RuleEngineApplication {
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(RuleEngineApplication.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package com.muyu.engine.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.engine.domain.RuleEngines;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
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.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.domain.req.RuleEngineQueryReq;
|
||||
import com.muyu.engine.domain.req.RuleEngineSaveReq;
|
||||
import com.muyu.engine.domain.req.RuleEngineEditReq;
|
||||
import com.muyu.engine.service.RuleEngineService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 规则引擎Controller
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
@Api(tags = "规则引擎")
|
||||
@RestController
|
||||
@RequestMapping("/engine")
|
||||
public class RuleEngineController extends BaseController {
|
||||
@Autowired
|
||||
private RuleEngineService ruleEngineService;
|
||||
|
||||
/**
|
||||
* 查询规则引擎列表
|
||||
*/
|
||||
@ApiOperation("获取规则引擎列表")
|
||||
@RequiresPermissions("rule_engine:engine:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<RuleEngine>> list(RuleEngineQueryReq ruleEngineQueryReq) {
|
||||
startPage();
|
||||
List<RuleEngine> list = ruleEngineService.list(RuleEngine.queryBuild(ruleEngineQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出规则引擎列表
|
||||
*/
|
||||
@ApiOperation("导出规则引擎列表")
|
||||
@RequiresPermissions("rule_engine:engine:export")
|
||||
@Log(title = "规则引擎", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RuleEngine ruleEngine) {
|
||||
List<RuleEngine> list = ruleEngineService.list(ruleEngine);
|
||||
ExcelUtil<RuleEngine> util = new ExcelUtil<RuleEngine>(RuleEngine.class);
|
||||
util.exportExcel(response, list, "规则引擎数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规则引擎详细信息
|
||||
*/
|
||||
@ApiOperation("获取规则引擎详细信息")
|
||||
@RequiresPermissions("rule_engine:engine:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<RuleEngine> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(ruleEngineService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增规则引擎
|
||||
*/
|
||||
@RequiresPermissions("rule_engine:engine:add")
|
||||
@Log(title = "规则引擎", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增规则引擎")
|
||||
public Result add(@RequestBody RuleEngineSaveReq ruleEngineSaveReq) throws Exception {
|
||||
ruleEngineService.add(RuleEngine.saveBuild(ruleEngineSaveReq));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规则引擎
|
||||
*/
|
||||
@RequiresPermissions("rule_engine:engine:edit")
|
||||
@Log(title = "规则引擎", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改规则引擎")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody RuleEngineEditReq ruleEngineEditReq) {
|
||||
return toAjax(ruleEngineService.updateById(RuleEngine.editBuild(id,ruleEngineEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规则引擎
|
||||
*/
|
||||
@RequiresPermissions("rule_engine:engine: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(ruleEngineService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
//编写代码
|
||||
@ApiOperation("编写代码")
|
||||
@PostMapping("/writeCode")
|
||||
public Result code(@RequestBody RuleEngine ruleEngine) throws Exception {
|
||||
return Result.success( ruleEngineService.code(ruleEngine));
|
||||
}
|
||||
|
||||
|
||||
//加载
|
||||
@PostMapping("/loading")
|
||||
public Result load(@RequestBody RuleEngine ruleEngine) {
|
||||
String load = ruleEngineService.load(ruleEngine);
|
||||
return Result.success(load);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/writeCodeAdd")
|
||||
public Result writeCodeAdd(@RequestBody RuleEngines ruleEngine) throws IOException {
|
||||
String s = ruleEngineService.writeCodeAdd(ruleEngine);
|
||||
return Result.success(s);
|
||||
}
|
||||
//修改规则引擎是否激活
|
||||
@PostMapping("/updateRuleEngineVersionIsActivate")
|
||||
public Result updateRuleEngineVersionIsActivate(@RequestBody RuleEngine ruleEngine){
|
||||
ruleEngineService.updateRuleEngineVersionIsActivate(ruleEngine);
|
||||
return Result.success("引擎激活状态修改成功");
|
||||
} //修改引擎状态
|
||||
@PostMapping("/updateRuleEngineVersionStates")
|
||||
public Result updateRuleEngineVersionStates(@RequestBody RuleEngine ruleEngine){
|
||||
ruleEngineService.updateRuleEngineVersionStates(ruleEngine);
|
||||
return Result.success("引擎状态操作成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.engine.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineList;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineVersion;
|
||||
import com.muyu.engine.domain.rule_engine_version.req.RuleEngineVersionQueryReq;
|
||||
import com.muyu.engine.service.RuleEngineVersionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规则引擎版本控制层 RuleEngineVersionController
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/engine")
|
||||
public class RuleEngineVersionController extends BaseController {
|
||||
@Autowired
|
||||
private RuleEngineVersionService ruleEngineVersionService;
|
||||
|
||||
/**
|
||||
* 获取规则引擎版本列表
|
||||
* @param ruleEngineVersionQueryReq
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/RuleEngineVersionList")
|
||||
public Result<List<RuleEngineVersion>> RuleEngineVersionList(RuleEngineVersionQueryReq ruleEngineVersionQueryReq) {
|
||||
startPage();
|
||||
List<RuleEngineVersion> ruleEngineVersionList= ruleEngineVersionService.list( RuleEngineVersion.queryBuild(ruleEngineVersionQueryReq));
|
||||
return Result.success(ruleEngineVersionList);
|
||||
}
|
||||
|
||||
//查询规则引擎版本详情
|
||||
@PostMapping("/selectRuleEngineVersion")
|
||||
public Result<RuleEngineList> listResult(@RequestParam Integer id){
|
||||
RuleEngineList ruleEngineList = ruleEngineVersionService.listResult(id);
|
||||
return Result.success(ruleEngineList);
|
||||
}
|
||||
|
||||
|
||||
//添加规则引擎版本
|
||||
@PostMapping("/RuleEngineVersionAdd")
|
||||
public Result RuleEngineVersionAdd(@RequestBody RuleEngineVersion ruleEngineVersion){
|
||||
ruleEngineVersionService.RuleEngineVersionAdd(ruleEngineVersion);
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
|
||||
//规则引擎中版本的状态修改
|
||||
@PostMapping("/updataEngineVersionStatus")
|
||||
public Result updataEngineVersionStatus(@RequestBody RuleEngineVersion ruleEngineVersion){
|
||||
ruleEngineVersionService.updataEngineVersionStatus(ruleEngineVersion);
|
||||
return Result.success("编码保存成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.engine.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
|
||||
/**
|
||||
* 规则引擎Mapper接口
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
public interface RuleEngineMapper extends BaseMapper<RuleEngine> {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.engine.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineVersion;
|
||||
|
||||
/**
|
||||
* RuleEngineVersionMapper
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
|
||||
public interface RuleEngineVersionMapper extends BaseMapper<RuleEngineVersion> {
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.engine.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.engine.domain.RuleEngines;
|
||||
|
||||
/**
|
||||
* 规则引擎Service接口
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
public interface RuleEngineService extends IService<RuleEngine> {
|
||||
/**
|
||||
* 查询规则引擎列表
|
||||
*
|
||||
* @param ruleEngine 规则引擎
|
||||
* @return 规则引擎集合
|
||||
*/
|
||||
public List<RuleEngine> list(RuleEngine ruleEngine);
|
||||
|
||||
String code(RuleEngine ruleEngine) throws Exception;
|
||||
|
||||
|
||||
void add(RuleEngine saveBuild) throws Exception;
|
||||
|
||||
String load(RuleEngine ruleEngine);
|
||||
|
||||
String writeCodeAdd(RuleEngines ruleEngine) throws IOException;
|
||||
|
||||
void updateRuleEngineVersionIsActivate(RuleEngine ruleEngine);
|
||||
|
||||
void updateRuleEngineVersionStates(RuleEngine ruleEngine);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.engine.service;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineList;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineVersion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规则引擎版本业务层 RuleEngineVersionService
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
public interface RuleEngineVersionService {
|
||||
|
||||
List<RuleEngineVersion> list(RuleEngineVersion ruleEngineVersion);
|
||||
|
||||
RuleEngineList listResult(Integer id);
|
||||
|
||||
|
||||
void RuleEngineVersionAdd(RuleEngineVersion ruleEngineVersion);
|
||||
|
||||
void updataEngineVersionStatus(RuleEngineVersion ruleEngineVersion);
|
||||
|
||||
}
|
|
@ -0,0 +1,276 @@
|
|||
package com.muyu.engine.service.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.engine.domain.RuleEngines;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.engine.mapper.RuleEngineMapper;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.service.RuleEngineService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 规则引擎Service业务层处理
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineMapper, RuleEngine> implements RuleEngineService {
|
||||
|
||||
|
||||
// 全部变量
|
||||
public static String url = "D:\\JavaTest\\";
|
||||
|
||||
/**
|
||||
* 查询规则引擎列表
|
||||
*
|
||||
* @param ruleEngine 规则引擎
|
||||
* @return 规则引擎
|
||||
*/
|
||||
@Override
|
||||
public List<RuleEngine> list(RuleEngine ruleEngine) {
|
||||
LambdaQueryWrapper<RuleEngine> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(ruleEngine.getName())){
|
||||
queryWrapper.like(RuleEngine::getName, ruleEngine.getName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(ruleEngine.getType())){
|
||||
queryWrapper.eq(RuleEngine::getType, ruleEngine.getType());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(ruleEngine.getCode())){
|
||||
queryWrapper.eq(RuleEngine::getCode, ruleEngine.getCode());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(ruleEngine.getLevel())){
|
||||
queryWrapper.eq(RuleEngine::getLevel, ruleEngine.getLevel());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(ruleEngine.getIsActivate())){
|
||||
queryWrapper.eq(RuleEngine::getIsActivate, ruleEngine.getIsActivate());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(ruleEngine.getStatus())){
|
||||
queryWrapper.eq(RuleEngine::getStatus, ruleEngine.getStatus());
|
||||
}
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String code(RuleEngine ruleEngine) throws Exception {
|
||||
|
||||
if (ruleEngine.getType().equals("rule-custom")) {
|
||||
this.setParams(ruleEngine);
|
||||
}
|
||||
return "修改成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(RuleEngine saveBuild) throws Exception {
|
||||
this.save(saveBuild);
|
||||
if (saveBuild.getType().equals("rule-custom")){
|
||||
this.setParams(saveBuild);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String load(RuleEngine ruleEngine) {
|
||||
try {
|
||||
// Files.exists(Paths.get("D:\\JavaTest\\" + ruleEngine.getWriteCode() + ".java"));
|
||||
//找到文件并读取
|
||||
Path path = Paths.get(url + ruleEngine.getWriteCode() + ".java");
|
||||
if (Files.exists(path)) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8));
|
||||
String line;
|
||||
StringBuilder content = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
return content.toString();
|
||||
} else {
|
||||
return "文件不存在";
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return Result.error(ex).getMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String writeCodeAdd(RuleEngines ruleEngine) throws IOException {
|
||||
String aa = this.aa(ruleEngine, ruleEngine.getSql());
|
||||
return aa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRuleEngineVersionIsActivate(RuleEngine ruleEngine) {
|
||||
log.info("开始修改");
|
||||
if (ruleEngine.getIsActivate().equals("activated")){
|
||||
RuleEngine build = RuleEngine.builder()
|
||||
.isActivate("no-activate")
|
||||
.build();
|
||||
this.update(build,new LambdaQueryWrapper<RuleEngine>().eq(RuleEngine::getId,ruleEngine.getId()));
|
||||
log.info("修改成功",build);
|
||||
}else
|
||||
if (ruleEngine.getIsActivate().equals("no-activate")){
|
||||
RuleEngine build = RuleEngine.builder()
|
||||
.isActivate("activated")
|
||||
.build();
|
||||
this.update(build,new LambdaQueryWrapper<RuleEngine>().eq(RuleEngine::getId,ruleEngine.getId()));
|
||||
log.info("修改成功",build);
|
||||
}
|
||||
}
|
||||
|
||||
//修改规则引擎状态
|
||||
@Override
|
||||
public void updateRuleEngineVersionStates(RuleEngine ruleEngine) {
|
||||
if (ruleEngine.getStatus().equals("0")){
|
||||
RuleEngine build = RuleEngine.builder()
|
||||
.status("1")
|
||||
.build();
|
||||
this.update(build,new LambdaQueryWrapper<RuleEngine>().eq(RuleEngine::getId,ruleEngine.getId()));
|
||||
log.info("修改成功",build);
|
||||
}else
|
||||
if (ruleEngine.getStatus().equals("1")){
|
||||
RuleEngine build = RuleEngine.builder()
|
||||
.status("0")
|
||||
.build();
|
||||
this.update(build,new LambdaQueryWrapper<RuleEngine>().eq(RuleEngine::getId,ruleEngine.getId()));
|
||||
log.info("修改成功",build);
|
||||
}
|
||||
}
|
||||
|
||||
public String setParams (RuleEngine ruleEngine) throws Exception {
|
||||
|
||||
String sql ="\n" +
|
||||
"/**\n" +
|
||||
" * @Author: yangle\n" +
|
||||
" * @date: 2024/5/3\n" +
|
||||
" */\n" +
|
||||
"public class "+ruleEngine.getWriteCode()+" {\n" +
|
||||
"\n" +
|
||||
" public static void main(String[] args) {\n" +
|
||||
" String s=\"sss\";\n" +
|
||||
" if (s.equals(\"sss\")){\n" +
|
||||
" System.out.println(true);\n" +
|
||||
" }else {\n" +
|
||||
" System.out.println(false);\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
" ";
|
||||
return this.aVoid(ruleEngine,sql);
|
||||
|
||||
}
|
||||
|
||||
public String aVoid (RuleEngine ruleEngine,String sql) {
|
||||
try {
|
||||
// 文件路径
|
||||
String fileName = ruleEngine.getWriteCode() + ".java";
|
||||
String filePath =url + fileName;
|
||||
|
||||
|
||||
// 编译Java文件
|
||||
ProcessBuilder pbCompile = new ProcessBuilder("javac",fileName);
|
||||
pbCompile.directory(Paths.get(url).toFile()); // 设置工作目录
|
||||
pbCompile.redirectErrorStream(true);
|
||||
|
||||
// 将字符串写入文件
|
||||
Path path = Paths.get(filePath);
|
||||
Files.write(path, sql.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 编译
|
||||
Process compileProcess = pbCompile.start();
|
||||
// 等待编译结果
|
||||
compileProcess.waitFor();
|
||||
// 编译结果
|
||||
int compileResult = compileProcess.exitValue();
|
||||
System.out.println(compileResult == 0 ? "编译成功" : "编译失败");
|
||||
|
||||
ProcessBuilder pbRun = new ProcessBuilder("java",ruleEngine.getWriteCode());
|
||||
pbRun.directory(Paths.get(url).toFile());
|
||||
Process runProcess = pbRun.start();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(runProcess.getInputStream()));
|
||||
String str;
|
||||
str = bufferedReader.readLine();
|
||||
while (str != null) {
|
||||
System.out.println(str);
|
||||
break;
|
||||
}
|
||||
runProcess.waitFor();
|
||||
int runResult = runProcess.exitValue();
|
||||
System.out.println(runResult);
|
||||
|
||||
System.out.println(runResult == 0 ? "运行成功" : "运行失败");
|
||||
|
||||
return (compileResult == 0 ? "编译成功" : "编译失败");
|
||||
}catch (Exception e){
|
||||
return Result.error(e).getMsg();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public String aa (RuleEngines ruleEngine,String sql) {
|
||||
try {
|
||||
// 文件路径
|
||||
String fileName = ruleEngine.getWriteCode() + ".java";
|
||||
String filePath =url + fileName;
|
||||
|
||||
// 编译Java文件
|
||||
ProcessBuilder pbCompile = new ProcessBuilder("javac",fileName);
|
||||
pbCompile.directory(Paths.get(url).toFile()); // 设置工作目录
|
||||
pbCompile.redirectErrorStream(true);
|
||||
|
||||
// 将字符串写入文件
|
||||
Path path = Paths.get(filePath);
|
||||
Files.write(path, sql.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 编译
|
||||
Process compileProcess = pbCompile.start();
|
||||
// 等待编译结果
|
||||
compileProcess.waitFor();
|
||||
// 编译结果
|
||||
int compileResult = compileProcess.exitValue();
|
||||
System.out.println(compileResult == 0 ? "编译成功" : "编译失败");
|
||||
|
||||
ProcessBuilder pbRun = new ProcessBuilder("java",ruleEngine.getWriteCode());
|
||||
pbRun.directory(Paths.get(url).toFile());
|
||||
Process runProcess = pbRun.start();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(runProcess.getInputStream()));
|
||||
String str;
|
||||
str = bufferedReader.readLine();
|
||||
while (str != null) {
|
||||
System.out.println(str);
|
||||
break;
|
||||
}
|
||||
runProcess.waitFor();
|
||||
int runResult = runProcess.exitValue();
|
||||
System.out.println(runResult);
|
||||
|
||||
System.out.println(runResult == 0 ? "运行成功" : "运行失败");
|
||||
|
||||
return (compileResult == 0 ? "编译成功" : "编译失败");
|
||||
|
||||
}catch (Exception e){
|
||||
return Result.error(e).getMsg();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.muyu.engine.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.engine.domain.RuleEngine;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineList;
|
||||
import com.muyu.engine.domain.rule_engine_version.RuleEngineVersion;
|
||||
import com.muyu.engine.mapper.RuleEngineMapper;
|
||||
import com.muyu.engine.mapper.RuleEngineVersionMapper;
|
||||
import com.muyu.engine.service.RuleEngineService;
|
||||
import com.muyu.engine.service.RuleEngineVersionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 规则引擎版本业务实现层 RuleEngineVersionServiceImpl
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/5/6
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionMapper, RuleEngineVersion> implements RuleEngineVersionService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<RuleEngineVersion> list(RuleEngineVersion ruleEngineVersion) {
|
||||
LambdaQueryWrapper<RuleEngineVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (Objects.nonNull(ruleEngineVersion.getRuleEngineId())){
|
||||
queryWrapper.eq(RuleEngineVersion::getRuleEngineId,ruleEngineVersion.getRuleEngineId());
|
||||
}
|
||||
if (Objects.nonNull(ruleEngineVersion.getCode())){
|
||||
queryWrapper.eq(RuleEngineVersion::getCode,ruleEngineVersion.getCode());
|
||||
}
|
||||
if (Objects.nonNull(ruleEngineVersion.getName())){
|
||||
queryWrapper.eq(RuleEngineVersion::getName,ruleEngineVersion.getName());
|
||||
}
|
||||
if (Objects.nonNull(ruleEngineVersion.getVersionCode())){
|
||||
queryWrapper.eq(RuleEngineVersion::getVersionCode,ruleEngineVersion.getVersionCode());
|
||||
}
|
||||
if (Objects.nonNull(ruleEngineVersion.getWriteCode())){
|
||||
queryWrapper.eq(RuleEngineVersion::getWriteCode,ruleEngineVersion.getWriteCode());
|
||||
}
|
||||
if (Objects.nonNull(ruleEngineVersion.getStatus())){
|
||||
queryWrapper.eq(RuleEngineVersion::getStatus,ruleEngineVersion.getStatus());
|
||||
}
|
||||
if (Objects.nonNull(ruleEngineVersion.getIsActivate())){
|
||||
queryWrapper.eq(RuleEngineVersion::getIsActivate,ruleEngineVersion.getIsActivate());
|
||||
}
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
@Autowired
|
||||
private RuleEngineService ruleEngineService;
|
||||
@Override
|
||||
public RuleEngineList listResult(Integer id) {
|
||||
log.info("开始查询");
|
||||
LambdaQueryWrapper<RuleEngineVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//根据id 查询规则
|
||||
queryWrapper.eq(RuleEngineVersion::getRuleEngineId,id);
|
||||
List<RuleEngineVersion> list = list(queryWrapper);
|
||||
|
||||
LambdaQueryWrapper<RuleEngine> wrapper = new LambdaQueryWrapper<>();
|
||||
//根据id 查询规则引擎对象
|
||||
wrapper.eq(RuleEngine::getId,id);
|
||||
List<RuleEngine> ruleEngineList = ruleEngineService.list(wrapper);
|
||||
RuleEngineList collect = ruleEngineList.stream()
|
||||
.map(ruleEngine ->
|
||||
RuleEngineList.builder()
|
||||
.id(ruleEngine.getId())
|
||||
.name(ruleEngine.getName())
|
||||
.type(ruleEngine.getType())
|
||||
.code(ruleEngine.getCode())
|
||||
.level(ruleEngine.getLevel())
|
||||
.isActivate(ruleEngine.getIsActivate())
|
||||
.status(ruleEngine.getStatus())
|
||||
.writeCode(ruleEngine.getWriteCode())
|
||||
.engineCode(ruleEngine.getEngineCode())
|
||||
.ruleEngineVersionList(list)
|
||||
.build()
|
||||
).collect(Collectors.toList()).get(0);
|
||||
|
||||
|
||||
return collect;
|
||||
}
|
||||
|
||||
//全局变量
|
||||
public static String url="D:\\JavaTest\\";
|
||||
@Override
|
||||
public void RuleEngineVersionAdd(RuleEngineVersion ruleEngineVersion) {
|
||||
this.save(ruleEngineVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updataEngineVersionStatus(RuleEngineVersion ruleEngineVersion) {
|
||||
RuleEngineVersion build = RuleEngineVersion.builder()
|
||||
.status("1")
|
||||
.codeIng(ruleEngineVersion.getCodeIng())
|
||||
.build();
|
||||
this.update(build,new LambdaQueryWrapper<RuleEngineVersion>().eq(RuleEngineVersion::getId,ruleEngineVersion.getId()));
|
||||
this.writeCodeAdd(ruleEngineVersion);
|
||||
log.info("编码保存成功",build);
|
||||
|
||||
}
|
||||
|
||||
//生产源文件
|
||||
public void writeCodeAdd(RuleEngineVersion ruleEngineVersion) {
|
||||
try{
|
||||
//文件路径
|
||||
String fileName =ruleEngineVersion.getWriteCode()+".java";
|
||||
String filePath = url+fileName;
|
||||
|
||||
//编写java文件
|
||||
ProcessBuilder pbCompiler = new ProcessBuilder("javac", fileName);
|
||||
pbCompiler.directory(Paths.get(url).toFile());
|
||||
pbCompiler.redirectErrorStream(true);
|
||||
|
||||
//将字符串写入文件中
|
||||
Path path = Paths.get(filePath);
|
||||
Files.write(path,ruleEngineVersion.getCodeIng().getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 编译
|
||||
Process process = pbCompiler.start();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
// 等待编译结果
|
||||
int exitCode = process.waitFor();
|
||||
|
||||
if (exitCode == 0) {
|
||||
System.out.println("编译成功");
|
||||
} else {
|
||||
System.out.println("编译失败");
|
||||
}
|
||||
|
||||
//编译成class文件
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("java", ruleEngineVersion.getWriteCode());
|
||||
processBuilder.directory(Paths.get(url).toFile());
|
||||
processBuilder.redirectErrorStream(true);
|
||||
Process Runprocess = processBuilder.start();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runprocess.getInputStream()));
|
||||
String str ;
|
||||
while ((str = bufferedReader.readLine()) != null) {
|
||||
System.out.println(str);
|
||||
break;
|
||||
}
|
||||
Runprocess.waitFor();
|
||||
int i = Runprocess.exitValue();
|
||||
if (i==0){
|
||||
System.out.println("运行成功");
|
||||
}else {
|
||||
System.out.println("运行失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9555
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-rule-engine
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 115.159.211.196:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 115.159.211.196:8848
|
||||
namespace: b8ace5a6-28a3-4126-b109-9b6623c58dc0
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.rule.engine.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-system"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.engine.mapper.RuleEngineMapper">
|
||||
|
||||
<resultMap type="com.muyu.engine.domain.RuleEngine" id="RuleEngineResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="type" column="type" />
|
||||
<result property="code" column="code" />
|
||||
<result property="level" column="level" />
|
||||
<result property="isActivate" column="is_activate" />
|
||||
<result property="status" column="status" />
|
||||
<result property="engineCode" column="engine_code" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRuleEngineVo">
|
||||
select id, name, type, code, level, is_activate, status, remark, create_by, create_time, update_by, update_time,engine_code from rule_engine
|
||||
</sql>
|
||||
</mapper>
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.engine.mapper.RuleEngineVersionMapper">
|
||||
|
||||
<!-- <resultMap type="com.muyu.engine.domain.rule_engine_version.RuleEngineVersion" id="RuleEngineResult">-->
|
||||
<!-- <result property="id" column="id" />-->
|
||||
<!-- <result property="ruleEngineId" column="rule_engine_id" />-->
|
||||
<!-- <result property="versionCode" column="version_code" />-->
|
||||
<!-- <result property="name" column="name" />-->
|
||||
<!-- <result property="code" column="code" />-->
|
||||
<!-- <result property="isActivate" column="isActivate" />-->
|
||||
<!-- <result property="status" column="status" />-->
|
||||
<!-- <result property="description" column="description" />-->
|
||||
<!-- <result property="writeCode" column="write_code" />-->
|
||||
<!-- <result property="remark" column="remark" />-->
|
||||
<!-- <result property="createBy" column="create_by" />-->
|
||||
<!-- <result property="createTime" column="create_time" />-->
|
||||
<!-- <result property="updateBy" column="update_by" />-->
|
||||
<!-- <result property="updateTime" column="update_time" />-->
|
||||
|
||||
<!-- </resultMap>-->
|
||||
|
||||
<!-- <sql id="selectRuleEngineVo">-->
|
||||
<!-- select-->
|
||||
<!-- id, rule_engine_id, version_code, name,code, isActivate, status, description, write_code, remark, create_by, create_time, update_by, update_time-->
|
||||
<!-- from rule_engine_version-->
|
||||
<!-- </sql>-->
|
||||
</mapper>
|
Loading…
Reference in New Issue