Skip to content

Commit

Permalink
Merge pull request #66 from wfh45678/develop
Browse files Browse the repository at this point in the history
1.经纬度转换成行政区域
2.HTTP插件支持多参数
3.前端支持系统黑白黑白名单
4.规则命中图标支持时间过滤
  • Loading branch information
wfh45678 authored Nov 22, 2020
2 parents 53524d1 + 7164060 commit 3dd8ec2
Show file tree
Hide file tree
Showing 53 changed files with 762 additions and 282 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The project code called Radar, like the code, monitor the transaction at the bac
特征工程,例如用户小时交易次数,IP 一天交易金额,设备一小时交易次数。。。
### Adaptation: 机器学习模型适配器
使用训练好的机器学习模型,进行检测
### Activation: 激活点
### Activation: 激活器
概念类似于机器学习里面的 (Activation Function), 一个模型可以定义多个 activation(相当于不同维度的检测报告),每个activation都可以独立配置规则,单独打分。
例如,用户注册行为, 可以定义:异常注册, 垃圾注册, 可以输出多个activation。
### Rule: 规则
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</parent>
<groupId>com.pgmmers</groupId>
<artifactId>radar</artifactId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
<name>radar</name>
<description>Demo project for Spring Boot</description>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion radar-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>radar-admin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.pgmmers.radar.service.engine.PluginServiceV2;
import com.pgmmers.radar.service.engine.vo.DataColumnInfo;
import com.pgmmers.radar.service.enums.DataType;
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
import com.pgmmers.radar.service.model.AbstractionService;
import com.pgmmers.radar.service.model.FieldService;
import com.pgmmers.radar.service.model.PreItemService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.pgmmers.radar.service.engine.PluginServiceV2;
import com.pgmmers.radar.service.engine.vo.DataColumnInfo;
import com.pgmmers.radar.service.enums.DataType;
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
import com.pgmmers.radar.service.model.AbstractionService;
import com.pgmmers.radar.service.model.ActivationService;
import com.pgmmers.radar.service.model.FieldService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.pgmmers.radar.enums.FieldType;
import com.pgmmers.radar.service.cache.CacheService;
import com.pgmmers.radar.service.common.CommonResult;
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
import com.pgmmers.radar.util.CaptchaUtil;
import com.pgmmers.radar.util.ZipUtils;
import com.pgmmers.radar.vo.common.PluginVO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.pgmmers.radar.service.engine.PluginServiceV2;
import com.pgmmers.radar.service.engine.vo.DataColumnInfo;
import com.pgmmers.radar.service.enums.DataType;
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
import com.pgmmers.radar.service.logs.EventService;
import com.pgmmers.radar.service.model.ActivationService;
import com.pgmmers.radar.service.model.FieldService;
Expand Down Expand Up @@ -78,7 +78,7 @@ public CommonResult query(@RequestBody EventQuery query) throws IOException {
@PostMapping("/search")
public CommonResult search(@RequestBody TermQuery term, HttpSession session) {
CommonResult result = new CommonResult();
PageResult<Object> page = new PageResult<>(1, 10, 0, new ArrayList<>());
PageResult<Object> page ;
page = eventService.query(term);
if (page != null) {
result.getData().put("page", page);
Expand Down Expand Up @@ -242,9 +242,10 @@ public void downloadExcel(HttpServletRequest request, HttpServletResponse respon
String file = "e:\\tmp\\" + System.currentTimeMillis() + ".xlsx";
FileOutputStream fos = null;


response.setContentType("application/ms-excel");// 设置相应类型,告诉浏览器输出的内容为图片
response.setHeader("Pragma", "No-cache");// 设置响应头信息,告诉浏览器不要缓存此内容
// 设置相应类型,告诉浏览器输出的内容为图片
response.setContentType("application/ms-excel");
// 设置响应头信息,告诉浏览器不要缓存此内容
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expire", 0);
OutputStream os = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.pgmmers.radar.controller;

import com.pgmmers.radar.dal.bean.EventQuery;
import com.pgmmers.radar.dal.bean.RuleHistoryQuery;
import com.pgmmers.radar.dal.bean.RuleQuery;
import com.pgmmers.radar.intercpt.ContextHolder;
import com.pgmmers.radar.service.common.CommonResult;
import com.pgmmers.radar.service.model.ModelService;
import com.pgmmers.radar.service.model.RuleService;
import com.pgmmers.radar.vo.admin.UserVO;
import com.pgmmers.radar.vo.model.ModelVO;
import com.pgmmers.radar.vo.model.RuleVO;
import io.swagger.annotations.Api;
Expand Down Expand Up @@ -55,14 +55,14 @@ public CommonResult delete(@RequestBody Long[] id) {
return ruleService.delete(id);
}

@GetMapping("/hitsSort/{modelId}")
public CommonResult hitsSort(@PathVariable Long modelId) {
@PostMapping("/hitsSort/{modelId}")
public CommonResult hitsSort(@PathVariable Long modelId, @RequestBody EventQuery query) {
CommonResult result = new CommonResult();
ModelVO modelVO = modelService.getModelById(modelId);
if (modelVO == null) {
return result;
}
return ruleService.getHitSorts(modelId);
return ruleService.getHitSorts(modelId, query.getBeginTime(), query.getEndTime());
}

@PostMapping("/ruleHistory")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public CommonResult regist(String loginName, String passwd, String verifyPasswd,
userVO.setUserName(loginName);
userVO.setPasswd(encrypt);
userVO.setStatus("1");
userVO.setVipLevel(0);
userVO.setVipLevel(1);
userVO.setGiteeAccount(giteeAccount);
userVO.setCode(loginName);
userVO.setCreateTime(new Date());
Expand Down
3 changes: 1 addition & 2 deletions radar-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ logging:
root: info
com.pgmmers.radar: info
com.pgmmers.radar.mapper: debug
org.elasticsearch: info

org.elasticsearch.client: debug
server:
port: 6580
8 changes: 8 additions & 0 deletions radar-admin/src/main/resources/static/index.7269f78c-1.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions radar-admin/src/main/resources/static/index.7269f78c-2.css

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions radar-admin/src/main/resources/static/index.7269f78c-3.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion radar-admin/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>风控引擎管理平台</title> <link rel="shortcut icon" href="/images/anquan.png"> <!--[if lt IE 10]>
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.5.7/es5-shim.min.js,es5-shim/4.5.7/es5-sham.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js"></script>
<![endif]--> <link href="./index.16542f8e-1.css" rel="stylesheet"><link href="./index.16542f8e-2.css" rel="stylesheet"><link href="./index.16542f8e-3.css" rel="stylesheet"></head> <body> <div id="react-content"></div> <script type="text/javascript" src="./main.16542f8e.js"></script></body> </html>
<![endif]--> <link href="./index.7269f78c-1.css" rel="stylesheet"><link href="./index.7269f78c-2.css" rel="stylesheet"><link href="./index.7269f78c-3.css" rel="stylesheet"></head> <body> <div id="react-content"></div> <script type="text/javascript" src="./main.7269f78c.js"></script></body> </html>
317 changes: 317 additions & 0 deletions radar-admin/src/main/resources/static/main.7269f78c.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.pgmmers.radar.test;
import com.pgmmers.radar.util.CryptUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class CryptUtilTest {


@Test
public void testSHA() {
String str = CryptUtils.sha("123456", "admin").toUpperCase();
System.out.println(str);
}

}
2 changes: 1 addition & 1 deletion radar-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
77 changes: 0 additions & 77 deletions radar-commons/src/main/java/com/pgmmers/radar/util/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,78 +40,6 @@ public static Date parseDateTime(String str) throws ParseException {
return dateTimeFormat.parse(str);
}

/**
* <p>getStartCurrentDate.</p>
*
* @return a {@link Date} object.
*/
public static Date getStartCurrentDate() {
// Calendar cal = Calendar.getInstance();
// cal.set(Calendar.HOUR_OF_DAY, 0);
// cal.set(Calendar.MINUTE, 0);
// cal.set(Calendar.SECOND, 0);
// try {
// return dateTimeFormat.parse(dateTimeFormat.format(cal.getTime()));
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return null;
return getCurrentDate();
}

/**
* <p>getEndCurrentDate.</p>
*
* @return a {@link Date} object.
*/
public static Date getEndCurrentDate() {
// Calendar cal = Calendar.getInstance();
// cal.set(Calendar.HOUR_OF_DAY, 23);
// cal.set(Calendar.MINUTE, 59);
// cal.set(Calendar.SECOND, 59);
//
// try {
// return dateTimeFormat.parse(dateTimeFormat.format(cal.getTime()));
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return null;
return addDate(1,getCurrentDate());
}

/**
* <p>getDateTime.</p>
*
* @return a long.
*/
public static long getDateTime() {
return new Date().getTime();
}

/**
* <p>getCurrentDate.</p>
*
* @return a {@link Date} object.
*/
public static Date getCurrentDate() {
return new Date();
}

/**
* <p>getCurrentGMTDate.</p>
*
* @return a {@link Date} object.
*/
public static Date getCurrentGMTDate() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
try {
return dateTimeFormat.parse(dateFormat.format(new Date()));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}

/**
* <p>formatDate.</p>
Expand Down Expand Up @@ -148,8 +76,6 @@ public static long dateSubtract(Date startDate,Date endDate) {
startCal.setTime(startDate);
Calendar endCal = Calendar.getInstance();
endCal.setTime(endDate);
System.out.println(startCal.getTimeInMillis());
System.out.println(endCal.getTimeInMillis());
return (startCal.getTimeInMillis() - endCal.getTimeInMillis()) / (1000);
}

Expand Down Expand Up @@ -200,9 +126,6 @@ public static Calendar addDate(Date d, int field, int value) {
* @param args an array of {@link String} objects.
*/
public static void main(String[] args) {
System.out.println(getStartCurrentDate());
System.out.println(getEndCurrentDate());

System.out.println(formatDate(new Date(), "yyyy-MM-ww-dd"));

}
Expand Down
2 changes: 1 addition & 1 deletion radar-dal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public interface DataListDal {

List<DataListsVO> listDataLists(Long modelId, Integer status);

//
/**
* get by id.
* @param id
* @return
*/
DataListsVO get(Long id);

List<DataListsVO> list(Long modelId);
Expand All @@ -31,14 +35,22 @@ public interface DataListDal {

int delete(Long[] id);

//
/**
* get list meta.
* @param id
* @return
*/
DataListMetaVO getMeta(Long id);

int saveMeta(DataListMetaVO dataListMeta);

int deleteMeta(List<Long> listId);

//
/**
* get list record.
* @param id
* @return
*/
DataListRecordVO getRecord(Long id);

PageResult<DataListRecordVO> queryRecord(DataListRecordQuery query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public DataListsVO get(Long id) {
public List<DataListsVO> list(Long modelId) {
Example example = new Example(DataListsPO.class);
Example.Criteria criteria = example.createCriteria();
criteria.andIn("modelId", Arrays.asList(modelId, 0L));
criteria.andIn("modelId", Arrays.asList(modelId, 1L));
List<DataListsPO> list = dataListMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion radar-dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>radar-dao</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion radar-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion radar-engine/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sys:
conf:
app: engine # admin 或者 engine, 根据启动的项目名称进行选择
entity-duplicate-insert: false # 事件是否允许重复插入
mongo-restore-days: 93 # 事件保存时间,默认3个月
mongo-restore-days: 3650 # 事件保存时间,默认3个月
workdir: d:/radar # 工作目录
machine-learning: true # 是否启用 机器学习
server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.pgmmers.radar.EngineApplication;
import com.pgmmers.radar.service.engine.PluginServiceV2;
import com.pgmmers.radar.service.engine.vo.Location;
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
import com.pgmmers.radar.vo.model.PreItemVO;
import java.util.Comparator;
import java.util.HashMap;
Expand Down
2 changes: 1 addition & 1 deletion radar-kafka-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion radar-service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>radar</artifactId>
<groupId>com.pgmmers</groupId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit 3dd8ec2

Please sign in to comment.