Merge pull request #1 from wfh45678/develop

Develop
This commit is contained in:
guor 2019-11-24 21:06:55 +08:00 committed by GitHub
commit df3e443b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 181 additions and 252 deletions

View File

@ -17,8 +17,8 @@ The project code called Radar, like the code, monitor the transaction at the bac
* 配置简单,开箱即用!
## 相关站点
Github: https://github.com/wfh45678/radar
Gitee: https://gitee.com/freshday/radar // 码云为镜像网站,贡献代码请提交到 github
Github: https://github.com/wfh45678/radar
官网: http://radar.pgmmer.top
Wiki: https://gitee.com/freshday/radar/wikis/home
@ -56,7 +56,7 @@ The project code called Radar, like the code, monitor the transaction at the bac
* Mysql 本项目中关系数据库,主要用于存放 风险模型的元信息。
* MongoDB 用于存放事件JSON 提供基本统计学计算例如max, min, sum, avg,
* MongoDB 用于存放事件JSON 提供基本统计学计算例如max, min, sum, avg,
复杂的统计学概念sd,variance, etc...)在内存中计算。
* Redis 提供缓存支持Engine 利用发布订阅特性监听管理端相关配置的更新
@ -104,7 +104,7 @@ https://gitee.com/freshday/radar/wikis/manual?sort_id=1637446
建议大家自行注册用户,避免使用同样的测试账号受干扰.
## 未完待续
[Release Note:](https://gitee.com/freshday/radar/wikis/release%20note?sort_id=1723765) https://gitee.com/freshday/radar/wikis/release%20note?sort_id=1723765
### 重大特性
* 支持机器学习
* 数据分析平台

144
pom.xml
View File

@ -19,13 +19,18 @@
</parent>
<groupId>com.pgmmers</groupId>
<artifactId>radar</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<name>radar</name>
<description>Demo project for Spring Boot</description>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mapper.version>4.0.0</mapper.version>
<mybatisGenerator.version>1.3.7</mybatisGenerator.version>
<mysql.version>5.1.47</mysql.version>
<springboot.version>2.1.7.RELEASE</springboot.version>
<tomcat.version>8.5.37</tomcat.version>
</properties>
@ -35,7 +40,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -43,52 +48,42 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
<version>${mybatisGenerator.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.0.0</version>
<version>${mapper.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper-spring-boot-starter -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
@ -128,31 +123,29 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.hdrhistogram</groupId>
<artifactId>HdrHistogram</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.1.10.RELEASE</version>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
</dependency>
<dependency>
@ -164,13 +157,13 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.1.7.RELEASE</version>
<version>${springboot.version}</version>
</dependency>
<dependency>
@ -202,11 +195,98 @@
<version>28.0-jre</version>
</dependency>
<!-- admin 模块独立引用-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- commons 模块独立引用-->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- dal 模块独立引用
(升级项目时请注意此处版本冲突,
mapper-spring-boot-starter、
mybatis-spring-boot-starter 引入的pagehelper-spring-boot-starter 均引入此包)-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>${mybatisGenerator.version}</version>
<configuration>
<configurationFile>
${basedir}/src/main/resources/generator/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>${mapper.version}</version>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-commons</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>radar-admin</artifactId>
@ -21,10 +21,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
@ -33,43 +29,21 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper-spring-boot-starter -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- ThymeLeaf 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -79,60 +53,28 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-service-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
@ -142,14 +84,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.7.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -47,8 +47,6 @@ public class RuleApiController {
@PutMapping
public CommonResult save(@RequestBody RuleVO rule, HttpServletRequest request) {
// HttpSession session = request.getSession();
// UserVO user = (UserVO) session.getAttribute("user");
return ruleService.save(rule, contextHolder.getContext().getUsername());
}

View File

@ -6,7 +6,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,10 +21,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
@ -33,32 +29,27 @@
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
@ -67,12 +58,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -3,7 +3,6 @@ package com.pgmmers.radar.util;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import java.util.HashMap;
import java.util.Map;
@ -58,4 +57,11 @@ public class GroovyScriptUtil {
return null;
}
}
/**
* 删除不在使用的脚本关联的groovy object, 不然内存有溢出风险
*/
public static void removeInactiveScript(String script){
passedClassMap.remove(script.hashCode() + "");
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -18,23 +18,10 @@
<artifactId>radar-dao</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@ -44,18 +31,11 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>radar-dao</artifactId>
@ -28,16 +28,9 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
@ -46,42 +39,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<configurationFile>
${basedir}/src/main/resources/generator/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-commons</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -27,11 +27,6 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@ -42,12 +37,6 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-service-impl</artifactId>
@ -64,44 +53,21 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
@ -111,14 +77,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.7.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -21,7 +21,7 @@ public class SwaggerConfig {
.apiInfo(buildApiInf())
.select()
.apis(RequestHandlerSelectors.basePackage("com.pgmmers.radar.controller"))
.paths(PathSelectors.any())
.paths(PathSelectors.regex("/services/.*"))
.build();
}

View File

@ -0,0 +1,22 @@
package com.pgmmers.radar.controller;
import com.pgmmers.radar.service.common.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* engine 启动首页.
* @author wangfeihu
*/
@RestController
public class IndexController {
@GetMapping(value = {"/", ""})
public CommonResult index(HttpServletRequest request) {
CommonResult result = new CommonResult(Boolean.TRUE, "100", "Engine is running");
result.getData().put("swagger url:", request.getRequestURL() + "swagger-ui.html");
return result;
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -13,29 +13,14 @@
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
@ -57,10 +42,6 @@
<artifactId>ip2region</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>

View File

@ -9,6 +9,7 @@ import com.pgmmers.radar.service.cache.CacheService;
import com.pgmmers.radar.service.cache.SubscribeHandle;
import com.pgmmers.radar.service.common.CommonResult;
import com.pgmmers.radar.service.model.AbstractionService;
import com.pgmmers.radar.util.GroovyScriptUtil;
import com.pgmmers.radar.vo.model.AbstractionVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -79,10 +80,17 @@ public class AbstractionServiceImpl implements AbstractionService, SubscribeHand
@Override
public CommonResult save(AbstractionVO abstraction) {
CommonResult result = new CommonResult();
if (abstraction.getId() != null) {
AbstractionVO oldAbs = abstractionDal.get(abstraction.getId());
// 如果规则有更新以前的编译好的groovy 对象用不到了应该删除
if (!oldAbs.getRuleScript().equals(abstraction.getRuleScript())) {
GroovyScriptUtil.removeInactiveScript(oldAbs.getRuleScript());
}
}
int count = abstractionDal.save(abstraction);
if (count > 0) {
if(StringUtils.isEmpty(abstraction.getName())){
abstraction.setName("abstraction_"+abstraction.getId());
abstraction.setName("abstraction_" + abstraction.getId());
abstractionDal.save(abstraction);
}

View File

@ -14,6 +14,7 @@ import com.pgmmers.radar.service.cache.SubscribeHandle;
import com.pgmmers.radar.service.common.CommonResult;
import com.pgmmers.radar.service.model.RuleService;
import com.pgmmers.radar.service.search.SearchEngineService;
import com.pgmmers.radar.util.GroovyScriptUtil;
import com.pgmmers.radar.vo.model.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -89,6 +90,13 @@ public class RuleServiceImpl implements RuleService, SubscribeHandle {
@Override
public CommonResult save(RuleVO rule,String merchantCode) {
CommonResult result = new CommonResult();
if (rule.getId() != null) {
RuleVO oldRule = ruleDal.get(rule.getId());
// 如果规则有更新以前的编译好的groovy 对象用不到了应该删除
if (!oldRule.getScripts().equals(rule.getScripts())) {
GroovyScriptUtil.removeInactiveScript(oldRule.getScripts());
}
}
int count = ruleDal.save(rule);
if (count > 0) {
if(StringUtils.isEmpty(rule.getName())){

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -19,10 +19,6 @@
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.pgmmers</groupId>
<artifactId>radar-dal</artifactId>

View File

@ -58,6 +58,17 @@ public class CommonResult implements Serializable{
this.data = data;
}
public CommonResult () {
}
public CommonResult(boolean success, String code, String msg) {
this.success = success;
this.code = code;
this.msg = msg;
}
@Override
public String toString() {
return "CommonResult [success=" + success + ", msg=" + msg + ", code=" + code + "]";