|
@@ -192,6 +192,15 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void packCzrkJzdzAddr(List<CzrkJzdz> czrkJzdzList) {
|
|
|
|
+ if (isEmpty(czrkJzdzList)) return;
|
|
|
|
+ for (CzrkJzdz czrkJzdz : czrkJzdzList) {
|
|
|
|
+ // 户籍地
|
|
|
|
+ String province = nullToEmpty(czrkJzdz.getProvince()), city = nullToEmpty(czrkJzdz.getCity()), region = nullToEmpty(czrkJzdz.getRegion()), villageTowns = nullToEmpty(czrkJzdz.getTown()), village = nullToEmpty(czrkJzdz.getVillage()), nowIn = nullToEmpty(czrkJzdz.getNowIn());
|
|
|
|
+ czrkJzdz.setNowIn(province + city + region + villageTowns + village + nowIn);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void startPage() {
|
|
private void startPage() {
|
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
Integer pageNum = pageDomain.getPageNum();
|
|
Integer pageNum = pageDomain.getPageNum();
|
|
@@ -1001,15 +1010,19 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public AjaxResult getInfo(String appKey, String appSecret, String idCard) {
|
|
public AjaxResult getInfo(String appKey, String appSecret, String idCard) {
|
|
- // checkAuth(appKey, appSecret);
|
|
|
|
- String ip = IpUtils.getIpAddr(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
|
|
|
- JSONObject jsonObject = ipTimesService.getByIp(ip);
|
|
|
|
|
|
+ checkAuth(appKey, appSecret);
|
|
|
|
+ checkIdCard(idCard);
|
|
|
|
+
|
|
|
|
+// String ip = IpUtils.getIpAddr(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
|
|
|
+// log.info("调用ip:{}", ip);
|
|
|
|
+// JSONObject jsonObject = ipTimesService.getByIp(ip);
|
|
|
|
+ JSONObject jsonObject = ipTimesService.countByUsername(appKey, appSecret);
|
|
if (jsonObject == null || jsonObject.size() == 0) {
|
|
if (jsonObject == null || jsonObject.size() == 0) {
|
|
- String errorMsg = "当前ip非法访问, ip: " + ip;
|
|
|
|
- log.error(errorMsg + "appKey:{}, appSecret:{}, idCard:{}", appKey, appSecret, idCard);
|
|
|
|
- return AjaxResult.error(errorMsg);
|
|
|
|
|
|
+ log.error("appKey:{}, appSecret:{}, idCard:{}", appKey, appSecret, idCard);
|
|
|
|
+ return AjaxResult.error("appKey or appSecret is error");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ String ip = jsonObject.getString("ip");
|
|
String today = DateUtils.getDate();
|
|
String today = DateUtils.getDate();
|
|
String redisKey = IP_TIMES + jsonObject.getString("ip") + ":" + today;
|
|
String redisKey = IP_TIMES + jsonObject.getString("ip") + ":" + today;
|
|
Integer cacheTimes = redisService.getCacheObject(redisKey);
|
|
Integer cacheTimes = redisService.getCacheObject(redisKey);
|
|
@@ -1028,6 +1041,14 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
long time = DateUtils.getTodayEnd().getTime(),time1 = DateUtils.getNowDate().getTime();
|
|
long time = DateUtils.getTodayEnd().getTime(),time1 = DateUtils.getNowDate().getTime();
|
|
redisService.setCacheObject(redisKey, cacheTimes, ((time - time1) / 1000), TimeUnit.SECONDS);
|
|
redisService.setCacheObject(redisKey, cacheTimes, ((time - time1) / 1000), TimeUnit.SECONDS);
|
|
|
|
+ packAddr(Collections.singletonList(czrk));
|
|
|
|
+
|
|
|
|
+ CzrkJzdz czrkJzdz = new CzrkJzdz();
|
|
|
|
+ czrkJzdz.setCzrkId(czrk.getId());
|
|
|
|
+ List<CzrkJzdz> czrkJzdzList = czrkJzdzService.selectCzrkJzdzList(czrkJzdz);
|
|
|
|
+ packCzrkJzdzAddr(czrkJzdzList);
|
|
|
|
+ czrk.setCzrkJzdzList(czrkJzdzList);
|
|
|
|
+ log.info("appKey:{}, appSecret:{}, idCard:{}, 查询到信息,czrk:{}", appKey, appSecret, idCard, JSON.toJSONString(czrk));
|
|
return AjaxResult.success(czrk);
|
|
return AjaxResult.success(czrk);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1038,4 +1059,15 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
private void setIntoRedis(String key, Object result) {
|
|
private void setIntoRedis(String key, Object result) {
|
|
redisService.setCacheObject(key, result, 1L, TimeUnit.HOURS);
|
|
redisService.setCacheObject(key, result, 1L, TimeUnit.HOURS);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void checkAuth(String appKey, String appSecret) {
|
|
|
|
+ if (isEmpty(appKey) || isEmpty(appSecret) ) {
|
|
|
|
+ throw new RuntimeException("appKey or appSecret must not be empty");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void checkIdCard(String idCard) {
|
|
|
|
+ if (isEmpty(idCard) ) {
|
|
|
|
+ throw new RuntimeException("idCard must not be empty");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|