Commit 8cb02918 authored by 徐小光's avatar 徐小光

Merge branch 'hotfix/refact' into 'master'

删除一些代码



See merge request !4
parents 99044458 89fe023e
...@@ -21,10 +21,6 @@ public enum EducationEnum { ...@@ -21,10 +21,6 @@ public enum EducationEnum {
this.name = name; this.name = name;
} }
public void setName(String name) {
this.name = name;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -14,10 +14,6 @@ public enum Gender { ...@@ -14,10 +14,6 @@ public enum Gender {
this.name = name; this.name = name;
} }
public void setName(String name) {
this.name = name;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -22,10 +22,6 @@ public enum IdType { ...@@ -22,10 +22,6 @@ public enum IdType {
this.name = name; this.name = name;
} }
public void setName(String name) {
this.name = name;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -23,15 +23,10 @@ public enum MaritalStatus { ...@@ -23,15 +23,10 @@ public enum MaritalStatus {
return description; return description;
} }
public void setDescription(String description) {
this.description = description;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("MaritalStatus{"); String sb = "MaritalStatus{" + "description='" + description + '\'' +
sb.append("description='").append(description).append('\''); '}';
sb.append('}'); return sb;
return sb.toString();
} }
} }
...@@ -23,10 +23,6 @@ public enum OccupationEnum { ...@@ -23,10 +23,6 @@ public enum OccupationEnum {
this.name = name; this.name = name;
} }
public void setName(String name) {
this.name = name;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -25,15 +25,10 @@ public enum Relation { ...@@ -25,15 +25,10 @@ public enum Relation {
return description; return description;
} }
public void setDescription(String description) {
this.description = description;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("Relation{"); String sb = "Relation{" + "description='" + description + '\'' +
sb.append("description='").append(description).append('\''); '}';
sb.append('}'); return sb;
return sb.toString();
} }
} }
...@@ -28,13 +28,6 @@ public class Bootstrap { ...@@ -28,13 +28,6 @@ public class Bootstrap {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Bootstrap.class); SpringApplication springApplication = new SpringApplication(Bootstrap.class);
springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
MotanSwitcherUtil.setSwitcherValue(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER, true);
log.info("注册zookeeper成功");
}
});
springApplication.run(args); springApplication.run(args);
} }
......
package cn.quantgroup.xyqb.aspect.logcaller; package cn.quantgroup.xyqb.aspect.logcaller;
import cn.quantgroup.xyqb.util.ApplicationContextHolder;
import cn.quantgroup.xyqb.util.IPUtil; import cn.quantgroup.xyqb.util.IPUtil;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
...@@ -10,7 +9,6 @@ import org.slf4j.Logger; ...@@ -10,7 +9,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -29,7 +27,8 @@ public class LogCallHttpAspect { ...@@ -29,7 +27,8 @@ public class LogCallHttpAspect {
private static final Logger LOGGER = LoggerFactory.getLogger(LogCallHttpAspect.class); private static final Logger LOGGER = LoggerFactory.getLogger(LogCallHttpAspect.class);
@Pointcut("@annotation(cn.quantgroup.xyqb.aspect.logcaller.LogHttpCaller)") @Pointcut(value = "execution(public * cn.quantgroup.xyqb.controller..*.*(..)) " +
"&& !execution(* cn.quantgroup.xyqb.controller.ExceptionHandlingController.*(..))")
private void logHttpCaller() { private void logHttpCaller() {
} }
...@@ -41,9 +40,7 @@ public class LogCallHttpAspect { ...@@ -41,9 +40,7 @@ public class LogCallHttpAspect {
try { try {
HttpServletRequest request = attrs.getRequest(); HttpServletRequest request = attrs.getRequest();
String remoteIP = IPUtil.getRemoteIP(request); String remoteIP = IPUtil.getRemoteIP(request);
LogCallHttpAspect logCallHttpAspect = ApplicationContextHolder.getBean(LogCallHttpAspect.class); this.asyncRecordIt(pjp, result, remoteIP);
// 异步记录日志
logCallHttpAspect.asyncRecordIt(pjp, result, remoteIP);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("打印http请求日志出错", e); LOGGER.error("打印http请求日志出错", e);
} }
...@@ -58,12 +55,11 @@ public class LogCallHttpAspect { ...@@ -58,12 +55,11 @@ public class LogCallHttpAspect {
* @param result * @param result
* @param remoteIP * @param remoteIP
*/ */
@Async("logExecutor") private void asyncRecordIt(ProceedingJoinPoint pjp, Object result, String remoteIP) {
public void asyncRecordIt(ProceedingJoinPoint pjp, Object result, String remoteIP) {
Object[] args = pjp.getArgs(); Object[] args = pjp.getArgs();
String methodName = pjp.getSignature().getName(); String methodName = pjp.getSignature().getName();
String targetName = pjp.getTarget().getClass().getName(); String targetName = pjp.getTarget().getClass().getName();
LOGGER.info("http api is called,from IP:[{}],method :[{}],args:[{}],response:[{}]", remoteIP, targetName.concat(".").concat(methodName), args, result); LOGGER.info("http api is called,from IP:[{}],method :[{}],args:[{}]", remoteIP, targetName.concat(".").concat(methodName), args);
} }
} }
package cn.quantgroup.xyqb.config.motan;
import com.weibo.api.motan.config.springsupport.AnnotationBean;
import com.weibo.api.motan.config.springsupport.BasicServiceConfigBean;
import com.weibo.api.motan.config.springsupport.ProtocolConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Created by 11 on 2017/2/27.
*/
@Configuration
public class MotanConfig {
@Bean
public AnnotationBean motanAnnotationBean() {
AnnotationBean motanAnnotationBean = new AnnotationBean();
motanAnnotationBean.setPackage("cn.quantgroup.xyqb.controller.external.motan");
return motanAnnotationBean;
}
@Bean(name = "userMotan")
public ProtocolConfigBean protocolConfig1(
@Value("${protocol.isDefault}") Boolean isDefault, @Value("${protocol.name}") String name,
@Value("${protocol.contentLength}") int contentLength) {
ProtocolConfigBean config = new ProtocolConfigBean();
config.setDefault(isDefault);
config.setName(name);
config.setMaxContentLength(contentLength);
config.setMaxServerConnection(1000);
return config;
}
@Bean(name = "registryConfig")
public RegistryConfigBean registryConfig(@Value("${registry.protocol}") String registryProtocol,
@Value("${registry.address}") String registryAddress
) {
RegistryConfigBean config = new RegistryConfigBean();
config.setRegProtocol(registryProtocol);
config.setAddress(registryAddress);
return config;
}
@Bean
public BasicServiceConfigBean baseServiceConfig(@Value("${motan.port}") int motanPort,
@Value("${motan.user.group}") String userGroup,
@Value("${motan.user.module}") String userModule,
@Value("${motan.application:xyqbUserMotan}") String applicationName) {
BasicServiceConfigBean config = new BasicServiceConfigBean();
config.setExport("userMotan:" + motanPort);
config.setGroup(userGroup);
config.setVersion("1.0");
config.setAccessLog(true);
config.setShareChannel(true);
config.setModule(userModule);
config.setApplication(applicationName);
config.setRegistry("registryConfig");
return config;
}
}
...@@ -88,22 +88,4 @@ public class LoanVestMQConfig { ...@@ -88,22 +88,4 @@ public class LoanVestMQConfig {
template.setExchange(loanVestExchange); template.setExchange(loanVestExchange);
return template; return template;
} }
//@Bean(name = "loanVestMsgQueue")
//public Queue loanStateMsgQueue() {
// return new Queue(stateQueueName);
//}
//@Bean(name = "loanVestListenerContainer")
//public SimpleMessageListenerContainer loanVestSimpleMessageListenerContainer(@Qualifier("loanVestMQService") IVestService vestService, @Qualifier("vestFactory") ConnectionFactory vestFactory, @Qualifier("loanVestMsgQueue")Queue loanVestMsgQueue) {
// SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
// container.setConnectionFactory(vestFactory);
// container.setQueues(loanVestMsgQueue);
// container.setAcknowledgeMode(AcknowledgeMode.NONE);
// container.setMessageListener(new MessageListenerAdapter(vestService));
// container.start();
// return container;
//
//}
} }
package cn.quantgroup.xyqb.config.thread;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
* Created by xuran on 2017/11/8.
*/
@Configuration
@EnableAsync
public class AsyncConfig {
/**
* 生成线程池
*
* @param corePoolSize
* @param maxPoolSize
* @param queueCapacity
* @param waitForCompleteOnShutdown
* @param prefix
* @return
*/
private ThreadPoolTaskExecutor generateThreadPoolTaskExecutor(int corePoolSize, int maxPoolSize, int queueCapacity,
boolean waitForCompleteOnShutdown, int keepAliveSeconds,
boolean allowCoreThreadTimeOut, String prefix) {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setKeepAliveSeconds(keepAliveSeconds);
executor.setAllowCoreThreadTimeOut(allowCoreThreadTimeOut);
executor.setWaitForTasksToCompleteOnShutdown(waitForCompleteOnShutdown);
executor.setThreadNamePrefix(prefix);
executor.initialize();
return executor;
}
/**
* 日志线程池
*
* @return
*/
@Bean(name = "logExecutor")
public Executor loanMqExecutor() {
return generateThreadPoolTaskExecutor(100, 2000, 2000, true, 30, true, "loanMqExecutor-");
}
}
...@@ -37,7 +37,7 @@ public class NewCaptchaController { ...@@ -37,7 +37,7 @@ public class NewCaptchaController {
@Value("${geetest.close:false}") @Value("${geetest.close:false}")
private String geetestClose; private String geetestClose;
@LogHttpCaller
@RequestMapping(value = "/captcha/new") @RequestMapping(value = "/captcha/new")
public JsonResult getCaptcha(String phoneNo, String clientType, HttpServletRequest request) { public JsonResult getCaptcha(String phoneNo, String clientType, HttpServletRequest request) {
String remoteIp = IPUtil.getRemoteIP(request); String remoteIp = IPUtil.getRemoteIP(request);
......
...@@ -48,7 +48,6 @@ import static cn.quantgroup.xyqb.constant.UserConstant.USER_ERROR_OR_PASSWORD_ER ...@@ -48,7 +48,6 @@ import static cn.quantgroup.xyqb.constant.UserConstant.USER_ERROR_OR_PASSWORD_ER
* Created by 11 on 2017/2/27. * Created by 11 on 2017/2/27.
*/ */
@Slf4j @Slf4j
@MotanService(basicService = "baseServiceConfig")
public class MotanUserServiceImpl implements UserMotanService { public class MotanUserServiceImpl implements UserMotanService {
private static final ObjectMapper MAPPER = new ObjectMapper(); private static final ObjectMapper MAPPER = new ObjectMapper();
......
...@@ -471,7 +471,7 @@ public class UserQueryLogController { ...@@ -471,7 +471,7 @@ public class UserQueryLogController {
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
HSSFSheet sheet = wb.createSheet("用户信息列表"); HSSFSheet sheet = wb.createSheet("用户信息列表");
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
HSSFRow row = sheet.createRow((int) 0); HSSFRow row = sheet.createRow(0);
// 第四步,创建单元格,并设置值表头 设置表头居中 // 第四步,创建单元格,并设置值表头 设置表头居中
HSSFCellStyle style = wb.createCellStyle(); HSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
...@@ -499,7 +499,7 @@ public class UserQueryLogController { ...@@ -499,7 +499,7 @@ public class UserQueryLogController {
//List list = CreateSimpleExcelToDisk.getStudent(); //List list = CreateSimpleExcelToDisk.getStudent();
for (int i = 0; i < uqls.size(); i++) { for (int i = 0; i < uqls.size(); i++) {
row = sheet.createRow((int) i + 1); row = sheet.createRow(i + 1);
UserQueryInfo user = uqls.get(i); UserQueryInfo user = uqls.get(i);
// 第四步,创建单元格,并设置值 // 第四步,创建单元格,并设置值
if (user != null && row != null) { if (user != null && row != null) {
......
...@@ -61,7 +61,7 @@ public class AppController implements IBaseController { ...@@ -61,7 +61,7 @@ public class AppController implements IBaseController {
* @param request * @param request
* @return Token和phoneNo * @return Token和phoneNo
*/ */
@LogHttpCaller
@IpValidator @IpValidator
@RequestMapping("/login") @RequestMapping("/login")
public JsonResult login( public JsonResult login(
...@@ -119,7 +119,7 @@ public class AppController implements IBaseController { ...@@ -119,7 +119,7 @@ public class AppController implements IBaseController {
* @param request * @param request
* @return 用户信息 * @return 用户信息
*/ */
@LogHttpCaller
@IpValidator @IpValidator
@RequestMapping("/login_super") @RequestMapping("/login_super")
public JsonResult loginSuper( public JsonResult loginSuper(
...@@ -186,7 +186,7 @@ public class AppController implements IBaseController { ...@@ -186,7 +186,7 @@ public class AppController implements IBaseController {
* @param request * @param request
* @return Token和phoneNo * @return Token和phoneNo
*/ */
@LogHttpCaller
@IpValidator @IpValidator
@RequestMapping("/login2") @RequestMapping("/login2")
public JsonResult login2( public JsonResult login2(
......
...@@ -83,7 +83,7 @@ public class UserApiController { ...@@ -83,7 +83,7 @@ public class UserApiController {
* @return * @return
*/ */
@ApiOperation(notes = "检查token是否有效,如果有效,可选择是否延续生命期(延续后有效期24Hour)", value = "Check token and then prolong session", nickname = "checkToken") @ApiOperation(notes = "检查token是否有效,如果有效,可选择是否延续生命期(延续后有效期24Hour)", value = "Check token and then prolong session", nickname = "checkToken")
@LogHttpCaller
@IpValidator @IpValidator
@RequestMapping(value = "/valid/{token}", method = RequestMethod.POST) @RequestMapping(value = "/valid/{token}", method = RequestMethod.POST)
public JsonResult checkToken(@ApiParam(value = "sid,session的id", required = true) @PathVariable("token") String token, public JsonResult checkToken(@ApiParam(value = "sid,session的id", required = true) @PathVariable("token") String token,
......
...@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
public class AuthInfoController implements IBaseController { public class AuthInfoController implements IBaseController {
@LogHttpCaller
@RequestMapping("/info/login") @RequestMapping("/info/login")
public JsonResult loginInfo(HttpServletRequest request) { public JsonResult loginInfo(HttpServletRequest request) {
SessionStruct sessionStruct = getCurrentSessionFromRedis(); SessionStruct sessionStruct = getCurrentSessionFromRedis();
......
...@@ -213,7 +213,7 @@ public class SmsController implements IBaseController { ...@@ -213,7 +213,7 @@ public class SmsController implements IBaseController {
private JsonResult sendVerificationCode2Voice(String phoneNo, String usage) { private JsonResult sendVerificationCode2Voice(String phoneNo, String usage) {
String verificationCountKey = Constants.REDIS_VOICE_CODE_COUNT + phoneNo; String verificationCountKey = Constants.REDIS_VOICE_CODE_COUNT + phoneNo;
Long getVerificationCount = redisTemplate.opsForHash().increment(verificationCountKey, usage.toString(), 1); Long getVerificationCount = redisTemplate.opsForHash().increment(verificationCountKey, usage, 1);
redisTemplate.expire(verificationCountKey, DateUtils.getSeconds(), TimeUnit.SECONDS); redisTemplate.expire(verificationCountKey, DateUtils.getSeconds(), TimeUnit.SECONDS);
if (getVerificationCount > 5) { if (getVerificationCount > 5) {
return JsonResult.buildErrorStateResult("今天已获取5次语音验证码,请使用短信验证码或明天再试", null); return JsonResult.buildErrorStateResult("今天已获取5次语音验证码,请使用短信验证码或明天再试", null);
......
...@@ -24,7 +24,7 @@ public class UserAuthorizedController { ...@@ -24,7 +24,7 @@ public class UserAuthorizedController {
@Resource @Resource
private IUserAuthorizedService userAuthorizedService; private IUserAuthorizedService userAuthorizedService;
@LogHttpCaller
@RequestMapping(value = "/hasUserAuthorized") @RequestMapping(value = "/hasUserAuthorized")
public JsonResult hasUserAuthorized(String idNo) { public JsonResult hasUserAuthorized(String idNo) {
LOGGER.info("[hasUserAuthorized]需要校验的用户的身份证号为idNo:{}", idNo); LOGGER.info("[hasUserAuthorized]需要校验的用户的身份证号为idNo:{}", idNo);
...@@ -35,7 +35,7 @@ public class UserAuthorizedController { ...@@ -35,7 +35,7 @@ public class UserAuthorizedController {
} }
} }
@LogHttpCaller
@RequestMapping(value = "/createUserAuthorized") @RequestMapping(value = "/createUserAuthorized")
public JsonResult createUserAuthorized(UserAuthorizedParam userAuthorizedParam) { public JsonResult createUserAuthorized(UserAuthorizedParam userAuthorizedParam) {
LOGGER.info("[createUserAuthorized]创建实名账户,userAuthorizedParam:{},", userAuthorizedParam); LOGGER.info("[createUserAuthorized]创建实名账户,userAuthorizedParam:{},", userAuthorizedParam);
...@@ -55,7 +55,7 @@ public class UserAuthorizedController { ...@@ -55,7 +55,7 @@ public class UserAuthorizedController {
} }
} }
@LogHttpCaller
@RequestMapping(value = "/getUserAuthorizedId") @RequestMapping(value = "/getUserAuthorizedId")
public JsonResult getUserAuthorizedId(String userUuid) { public JsonResult getUserAuthorizedId(String userUuid) {
LOGGER.info("[getUserAuthorizedId]获取实名账户的id,userUuid:{}", userUuid); LOGGER.info("[getUserAuthorizedId]获取实名账户的id,userUuid:{}", userUuid);
......
...@@ -113,7 +113,7 @@ public class UserController implements IBaseController { ...@@ -113,7 +113,7 @@ public class UserController implements IBaseController {
return login(channelId, appChannel, createdFrom, userId, key, dimension, request); return login(channelId, appChannel, createdFrom, userId, key, dimension, request);
} }
@LogHttpCaller
@PasswordErrorFiniteValidator @PasswordErrorFiniteValidator
@RequestMapping("/login") @RequestMapping("/login")
public JsonResult login( public JsonResult login(
...@@ -328,7 +328,7 @@ public class UserController implements IBaseController { ...@@ -328,7 +328,7 @@ public class UserController implements IBaseController {
* @param verificationCode * @param verificationCode
* @return * @return
*/ */
@LogHttpCaller
@RequestMapping("/reset_password") @RequestMapping("/reset_password")
public JsonResult resetPassword(@RequestParam String phoneNo, public JsonResult resetPassword(@RequestParam String phoneNo,
@RequestParam String password, @RequestParam String password,
...@@ -364,7 +364,7 @@ public class UserController implements IBaseController { ...@@ -364,7 +364,7 @@ public class UserController implements IBaseController {
* @param token - sid,session的id * @param token - sid,session的id
* @return * @return
*/ */
@LogHttpCaller
@RequestMapping("/exists_token") @RequestMapping("/exists_token")
public JsonResult checkToken(@RequestParam String token) { public JsonResult checkToken(@RequestParam String token) {
if (StringUtils.isEmpty(token)) { if (StringUtils.isEmpty(token)) {
......
...@@ -29,9 +29,8 @@ public enum MaritalStatus { ...@@ -29,9 +29,8 @@ public enum MaritalStatus {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("MaritalStatus{"); String sb = "MaritalStatus{" + "description='" + description + '\'' +
sb.append("description='").append(description).append('\''); '}';
sb.append('}'); return sb;
return sb.toString();
} }
} }
...@@ -27,10 +27,6 @@ public enum OccupationEnum { ...@@ -27,10 +27,6 @@ public enum OccupationEnum {
return name; return name;
} }
public void setName(String name) {
this.name = name;
}
@Override @Override
public String toString() { public String toString() {
return name; return name;
......
...@@ -25,15 +25,10 @@ public enum Relation { ...@@ -25,15 +25,10 @@ public enum Relation {
return description; return description;
} }
public void setDescription(String description) {
this.description = description;
}
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("Relation{"); String sb = "Relation{" + "description='" + description + '\'' +
sb.append("description='").append(description).append('\''); '}';
sb.append('}'); return sb;
return sb.toString();
} }
} }
...@@ -429,13 +429,13 @@ public class GeetestLib { ...@@ -429,13 +429,13 @@ public class GeetestLib {
* @time 2014年7月10日 下午3:30:01 * @time 2014年7月10日 下午3:30:01
*/ */
private String md5Encode(String plainText) { private String md5Encode(String plainText) {
String re_md5 = new String(); String re_md5 = "";
try { try {
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes()); md.update(plainText.getBytes());
byte b[] = md.digest(); byte b[] = md.digest();
int i; int i;
StringBuilder buf = new StringBuilder(""); StringBuilder buf = new StringBuilder();
for (int offset = 0; offset < b.length; offset++) { for (int offset = 0; offset < b.length; offset++) {
i = b[offset]; i = b[offset];
if (i < 0) { if (i < 0) {
......
...@@ -3,7 +3,6 @@ package cn.quantgroup.xyqb.service.http.impl; ...@@ -3,7 +3,6 @@ package cn.quantgroup.xyqb.service.http.impl;
import cn.quantgroup.tech.brave.service.ITechHttpClient; import cn.quantgroup.tech.brave.service.ITechHttpClient;
import cn.quantgroup.xyqb.service.http.IHttpService; import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.util.Utils; import cn.quantgroup.xyqb.util.Utils;
import com.google.common.base.Predicates;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.commons.codec.Charsets; import org.apache.commons.codec.Charsets;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
...@@ -29,7 +28,6 @@ import org.apache.http.conn.ssl.SSLContextBuilder; ...@@ -29,7 +28,6 @@ import org.apache.http.conn.ssl.SSLContextBuilder;
import org.apache.http.cookie.Cookie; import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin; import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpecProvider; import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy; import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.StandardHttpRequestRetryHandler; import org.apache.http.impl.client.StandardHttpRequestRetryHandler;
...@@ -211,7 +209,7 @@ public class HttpServiceImpl implements IHttpService { ...@@ -211,7 +209,7 @@ public class HttpServiceImpl implements IHttpService {
*/ */
private void setParameter(RequestBuilder requestBuilder, Map<String, String> parameters, String method) { private void setParameter(RequestBuilder requestBuilder, Map<String, String> parameters, String method) {
if (MapUtils.isNotEmpty(parameters)) { if (MapUtils.isNotEmpty(parameters)) {
parameters = Maps.filterValues(parameters, Predicates.notNull()); parameters = Maps.filterValues(parameters, s -> s != null);
Set<Map.Entry<String, String>> entrys = parameters.entrySet(); Set<Map.Entry<String, String>> entrys = parameters.entrySet();
/************** Get 请求 **************/ /************** Get 请求 **************/
...@@ -244,7 +242,7 @@ public class HttpServiceImpl implements IHttpService { ...@@ -244,7 +242,7 @@ public class HttpServiceImpl implements IHttpService {
.setHeader("Connection", "keep-alive"); .setHeader("Connection", "keep-alive");
if (MapUtils.isNotEmpty(headers)) { if (MapUtils.isNotEmpty(headers)) {
headers = Maps.filterValues(headers, Predicates.notNull()); headers = Maps.filterValues(headers, s -> s != null);
Set<Map.Entry<String, String>> entrys = headers.entrySet(); Set<Map.Entry<String, String>> entrys = headers.entrySet();
for (Map.Entry<String, String> entry : entrys) { for (Map.Entry<String, String> entry : entrys) {
......
...@@ -118,21 +118,18 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -118,21 +118,18 @@ public class UserDetailServiceImpl implements IUserDetailService {
private Specification<UserDetail> getSpecification(String name, String phoneNo, String idNo) { private Specification<UserDetail> getSpecification(String name, String phoneNo, String idNo) {
List<Predicate> list = new ArrayList<>(); List<Predicate> list = new ArrayList<>();
Specification<UserDetail> specification = new Specification<UserDetail>() { Specification<UserDetail> specification = (root, criteriaQuery, criteriaBuilder) -> {
@Override if (!StringUtils.isEmpty(name)) {
public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { list.add(criteriaBuilder.equal(root.get("name").as(String.class), name));
if (!StringUtils.isEmpty(name)) { }
list.add(criteriaBuilder.equal(root.get("name").as(String.class), name)); if (!StringUtils.isEmpty(phoneNo)) {
} list.add(criteriaBuilder.equal(root.get(Constants.PHONE_NO).as(String.class), phoneNo));
if (!StringUtils.isEmpty(phoneNo)) { }
list.add(criteriaBuilder.equal(root.get(Constants.PHONE_NO).as(String.class), phoneNo)); if (!StringUtils.isEmpty(idNo)) {
} list.add(criteriaBuilder.equal(root.get("idNo").as(String.class), idNo));
if (!StringUtils.isEmpty(idNo)) {
list.add(criteriaBuilder.equal(root.get("idNo").as(String.class), idNo));
}
Predicate[] p = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(p));
} }
Predicate[] p = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(p));
}; };
return specification; return specification;
} }
...@@ -148,24 +145,21 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -148,24 +145,21 @@ public class UserDetailServiceImpl implements IUserDetailService {
private Specification<UserDetail> valueInSpecification(List<Long> userId, List<String> phoneNo, List<String> idNo) { private Specification<UserDetail> valueInSpecification(List<Long> userId, List<String> phoneNo, List<String> idNo) {
List<Predicate> list = new ArrayList<>(); List<Predicate> list = new ArrayList<>();
Specification<UserDetail> specification = new Specification<UserDetail>() { Specification<UserDetail> specification = (root, criteriaQuery, criteriaBuilder) -> {
@Override if (userId != null && userId.size() > 0) {
public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { criteriaQuery.where(root.get("userId").in(userId));
if (userId != null && userId.size() > 0) { list.add(criteriaQuery.getRestriction());
criteriaQuery.where(root.get("userId").in(userId)); }
list.add(criteriaQuery.getRestriction()); if (phoneNo != null && phoneNo.size() > 0) {
} criteriaQuery.where(root.get(Constants.PHONE_NO).in(phoneNo));
if (phoneNo != null && phoneNo.size() > 0) { list.add(criteriaQuery.getRestriction());
criteriaQuery.where(root.get(Constants.PHONE_NO).in(phoneNo)); }
list.add(criteriaQuery.getRestriction()); if (idNo != null && idNo.size() > 0) {
} criteriaQuery.where(root.get("idNo").in(idNo));
if (idNo != null && idNo.size() > 0) { list.add(criteriaQuery.getRestriction());
criteriaQuery.where(root.get("idNo").in(idNo));
list.add(criteriaQuery.getRestriction());
}
Predicate[] p = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(p));
} }
Predicate[] p = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(p));
}; };
return specification; return specification;
} }
......
...@@ -133,9 +133,7 @@ public class ValidationUtil { ...@@ -133,9 +133,7 @@ public class ValidationUtil {
public static String getMd5Key(boolean lock) { public static String getMd5Key(boolean lock) {
Calendar today = Calendar.getInstance(); Calendar today = Calendar.getInstance();
int hour_24 = today.get(Calendar.HOUR_OF_DAY); int hour_24 = today.get(Calendar.HOUR_OF_DAY);
StringBuilder _key = new StringBuilder(); return MD5Util.build(Constants.CLEAR_LOCK_FOR_IPV4_KEY + lock + hour_24);
_key.append(Constants.CLEAR_LOCK_FOR_IPV4_KEY).append(lock).append(hour_24);
return MD5Util.build(_key.toString());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment