mirror of
https://gitee.com/freshday/radar.git
synced 2025-12-26 07:16:26 +08:00
commit
82c9bd9c1d
@ -4,10 +4,11 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.pgmmers.radar.dal.bean.AbstractionQuery;
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
import com.pgmmers.radar.service.common.CommonResult;
|
||||
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.model.AbstractionService;
|
||||
import com.pgmmers.radar.service.model.FieldService;
|
||||
import com.pgmmers.radar.service.model.PreItemService;
|
||||
@ -15,13 +16,18 @@ import com.pgmmers.radar.vo.model.AbstractionVO;
|
||||
import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/services/v1/abstraction")
|
||||
@Api(value = "AbstractionApi", description = "特征管理相关操作", tags = {"特征API"})
|
||||
@ -74,7 +80,7 @@ public class AbstractionApiController {
|
||||
List<PreItemVO> listPreItem = preItemService.listPreItem(modelId);
|
||||
if(listPreItem != null && listPreItem.size()!= 0){
|
||||
for (PreItemVO preItem : listPreItem) {
|
||||
PluginType pt = PluginType.get(preItem.getPlugin());
|
||||
PluginServiceV2 pt= PluginManager.pluginServiceMap().get(preItem.getPlugin());
|
||||
if (StringUtils.isNotEmpty(pt.getType()) && pt.getType().equals("JSON")) {
|
||||
//load http request data
|
||||
JsonNode json = preItem.getConfigJson();
|
||||
|
||||
@ -2,23 +2,38 @@ package com.pgmmers.radar.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.pgmmers.radar.dal.bean.ActivationQuery;
|
||||
import com.pgmmers.radar.enums.FieldType;
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
import com.pgmmers.radar.service.common.CommonResult;
|
||||
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.model.*;
|
||||
import com.pgmmers.radar.vo.model.*;
|
||||
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;
|
||||
import com.pgmmers.radar.service.model.PreItemService;
|
||||
import com.pgmmers.radar.service.model.RuleService;
|
||||
import com.pgmmers.radar.vo.model.AbstractionVO;
|
||||
import com.pgmmers.radar.vo.model.ActivationVO;
|
||||
import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import com.pgmmers.radar.vo.model.RuleVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/services/v1/activation")
|
||||
@Api(value = "ActivationApi", description = "策略集管理相关操作", tags = {"策略集API"})
|
||||
@ -67,7 +82,7 @@ public class ActivationApiController {
|
||||
ds = new DataColumnInfo(DataType.PREITEMS.getDesc(), DataType.PREITEMS.getName());
|
||||
List<PreItemVO> listPreItem = preItemService.listPreItem(modelId);
|
||||
for (PreItemVO preItem : listPreItem) {
|
||||
PluginType pt = PluginType.get(preItem.getPlugin());
|
||||
PluginServiceV2 pt= PluginManager.pluginServiceMap().get(preItem.getPlugin());
|
||||
if (StringUtils.isNotEmpty(pt.getType()) && pt.getType().equals("JSON")) {
|
||||
//load http request data
|
||||
JsonNode json = preItem.getConfigJson();
|
||||
@ -129,7 +144,7 @@ public class ActivationApiController {
|
||||
list.add(ds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CommonResult result = new CommonResult();
|
||||
result.setSuccess(true);
|
||||
result.getData().put("list", list);
|
||||
|
||||
@ -3,14 +3,15 @@ package com.pgmmers.radar.controller;
|
||||
|
||||
import com.alibaba.excel.util.IoUtils;
|
||||
import com.pgmmers.radar.enums.FieldType;
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
import com.pgmmers.radar.service.common.CommonResult;
|
||||
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
|
||||
import com.pgmmers.radar.util.RandomValidateCode;
|
||||
import com.pgmmers.radar.util.ZipUtils;
|
||||
import com.pgmmers.radar.vo.common.PluginVO;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -37,14 +38,15 @@ public class CommonApiController {
|
||||
|
||||
@Value("${sys.conf.workdir}")
|
||||
public String workDir;
|
||||
|
||||
|
||||
@GetMapping("/plugins")
|
||||
public CommonResult plugins() {
|
||||
CommonResult result = new CommonResult();
|
||||
List<PluginVO> plugins = new ArrayList<PluginVO>();
|
||||
for (PluginType pt : PluginType.values()) {
|
||||
plugins.add(new PluginVO(pt));
|
||||
}
|
||||
List<PluginVO> plugins=PluginManager.pluginServiceMap()
|
||||
.values()
|
||||
.stream()
|
||||
.map(t-> new PluginVO(t.key(),t.pluginName(),t.desc()))
|
||||
.collect(Collectors.toList());
|
||||
result.setSuccess(true);
|
||||
result.getData().put("plugins", plugins);
|
||||
return result;
|
||||
|
||||
@ -2,15 +2,15 @@ package com.pgmmers.radar.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.pgmmers.radar.dal.bean.EventExportQuery;
|
||||
import com.pgmmers.radar.dal.bean.EventQuery;
|
||||
import com.pgmmers.radar.dal.bean.PageResult;
|
||||
import com.pgmmers.radar.dal.bean.TermQuery;
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
import com.pgmmers.radar.service.common.CommonResult;
|
||||
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.logs.EventService;
|
||||
import com.pgmmers.radar.service.model.ActivationService;
|
||||
import com.pgmmers.radar.service.model.FieldService;
|
||||
@ -22,13 +22,6 @@ import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import com.pgmmers.radar.vo.model.RuleVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@ -36,6 +29,17 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 以后会独立拆分到分析子项目里面去。
|
||||
@ -105,7 +109,7 @@ public class EventApiController {
|
||||
return;
|
||||
}
|
||||
EventExportQuery query = (EventExportQuery) request.getSession().getAttribute("exportQuery");
|
||||
|
||||
|
||||
if (query == null) {
|
||||
return;
|
||||
}
|
||||
@ -179,8 +183,7 @@ public class EventApiController {
|
||||
if (!itemsIdMap.containsKey(item.getDestField())) {
|
||||
continue;
|
||||
}
|
||||
PluginType plugin = Enum
|
||||
.valueOf(PluginType.class, item.getPlugin());
|
||||
PluginServiceV2 plugin= PluginManager.pluginServiceMap().get(item.getPlugin());
|
||||
String type = plugin.getType();
|
||||
String meta = plugin.getMeta();
|
||||
|
||||
|
||||
@ -1,101 +0,0 @@
|
||||
package com.pgmmers.radar.enums;
|
||||
|
||||
/**
|
||||
*
|
||||
* 插件类型.
|
||||
*
|
||||
* @author feihu.wang
|
||||
* @version Revision 1.0.0
|
||||
* @since:2016年8月19日
|
||||
*
|
||||
*/
|
||||
public enum PluginType {
|
||||
|
||||
IP2LOCATION(
|
||||
1,
|
||||
"ip2location",
|
||||
"IP转换成地址",
|
||||
null,
|
||||
"[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]"), //
|
||||
GPS2LOCATION(
|
||||
2,
|
||||
"gps2location",
|
||||
"GPS转换成地址",
|
||||
null,
|
||||
"[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]"), //
|
||||
ALLINONE(3, "allInOne", "字段合并", "STRING", null), //
|
||||
SUBSTRING(4, "subString", "字符串截短", "STRING", null), //
|
||||
MOBILE2LOCATION(
|
||||
5,
|
||||
"mobile2location",
|
||||
"手机号码归属地",
|
||||
null,
|
||||
"[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]"), //
|
||||
SENSITIVE_TIME(6, "getSensitiveTime", "敏感时间段(小时)", "STRING", null),
|
||||
DATEFORMAT(7, "formatDate", "日期时间格式化", "STRING", null),
|
||||
HTTP_UTIL(8, "httpRequest", "HttpUtil", "JSON", null),
|
||||
;
|
||||
|
||||
private Integer key;
|
||||
private String method;
|
||||
private String desc;
|
||||
private String type;
|
||||
private String meta;
|
||||
|
||||
PluginType(Integer key, String method, String desc, String type, String meta) {
|
||||
this.key = key;
|
||||
this.method = method;
|
||||
this.desc = desc;
|
||||
this.type = type;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public Integer getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(Integer key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public static PluginType get(String plugin) {
|
||||
for (PluginType pluginType : PluginType.values()) {
|
||||
if (pluginType.name().equals(plugin))
|
||||
return pluginType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
package com.pgmmers.radar.vo.common;
|
||||
|
||||
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
|
||||
public class PluginVO {
|
||||
|
||||
private Integer key;
|
||||
@ -12,14 +10,10 @@ public class PluginVO {
|
||||
// private JSONArray meta;
|
||||
|
||||
|
||||
|
||||
public PluginVO(PluginType plugin) {
|
||||
this.key = plugin.getKey();
|
||||
this.method = plugin.name();
|
||||
this.desc = plugin.getDesc();
|
||||
// if (!StringUtils.isEmpty(plugin.getMeta())) {
|
||||
// this.meta = JSONArray.parseArray(plugin.getMeta());
|
||||
// }
|
||||
public PluginVO(Integer key, String method, String desc) {
|
||||
this.key = key;
|
||||
this.method = method;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getKey() {
|
||||
|
||||
146
radar-engine/src/main/test/com/pgmmers/radar/dal/PluginTest.java
Normal file
146
radar-engine/src/main/test/com/pgmmers/radar/dal/PluginTest.java
Normal file
@ -0,0 +1,146 @@
|
||||
package com.pgmmers.radar.dal;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.vo.model.PreItemVO;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = EngineApplication.class)
|
||||
public class PluginTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PluginTest.class);
|
||||
|
||||
@Test
|
||||
public void pluginList() {
|
||||
PluginManager.pluginServiceMap().values()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(PluginServiceV2::key))
|
||||
.forEach(t -> logger.info(t.info()));
|
||||
}
|
||||
|
||||
private Map<String, Object> jsonInfo;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
jsonInfo = new HashMap<>();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ALLINONE() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setSourceField("firsName,lastName");
|
||||
jsonInfo.put("firsName", "aaa");
|
||||
jsonInfo.put("lastName", "ccc");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("ALLINONE");
|
||||
String result = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(result);
|
||||
logger.info("{}", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DATEFORMAT() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setArgs("yyyyMMdd HH:mm:ss");
|
||||
item.setSourceField("time");
|
||||
jsonInfo.put("time", System.currentTimeMillis());
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("DATEFORMAT");
|
||||
String result = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(result);
|
||||
logger.info("{}", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void GPS2LOCATION() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HTTP_UTIL() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setReqType(HttpMethod.GET.name());
|
||||
item.setArgs("http://t.weather.sojson.com/api/weather/city/101030100");
|
||||
item.setSourceField("json");
|
||||
jsonInfo.put("json","");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("HTTP_UTIL");
|
||||
JSONObject result = (JSONObject) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(result);
|
||||
logger.info("{}", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void IP2LOCATION() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setSourceField("ip");
|
||||
jsonInfo.put("ip", "1.1.1.1");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("IP2LOCATION");
|
||||
Location location = (Location) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
logger.info("{}", location);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MOBILE2LOCATION() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setSourceField("phone");
|
||||
jsonInfo.put("phone", "18657150000");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("MOBILE2LOCATION");
|
||||
Location location = (Location) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
logger.info("{}", location);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SENSITIVE_TIME() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setSourceField("time");
|
||||
jsonInfo.put("time",System.currentTimeMillis());
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("SENSITIVE_TIME");
|
||||
String location = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
logger.info("{}", location);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void SUBSTRING() {
|
||||
PreItemVO item = new PreItemVO();
|
||||
item.setArgs("0,7");
|
||||
item.setSourceField("phone");
|
||||
jsonInfo.put("phone", "18657150000");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("SUBSTRING");
|
||||
String location = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
logger.info("{}", location);
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
package com.pgmmers.radar.service.impl.engine;
|
||||
|
||||
|
||||
import com.pgmmers.radar.enums.CombineType;
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
import com.pgmmers.radar.enums.StatusType;
|
||||
import com.pgmmers.radar.service.common.CommonResult;
|
||||
import com.pgmmers.radar.service.engine.AntiFraudEngine;
|
||||
@ -12,6 +10,7 @@ import com.pgmmers.radar.service.engine.vo.AbstractionResult;
|
||||
import com.pgmmers.radar.service.engine.vo.ActivationResult;
|
||||
import com.pgmmers.radar.service.engine.vo.AdaptationResult;
|
||||
import com.pgmmers.radar.service.engine.vo.AntiFraudProcessResult;
|
||||
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
|
||||
import com.pgmmers.radar.service.model.ModelService;
|
||||
import com.pgmmers.radar.service.model.PreItemService;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
@ -21,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -41,7 +39,7 @@ public class AntiFraudServiceImpl implements AntiFraudService {
|
||||
|
||||
@Autowired
|
||||
private PreItemService preItemService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
|
||||
@ -109,48 +107,7 @@ public class AntiFraudServiceImpl implements AntiFraudService {
|
||||
continue;
|
||||
}
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginType plugin = Enum.valueOf(PluginType.class, item.getPlugin());
|
||||
Object transfer = "";
|
||||
switch (plugin) {
|
||||
case IP2LOCATION:
|
||||
transfer = pluginService.ip2location(jsonInfo.get(sourceField[0]).toString());
|
||||
break;
|
||||
case GPS2LOCATION:
|
||||
transfer = pluginService.gps2location(jsonInfo.get(sourceField[0]).toString(),
|
||||
jsonInfo.get(sourceField[1]).toString());
|
||||
break;
|
||||
case ALLINONE:
|
||||
List<Object> values = new ArrayList<>();
|
||||
for (String field : sourceField) {
|
||||
values.add(jsonInfo.get(field));
|
||||
}
|
||||
transfer = pluginService.allInOne(values, CombineType.CONCAT);
|
||||
break;
|
||||
case SUBSTRING:
|
||||
String[] args = item.getArgs().split(",");
|
||||
transfer = pluginService.subString(jsonInfo.get(sourceField[0]).toString(), Integer.parseInt(args[0]), Integer.parseInt(args[1]));
|
||||
break;
|
||||
case MOBILE2LOCATION:
|
||||
transfer = pluginService.mobile2location(jsonInfo.get(sourceField[0]).toString());
|
||||
break;
|
||||
case SENSITIVE_TIME:
|
||||
Long millis = Long.parseLong(jsonInfo.get(sourceField[0]).toString());
|
||||
transfer = pluginService.getSensitiveTime(millis);
|
||||
break;
|
||||
case DATEFORMAT:
|
||||
String formatStr = item.getArgs();
|
||||
millis = Long.parseLong(jsonInfo.get(sourceField[0]).toString());
|
||||
transfer = pluginService.formatDate(millis, formatStr);
|
||||
break;
|
||||
case HTTP_UTIL:
|
||||
String url = item.getArgs();
|
||||
String reqType = item.getReqType();
|
||||
String arg = jsonInfo.get(sourceField[0]).toString();
|
||||
transfer = pluginService.httpRequest(url, reqType, arg);
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
Object transfer = PluginManager.pluginServiceMap().get(item.getPlugin()).handle(item,jsonInfo,sourceField);
|
||||
result.put(item.getDestField(), transfer);
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:45 Description:
|
||||
*/
|
||||
public class ALLINONE implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "字段合并";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "STRING";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo,
|
||||
String[] sourceField) {
|
||||
List<Object> fields = new ArrayList<>();
|
||||
for (String field : sourceField) {
|
||||
fields.add(jsonInfo.get(field));
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
Object f = fields.get(i);
|
||||
builder.append(f == null ? "" : f.toString());
|
||||
if (i < fields.size() - 1) {
|
||||
builder.append("_");
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
|
||||
public class DATEFORMAT implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "日期时间格式化";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "STRING";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeta() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField) {
|
||||
String formatStr = item.getArgs();
|
||||
long millis = Long.parseLong(jsonInfo.get(sourceField[0]).toString());
|
||||
return DateFormatUtils.format(millis, formatStr);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:44 Description:
|
||||
*/
|
||||
public class GPS2LOCATION implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "GPS转换成地址";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeta() {
|
||||
return "[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo,
|
||||
String[] sourceField) {
|
||||
// TODO 可以参考 http://jwd.funnyapi.com/#/index , 最好是本地库。
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.impl.util.BeanUtils;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:47 Description:
|
||||
*/
|
||||
public class HTTP_UTIL implements PluginServiceV2 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HTTP_UTIL.class);
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "HttpUtil";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "JSON";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField) {
|
||||
String url = item.getArgs();
|
||||
String reqType = item.getReqType();
|
||||
String arg = jsonInfo.get(sourceField[0]).toString();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
RestTemplate restTemplate = (RestTemplate) BeanUtils.getBean("restTemplate");
|
||||
ResponseEntity<JSONObject> responseEntity = restTemplate
|
||||
.exchange(url, HttpMethod.valueOf(reqType), entity, JSONObject.class, arg);
|
||||
logger.info("http plugin:{}\n{}\n {}", url, arg, responseEntity.toString());
|
||||
if (responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||
return responseEntity.getBody();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.engine.vo.Location;
|
||||
import com.pgmmers.radar.service.impl.util.BeanUtils;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.lionsoul.ip2region.DataBlock;
|
||||
import org.lionsoul.ip2region.DbConfig;
|
||||
import org.lionsoul.ip2region.DbSearcher;
|
||||
import org.lionsoul.ip2region.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class IP2LOCATION implements PluginServiceV2 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IP2LOCATION.class);
|
||||
private DbSearcher ipSearcher;
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "IP转换成地址";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeta() {
|
||||
return "[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]";
|
||||
}
|
||||
|
||||
public IP2LOCATION() {
|
||||
try {
|
||||
String ipFilePath = BeanUtils.getApplicationContext().getEnvironment()
|
||||
.getProperty("ip2region.db.path");
|
||||
DbConfig conf = new DbConfig();
|
||||
ipSearcher = new DbSearcher(conf, ipFilePath);
|
||||
logger.info("IP2LOCATION Plugin load success");
|
||||
} catch (Exception e) {
|
||||
logger.error("ip2region init failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo,
|
||||
String[] sourceField) {
|
||||
Location location;
|
||||
String ip = jsonInfo.get(sourceField[0]).toString();
|
||||
if (!Util.isIpAddress(ip)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
DataBlock block = ipSearcher.memorySearch(ip);
|
||||
String[] detail = block.getRegion().split("\\|");
|
||||
location = new Location();
|
||||
location.setCountry(detail[0]);
|
||||
location.setRegion(detail[1]);
|
||||
location.setProvince(detail[2]);
|
||||
location.setCity(detail[3]);
|
||||
location.setAddress(detail[4]);
|
||||
} catch (Exception e) {
|
||||
location = new Location();
|
||||
logger.error("ip2region error", e);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.data.MobileInfoService;
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.engine.vo.Location;
|
||||
import com.pgmmers.radar.service.impl.util.BeanUtils;
|
||||
import com.pgmmers.radar.vo.data.MobileInfoVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:46 Description:
|
||||
*/
|
||||
public class MOBILE2LOCATION implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "手机号码归属地";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMeta() {
|
||||
return "[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField) {
|
||||
String mobile = jsonInfo.get(sourceField[0]).toString();
|
||||
if (!StringUtils.isEmpty(mobile) && mobile.length() == 11) {
|
||||
mobile = mobile.substring(0, 7);
|
||||
}
|
||||
MobileInfoVO vo = BeanUtils.getBean(MobileInfoService.class).getMobileInfoByMobile(mobile);
|
||||
Location location = new Location();
|
||||
if (vo != null) {
|
||||
location.setProvince(vo.getProvince());
|
||||
location.setCity(vo.getCity());
|
||||
location.setCountry("中国");
|
||||
}
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
|
||||
|
||||
public class PluginManager {
|
||||
|
||||
private PluginManager() {
|
||||
}
|
||||
|
||||
public static Map<String, PluginServiceV2> pluginServiceMap() {
|
||||
return SingletonHolder.pluginServiceMap;
|
||||
}
|
||||
private static class SingletonHolder {
|
||||
private static final Map<String, PluginServiceV2> pluginServiceMap = SpringFactoriesLoader
|
||||
.loadFactories(PluginServiceV2.class, null).stream()
|
||||
.sorted(Comparator.comparing(PluginServiceV2::key))
|
||||
.collect(Collectors.toMap(PluginServiceV2::pluginName, e -> e,
|
||||
(oldValue, newValue) -> newValue));
|
||||
;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:46 Description:
|
||||
*/
|
||||
public class SENSITIVE_TIME implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "敏感时间段(小时)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "STRING";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField) {
|
||||
long millis = Long.parseLong(jsonInfo.get(sourceField[0]).toString());
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTimeInMillis(millis);
|
||||
return c.get(Calendar.HOUR_OF_DAY) + "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package com.pgmmers.radar.service.impl.engine.Plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:45 Description:
|
||||
*/
|
||||
public class SUBSTRING implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "字符串截短";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "STRING";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField) {
|
||||
String[] args = item.getArgs().split(",");
|
||||
String field = jsonInfo.get(sourceField[0]).toString();
|
||||
int start =Integer.parseInt(args[0]);
|
||||
int end = Integer.parseInt(args[1]);
|
||||
if (field != null && field.length() > end) {
|
||||
return field.substring(start, end);
|
||||
} else {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,12 +8,13 @@ import com.pgmmers.radar.dal.bean.ModelQuery;
|
||||
import com.pgmmers.radar.dal.bean.PageResult;
|
||||
import com.pgmmers.radar.dal.model.ModelDal;
|
||||
import com.pgmmers.radar.enums.FieldType;
|
||||
import com.pgmmers.radar.enums.PluginType;
|
||||
import com.pgmmers.radar.enums.StatusType;
|
||||
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.data.MongoService;
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.impl.engine.Plugin.PluginManager;
|
||||
import com.pgmmers.radar.service.model.ModelService;
|
||||
import com.pgmmers.radar.service.search.SearchEngineService;
|
||||
import com.pgmmers.radar.util.JsonUtils;
|
||||
@ -251,7 +252,7 @@ public class ModelServiceImpl extends BaseLocalCacheService implements ModelServ
|
||||
JSONObject preItemJson = new JSONObject();
|
||||
for (PreItemVO item : items) {
|
||||
String pluginType = item.getPlugin();
|
||||
PluginType plugin = Enum.valueOf(PluginType.class, pluginType);
|
||||
PluginServiceV2 plugin= PluginManager.pluginServiceMap().get(pluginType);
|
||||
String columns = plugin.getMeta();
|
||||
if (columns == null) {
|
||||
String fieldType = plugin.getType();
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
com.pgmmers.radar.service.engine.PluginServiceV2=\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.DATEFORMAT,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.ALLINONE,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.GPS2LOCATION,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.HTTP_UTIL,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.IP2LOCATION,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.MOBILE2LOCATION,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.SENSITIVE_TIME,\
|
||||
com.pgmmers.radar.service.impl.engine.Plugin.SUBSTRING
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package com.pgmmers.radar.service.engine;
|
||||
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public interface PluginServiceV2 {
|
||||
|
||||
default String pluginName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
Integer key();
|
||||
|
||||
String desc();
|
||||
|
||||
String getType();
|
||||
|
||||
default String getMeta() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object handle(PreItemVO item, Map<String, Object> jsonInfo, String[] sourceField);
|
||||
|
||||
default String info() {
|
||||
return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]")
|
||||
.add("key='" + key() + "'")
|
||||
.add("desc='" + desc() + "'")
|
||||
.add("type='" + getType() + "'")
|
||||
.add("meta='" + getMeta() + "'")
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,17 @@
|
||||
package com.pgmmers.radar.service.engine.vo;
|
||||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class Location {
|
||||
|
||||
private String country = "中国";
|
||||
|
||||
|
||||
private String region = "";
|
||||
|
||||
|
||||
private String province = "";
|
||||
|
||||
|
||||
private String city = "";
|
||||
|
||||
|
||||
private String address = "";
|
||||
|
||||
public String getCountry() {
|
||||
@ -51,7 +53,16 @@ public class Location {
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(", ", Location.class.getSimpleName() + "[", "]")
|
||||
.add("country='" + country + "'")
|
||||
.add("region='" + region + "'")
|
||||
.add("province='" + province + "'")
|
||||
.add("city='" + city + "'")
|
||||
.add("address='" + address + "'")
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user