Commit 6d964f82 authored by Java—红包—徐 然's avatar Java—红包—徐 然

Merge branch 'feature/junit_test'

parents fa65cadb 348e0127
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- jUnit 5 --> <!-- jUnit 5 -->
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
...@@ -249,7 +248,15 @@ ...@@ -249,7 +248,15 @@
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId> <artifactId>apollo-client</artifactId>
<version>0.10.1</version> <version>0.10.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.quantgroup</groupId>
<artifactId>commons</artifactId>
<version>0.0.5</version>
<scope>compile</scope>
</dependency> </dependency>
<!-- motan --> <!-- motan -->
<dependency> <dependency>
<groupId>com.weibo</groupId> <groupId>com.weibo</groupId>
...@@ -385,7 +392,6 @@ ...@@ -385,7 +392,6 @@
<id>test</id> <id>test</id>
<properties> <properties>
<profiles.activation>test</profiles.activation> <profiles.activation>test</profiles.activation>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
......
package cn.quantgroup.xyqb; package cn.quantgroup.xyqb;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import cn.quantgroup.tech.shutdown.DefaultSignalHandler;
import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
import com.weibo.api.motan.common.MotanConstants; import com.weibo.api.motan.common.MotanConstants;
import com.weibo.api.motan.util.MotanSwitcherUtil; import com.weibo.api.motan.util.MotanSwitcherUtil;
import io.sentry.Sentry; import io.sentry.Sentry;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import sun.misc.Signal;
@ComponentScan(basePackages = {"cn.quantgroup.sms", "cn.quantgroup.xyqb"}) @ComponentScan(basePackages = {"cn.quantgroup.sms", "cn.quantgroup.xyqb"})
@EnableAutoConfiguration
@SpringBootApplication @SpringBootApplication
@EnableCaching @EnableCaching
@EnableApolloConfig
@PropertySource(value = {"classpath:application.properties", "classpath:xyqb.properties"}, ignoreResourceNotFound = true)
@Configuration
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableAsync @EnableAsync
@Slf4j @Slf4j
...@@ -32,7 +27,6 @@ public class Bootstrap { ...@@ -32,7 +27,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.addInitializers(new ApolloPropertySourceInitializer("application", "tech.msg.sdk", "cash.common","tech.service.urls"));
springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() { springApplication.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
@Override @Override
public void onApplicationEvent(ContextRefreshedEvent event) { public void onApplicationEvent(ContextRefreshedEvent event) {
...@@ -41,8 +35,14 @@ public class Bootstrap { ...@@ -41,8 +35,14 @@ public class Bootstrap {
} }
}); });
springApplication.setRegisterShutdownHook(true); springApplication.setRegisterShutdownHook(true);
springApplication.run(args); ConfigurableApplicationContext run = springApplication.run(args);
log.info("server start..."); log.info("server start...");
Sentry.init("http://13ef5642903a414c910f8d0e0a2c56ee:8b351ad1abf44de3b4c25f39105fb927@172.16.4.89:9000/6"); // 启用平滑退出功能
Signal.handle(new Signal("INT"), new DefaultSignalHandler(run));
// 异常log捕获
Environment environment = run.getBean(Environment.class);
String dsn = environment.getProperty("dsn");
Sentry.init(dsn);
} }
} }
...@@ -8,13 +8,11 @@ import org.aspectj.lang.annotation.Aspect; ...@@ -8,13 +8,11 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
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;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/** /**
* IP白名单检验 * IP白名单检验
...@@ -27,18 +25,12 @@ import java.util.Objects; ...@@ -27,18 +25,12 @@ import java.util.Objects;
public class IpValidateAdvisor { public class IpValidateAdvisor {
private static final Logger LOGGER = LoggerFactory.getLogger(IpValidateAdvisor.class); private static final Logger LOGGER = LoggerFactory.getLogger(IpValidateAdvisor.class);
@Value("${configserver.disable}")
private Integer isDebug;
@Pointcut("execution(public * cn.quantgroup.xyqb.controller.external.user.InnerController.*(..)) || @annotation(cn.quantgroup.xyqb.aspect.accessable.IpValidator)") @Pointcut("execution(public * cn.quantgroup.xyqb.controller.external.user.InnerController.*(..)) || @annotation(cn.quantgroup.xyqb.aspect.accessable.IpValidator)")
private void whiteIpMatch() { private void whiteIpMatch() {
} }
@Around("whiteIpMatch()") @Around("whiteIpMatch()")
private Object doWhiteIpMatch(ProceedingJoinPoint pjp) throws Throwable { private Object doWhiteIpMatch(ProceedingJoinPoint pjp) throws Throwable {
if(Objects.equals(isDebug, 0)){
return pjp.proceed();
}
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
// 客户端IP // 客户端IP
String clientIp = IPUtil.getRemoteIP(request); String clientIp = IPUtil.getRemoteIP(request);
......
package cn.quantgroup.xyqb.aspect.captcha;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.thirdparty.jcaptcha.AbstractManageableImageCaptchaService;
import cn.quantgroup.xyqb.util.IPUtil;
import com.octo.captcha.service.CaptchaServiceException;
import java.nio.charset.Charset;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
/**
* 类名称:CaptchaValidateAdvisor
* 类描述:
*
* @author 李宁
* @version 1.0.0 创建时间:15/11/17 14:49
*/
@Aspect
@Component
public class CaptchaNewValidateAdvisor {
private static final Logger LOGGER = LoggerFactory.getLogger(CaptchaNewValidateAdvisor.class);
private static final String SUPER_CAPTCHA_ID = UUID.nameUUIDFromBytes("__QG_APPCLIENT_AGENT__".getBytes(Charset.forName("UTF-8"))).toString();
private static final String SUPER_CAPTCHA = "__SUPERQG__";
@Autowired
@Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> redisTemplate;
@Autowired
@Qualifier("customCaptchaService")
private AbstractManageableImageCaptchaService imageCaptchaService;
/**
* 自动化测试忽略验证码
*/
@Value("${xyqb.auth.captcha.autotest.enable:false}")
private boolean autoTestCaptchaEnabled;
private static final String IMAGE_IP_COUNT = "image:ip";
private static final String IMAGE_PHONE_COUNT = "image:phone";
private static final String IMAGE_DEVICEID_COUNT = "image:deviceId:";
private static final Long FIVE_MIN = 24 * 5L;
/**
* 图形验证码切面
*/
@Pointcut("@annotation(cn.quantgroup.xyqb.aspect.captcha.CaptchaNewValidator)")
private void needNewCaptchaValidate() {
}
/**
* 在受图形验证码保护的接口方法执行前, 执行图形验证码校验
* captchaId 图形验证码key
* captchaValue 图形验证码value
*
* @throws Throwable
*/
@Around("needNewCaptchaValidate()")
private Object doCapchaValidate(ProceedingJoinPoint pjp) throws Throwable {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String registerFrom = Optional.ofNullable(request.getParameter("registerFrom")).orElse("");
String captchaId = Optional.ofNullable(request.getParameter("captchaId")).orElse("");
String captchaValue = request.getParameter("captchaValue");
String phoneNo = request.getParameter("phoneNo");
String deviceId = Optional.ofNullable(request.getParameter("deviceId")).orElse("");
String clientIp = IPUtil.getRemoteIP(request);
Long countIP = countByClientId(clientIp, false);
Long countPhone = countPhone(phoneNo);
Long countDeviceId = countByClientId(deviceId, true);
IPUtil.logIp(LOGGER, request);
LOGGER.info("使用图形验证码, registerFrom={}, clientIp={},手机号次数:{},设备次数:{},ip次数:{},phone:{}", registerFrom, clientIp,countPhone,countDeviceId,countIP,phoneNo);
//if (countIP > Constants.Image_Need_Count || countPhone > Constants.Image_Need_Count || countDeviceId > Constants.Image_Need_Count) {
if(true){
if (shouldSkipCaptchaValidate(registerFrom, captchaId, captchaValue)) {
LOGGER.info("使用超级图形验证码校验, registerFrom={}, clientIp={}", registerFrom, clientIp);
return pjp.proceed();
}
JsonResult result = JsonResult.buildSuccessResult("图形验证码不正确", "");
result.setBusinessCode("0002");
if (StringUtils.isNotBlank(captchaValue)) {
// 忽略用户输入的大小写
String captcha = StringUtils.lowerCase(captchaValue);
// 验证码校验
Boolean validCaptcha = false;
try {
validCaptcha = imageCaptchaService.validateResponseForID(Constants.IMAGE_CAPTCHA_KEY + captchaId, captcha);
} catch (CaptchaServiceException ex) {
LOGGER.error("验证码校验异常, {}, {}", ex.getMessage(), ex);
}
if (validCaptcha) {
return pjp.proceed();
}
return result;
}
LOGGER.info("使用错误图形验证码, registerFrom={}, clientIp={},手机号次数:{},设备次数:{},ip次数:{},phone:{}", registerFrom, clientIp,countPhone,countDeviceId,countIP,phoneNo);
result.setMsg("请输入图形验证码");
return result;
}
return pjp.proceed();
}
private boolean shouldSkipCaptchaValidate(String registerFrom, String captchaId, Object captchaValue) {
// 如果启用了超级验证码功能, 检查超级验证码, 超级验证码区分大小写
if (autoTestCaptchaEnabled) {
return true;
}
return StringUtils.equals(SUPER_CAPTCHA_ID, String.valueOf(captchaId)) && StringUtils.equals(SUPER_CAPTCHA, String.valueOf(captchaValue));
}
private Long countPhone(String phoneNo) {
Long count = 1L;
String countString = redisTemplate.opsForValue().get(IMAGE_PHONE_COUNT + phoneNo);
if (StringUtils.isBlank(countString)) {
redisTemplate.opsForValue().set(IMAGE_PHONE_COUNT + phoneNo, String.valueOf(count),
FIVE_MIN, TimeUnit.SECONDS);
} else {
count = Long.valueOf(countString) + 1L;
redisTemplate.opsForValue().set(IMAGE_PHONE_COUNT + phoneNo, String.valueOf(count),
FIVE_MIN, TimeUnit.SECONDS);
}
return count;
}
/**
* 短信发送限制
* @param clientId - 设备ID或IP
* @param device - true - 设备,false - IP
* @return
*/
private Long countByClientId(String clientId, boolean device) {
Long count = 1L;
if (StringUtils.isBlank(clientId)) {
return count;
} else {
String key = (device ? IMAGE_DEVICEID_COUNT : IMAGE_IP_COUNT) + clientId;
String countString = redisTemplate.opsForValue().get(key);
if (StringUtils.isBlank(countString)) {
redisTemplate.opsForValue().set(key, String.valueOf(count), FIVE_MIN, TimeUnit.SECONDS);
} else {
count = Long.valueOf(countString) + 1L;
redisTemplate.opsForValue().set(key, String.valueOf(count), FIVE_MIN, TimeUnit.SECONDS);
}
return count;
}
}
}
package cn.quantgroup.xyqb.aspect.captcha;
import java.lang.annotation.*;
/**
* Created by xuran on 2017/8/28.
*/
@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CaptchaNewValidator {
}
package cn.quantgroup.xyqb.aspect.captcha; package cn.quantgroup.xyqb.aspect.captcha;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.thirdparty.jcaptcha.AbstractManageableImageCaptchaService; import cn.quantgroup.xyqb.thirdparty.jcaptcha.AbstractManageableImageCaptchaService;
...@@ -78,19 +77,16 @@ public class CaptchaValidateAdvisor { ...@@ -78,19 +77,16 @@ public class CaptchaValidateAdvisor {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String registerFrom = Optional.ofNullable(request.getParameter("registerFrom")).orElse(""); String registerFrom = Optional.ofNullable(request.getParameter("registerFrom")).orElse("");
String captchaId = Optional.ofNullable(request.getParameter("captchaId")).orElse(""); String captchaId = Optional.ofNullable(request.getParameter("captchaId")).orElse("");
Object captchaValue = request.getParameter("captchaValue"); String captchaValue = request.getParameter("captchaValue");
if (shouldSkipCaptchaValidate(registerFrom, captchaId, captchaValue)) { if (shouldSkipCaptchaValidate(registerFrom, captchaId, captchaValue)) {
LOGGER.info("使用超级图形验证码校验, registerFrom={}, clientIp={}", registerFrom, IPUtil.getRemoteIP(request)); LOGGER.info("使用超级图形验证码校验, registerFrom={}, clientIp={}", registerFrom, IPUtil.getRemoteIP(request));
return pjp.proceed(); return pjp.proceed();
} }
JsonResult result = JsonResult.buildSuccessResult("图形验证码不正确", ""); JsonResult result = JsonResult.buildSuccessResult("图形验证码不正确", "");
result.setBusinessCode("0002"); result.setBusinessCode("0002");
if (captchaValue != null) { if (StringUtils.isNotBlank(captchaValue)) {
String captcha = String.valueOf(captchaValue);
// 忽略用户输入的大小写 // 忽略用户输入的大小写
captcha = StringUtils.lowerCase(captcha); String captcha = StringUtils.lowerCase(captchaValue);
// 验证码校验 // 验证码校验
Boolean validCaptcha = false; Boolean validCaptcha = false;
try { try {
...@@ -98,7 +94,6 @@ public class CaptchaValidateAdvisor { ...@@ -98,7 +94,6 @@ public class CaptchaValidateAdvisor {
} catch (CaptchaServiceException ex) { } catch (CaptchaServiceException ex) {
LOGGER.error("验证码校验异常, {}, {}", ex.getMessage(), ex); LOGGER.error("验证码校验异常, {}, {}", ex.getMessage(), ex);
} }
if (validCaptcha) { if (validCaptcha) {
return pjp.proceed(); return pjp.proceed();
} }
......
...@@ -112,6 +112,7 @@ public class HttpConfig { ...@@ -112,6 +112,7 @@ public class HttpConfig {
.register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory()) .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
.register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()) .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory())
.register("easy", httpContext -> new BrowserCompatSpec() { .register("easy", httpContext -> new BrowserCompatSpec() {
@Override
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException { public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
} }
}).build(); }).build();
......
...@@ -18,7 +18,6 @@ import cn.quantgroup.xyqb.service.http.IHttpService; ...@@ -18,7 +18,6 @@ import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.merchant.IMerchantService; import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import cn.quantgroup.xyqb.service.register.IUserRegisterService; import cn.quantgroup.xyqb.service.register.IUserRegisterService;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.sms.ISmsService;
import cn.quantgroup.xyqb.service.user.*; import cn.quantgroup.xyqb.service.user.*;
import cn.quantgroup.xyqb.service.user.vo.UserDetailVO; import cn.quantgroup.xyqb.service.user.vo.UserDetailVO;
import cn.quantgroup.xyqb.service.wechat.IWechatService; import cn.quantgroup.xyqb.service.wechat.IWechatService;
...@@ -68,8 +67,6 @@ public class MotanUserServiceImpl implements UserMotanService { ...@@ -68,8 +67,6 @@ public class MotanUserServiceImpl implements UserMotanService {
@Autowired @Autowired
private IUserRepository userRepository; private IUserRepository userRepository;
@Autowired @Autowired
private ISmsService smsService;
@Autowired
private ILkbUserService lkbUserService; private ILkbUserService lkbUserService;
@Autowired @Autowired
private IMerchantService merchantService; private IMerchantService merchantService;
......
...@@ -57,11 +57,11 @@ public class UserQueryLogController { ...@@ -57,11 +57,11 @@ public class UserQueryLogController {
@Autowired @Autowired
private IAddressService addressService; private IAddressService addressService;
@Value("${xyqb.paycenter.url}") @Value("${payapi.http}")
private String payCenterUrl; private String payCenterUrl;
@Value("${xyqb.paycenter.id}") @Value("${xyqb.paycenter.id}")
private String payCenterId; private String payCenterId;
@Value("${xyqb.yunying.url}") @Value("${opapi.http}")
private String yunyingUrl; private String yunyingUrl;
......
...@@ -15,7 +15,6 @@ import cn.quantgroup.xyqb.service.auth.IIdCardService; ...@@ -15,7 +15,6 @@ import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.merchant.IMerchantService; import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import cn.quantgroup.xyqb.service.register.IUserRegisterService; import cn.quantgroup.xyqb.service.register.IUserRegisterService;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.sms.ISmsService;
import cn.quantgroup.xyqb.service.user.ILkbUserService; import cn.quantgroup.xyqb.service.user.ILkbUserService;
import cn.quantgroup.xyqb.service.user.IUserBtRegisterService; import cn.quantgroup.xyqb.service.user.IUserBtRegisterService;
import cn.quantgroup.xyqb.service.user.IUserDetailService; import cn.quantgroup.xyqb.service.user.IUserDetailService;
...@@ -53,8 +52,6 @@ public class AppController implements IBaseController { ...@@ -53,8 +52,6 @@ public class AppController implements IBaseController {
@Autowired @Autowired
private IUserRepository userRepository; private IUserRepository userRepository;
@Autowired @Autowired
private ISmsService smsService;
@Autowired
private IUserDetailService userDetailService; private IUserDetailService userDetailService;
@Autowired @Autowired
private IIdCardService idCardService; private IIdCardService idCardService;
......
...@@ -85,12 +85,9 @@ public class InnerController implements IBaseController { ...@@ -85,12 +85,9 @@ public class InnerController implements IBaseController {
@Autowired @Autowired
private IUserRegisterService userRegisterService; private IUserRegisterService userRegisterService;
@Value("${xyqb.user.query.url}") @Value("${userqry.http}")
private String queryUrl; private String queryUrl;
@Value("${xyqb.auth.url}")
private String hanguguanUrl;
private static final ObjectMapper MAPPER = new ObjectMapper(); private static final ObjectMapper MAPPER = new ObjectMapper();
static { static {
...@@ -117,8 +114,8 @@ public class InnerController implements IBaseController { ...@@ -117,8 +114,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("", userRet); return JsonResult.buildSuccessResult("", userRet);
} }
@RequestMapping("/user/search/uuid")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/search/uuid")
public JsonResult findByUuid(String uuid) { public JsonResult findByUuid(String uuid) {
User user = userService.findByUuidInDb(uuid); User user = userService.findByUuidInDb(uuid);
if (user == null) { if (user == null) {
...@@ -128,8 +125,8 @@ public class InnerController implements IBaseController { ...@@ -128,8 +125,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("", userRet); return JsonResult.buildSuccessResult("", userRet);
} }
@RequestMapping("/userInfo/search/uuid")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/userInfo/search/uuid")
public JsonResult findUserInfoByUuid(@RequestParam(value = "uuid") String uuid) { public JsonResult findUserInfoByUuid(@RequestParam(value = "uuid") String uuid) {
LOGGER.info("需要查询的用户uuidid, uuid:" + uuid); LOGGER.info("需要查询的用户uuidid, uuid:" + uuid);
...@@ -148,8 +145,8 @@ public class InnerController implements IBaseController { ...@@ -148,8 +145,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
} }
@RequestMapping("/userInfo/search/phone")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/userInfo/search/phone")
public JsonResult findUserInfoByPhone(@RequestParam(value = "phone") String phone) { public JsonResult findUserInfoByPhone(@RequestParam(value = "phone") String phone) {
LOGGER.info("需要查询的用户phone, phone:" + phone); LOGGER.info("需要查询的用户phone, phone:" + phone);
...@@ -168,9 +165,8 @@ public class InnerController implements IBaseController { ...@@ -168,9 +165,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
} }
@RequestMapping("/user/getPhoneByUserIds")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/getPhoneByUserIds")
public JsonResult findByIds(@RequestParam(value = "userIds") String userIdsString) { public JsonResult findByIds(@RequestParam(value = "userIds") String userIdsString) {
LOGGER.info("批量查询用户的手机号列表, userIdsString:" + userIdsString); LOGGER.info("批量查询用户的手机号列表, userIdsString:" + userIdsString);
if (StringUtils.isEmpty(userIdsString)) { if (StringUtils.isEmpty(userIdsString)) {
...@@ -234,7 +230,6 @@ public class InnerController implements IBaseController { ...@@ -234,7 +230,6 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, userRet); return JsonResult.buildSuccessResult(null, userRet);
} }
/** /**
* 保存用户详细信息 * 保存用户详细信息
*/ */
...@@ -295,8 +290,8 @@ public class InnerController implements IBaseController { ...@@ -295,8 +290,8 @@ public class InnerController implements IBaseController {
/** /**
* 根据用户id查询用户的详细信息 * 根据用户id查询用户的详细信息
*/ */
@RequestMapping("/user_detail/search/userId")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user_detail/search/userId")
public JsonResult findUserDetailByUserId(Long userId) { public JsonResult findUserDetailByUserId(Long userId) {
UserDetail userDetail = userDetailService.findByUserId(userId); UserDetail userDetail = userDetailService.findByUserId(userId);
if (userDetail != null) { if (userDetail != null) {
...@@ -305,8 +300,8 @@ public class InnerController implements IBaseController { ...@@ -305,8 +300,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("", null); return JsonResult.buildErrorStateResult("", null);
} }
@RequestMapping("/user/search/userId")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/search/userId")
public JsonResult findUserByUserId(Long userId) { public JsonResult findUserByUserId(Long userId) {
User user = userService.findById(userId); User user = userService.findById(userId);
if (user != null) { if (user != null) {
...@@ -315,8 +310,8 @@ public class InnerController implements IBaseController { ...@@ -315,8 +310,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildErrorStateResult("", null); return JsonResult.buildErrorStateResult("", null);
} }
@RequestMapping("/user_detail/search/phone")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user_detail/search/phone")
public JsonResult findUserDetailByPhone(String phoneNo) { public JsonResult findUserDetailByPhone(String phoneNo) {
UserDetail userDetail = userDetailService.findByPhoneNo(phoneNo); UserDetail userDetail = userDetailService.findByPhoneNo(phoneNo);
if (userDetail != null) { if (userDetail != null) {
...@@ -331,8 +326,8 @@ public class InnerController implements IBaseController { ...@@ -331,8 +326,8 @@ public class InnerController implements IBaseController {
* @param phoneNo * @param phoneNo
* @return * @return
*/ */
@RequestMapping("/user_full_info/search/phone")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user_full_info/search/phone")
public JsonResult findUserFullInfoByPhone(String phoneNo) { public JsonResult findUserFullInfoByPhone(String phoneNo) {
if (StringUtils.isBlank(phoneNo)) { if (StringUtils.isBlank(phoneNo)) {
LOGGER.warn("[findUserFullInfoByPhone]phoneNo为空"); LOGGER.warn("[findUserFullInfoByPhone]phoneNo为空");
...@@ -352,8 +347,8 @@ public class InnerController implements IBaseController { ...@@ -352,8 +347,8 @@ public class InnerController implements IBaseController {
* @param uuid * @param uuid
* @return * @return
*/ */
@RequestMapping("/user_full_info/search/uuid")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user_full_info/search/uuid")
public JsonResult findUserFullInfoByUUuid(String uuid) { public JsonResult findUserFullInfoByUUuid(String uuid) {
if (StringUtils.isBlank(uuid)) { if (StringUtils.isBlank(uuid)) {
LOGGER.warn("[findUserFullInfoByUUuid]uuid为空"); LOGGER.warn("[findUserFullInfoByUUuid]uuid为空");
...@@ -376,8 +371,8 @@ public class InnerController implements IBaseController { ...@@ -376,8 +371,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, null); return JsonResult.buildSuccessResult(null, null);
} }
@RequestMapping("/contact/search/user_id")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/contact/search/user_id")
public JsonResult findContactsByUserId(Long userId) { public JsonResult findContactsByUserId(Long userId) {
if (null == userId) { if (null == userId) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
...@@ -488,8 +483,8 @@ public class InnerController implements IBaseController { ...@@ -488,8 +483,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj)); return JsonResult.buildSuccessResult(null, AddressRet.address2AddressRet(addressObj));
} }
@RequestMapping("/user_ext_info/update")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user_ext_info/update")
public JsonResult updateMarryStatus( public JsonResult updateMarryStatus(
Long userId, IncomeEnum incomeEnum, IncomeRangeEnum incomeRangeEnum, Long userId, IncomeEnum incomeEnum, IncomeRangeEnum incomeRangeEnum,
OccupationEnum occupationEnum, EducationEnum educationEnum, Boolean hasCar, OccupationEnum occupationEnum, EducationEnum educationEnum, Boolean hasCar,
...@@ -566,8 +561,8 @@ public class InnerController implements IBaseController { ...@@ -566,8 +561,8 @@ public class InnerController implements IBaseController {
return JSON.parseObject(s, JsonResult.class); return JSON.parseObject(s, JsonResult.class);
} }
@RequestMapping("/user_ext_info/search/user_id")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user_ext_info/search/user_id")
public JsonResult searchUserExtInfoByUserId(Long userId) { public JsonResult searchUserExtInfoByUserId(Long userId) {
if (userId == null) { if (userId == null) {
return JsonResult.buildErrorStateResult("userId不能为空", null); return JsonResult.buildErrorStateResult("userId不能为空", null);
...@@ -579,8 +574,8 @@ public class InnerController implements IBaseController { ...@@ -579,8 +574,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, UserExtInfoRet.getUserExtInfoRet(userExtInfo)); return JsonResult.buildSuccessResult(null, UserExtInfoRet.getUserExtInfoRet(userExtInfo));
} }
@RequestMapping("/user/query/openId")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/query/openId")
public JsonResult queryOpenIdByUserId(Long userId) { public JsonResult queryOpenIdByUserId(Long userId) {
if (userId == null) { if (userId == null) {
return JsonResult.buildErrorStateResult("userId不能为空", null); return JsonResult.buildErrorStateResult("userId不能为空", null);
...@@ -791,8 +786,8 @@ public class InnerController implements IBaseController { ...@@ -791,8 +786,8 @@ public class InnerController implements IBaseController {
return contactRets; return contactRets;
} }
@RequestMapping("/user/wechat/phone_no")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/wechat/phone_no")
public JsonResult queryOpenIdByPhoneNo(String phoneNo) { public JsonResult queryOpenIdByPhoneNo(String phoneNo) {
if (StringUtils.isBlank(phoneNo)) { if (StringUtils.isBlank(phoneNo)) {
return JsonResult.buildErrorStateResult("手机号错误", null); return JsonResult.buildErrorStateResult("手机号错误", null);
...@@ -871,8 +866,8 @@ public class InnerController implements IBaseController { ...@@ -871,8 +866,8 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, UserSpouseRet.getUserSpouseRet(userSpouse)); return JsonResult.buildSuccessResult(null, UserSpouseRet.getUserSpouseRet(userSpouse));
} }
@RequestMapping("/user/spouse/findByUserId")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/spouse/findByUserId")
public JsonResult querySpouse(Long userId) { public JsonResult querySpouse(Long userId) {
if (userId == null || userId == 0) { if (userId == null || userId == 0) {
return JsonResult.buildErrorStateResult("用户不能为空", null); return JsonResult.buildErrorStateResult("用户不能为空", null);
...@@ -942,8 +937,8 @@ public class InnerController implements IBaseController { ...@@ -942,8 +937,8 @@ public class InnerController implements IBaseController {
/** /**
* 保存用户信息,地址信息,联系人信息 * 保存用户信息,地址信息,联系人信息
*/ */
@RequestMapping("/user/save_multi")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/user/save_multi")
public JsonResult saveMulti( public JsonResult saveMulti(
String registeredFrom, String registeredFrom,
String channelId, String channelId,
...@@ -1032,9 +1027,8 @@ public class InnerController implements IBaseController { ...@@ -1032,9 +1027,8 @@ public class InnerController implements IBaseController {
} }
//根据日期时间段查询新注册用户信息并返回 //根据日期时间段查询新注册用户信息并返回
@RequestMapping("/contract/queryRegisterUsers")
@LogHttpCaller @LogHttpCaller
@RequestMapping("/contract/queryRegisterUsers")
public JsonResult findRegisterUserByTime(String beginTime, String endTime) { public JsonResult findRegisterUserByTime(String beginTime, String endTime) {
if (null == beginTime || endTime == null) { if (null == beginTime || endTime == null) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
...@@ -1084,15 +1078,6 @@ public class InnerController implements IBaseController { ...@@ -1084,15 +1078,6 @@ public class InnerController implements IBaseController {
} }
int affectedRows = userDetailService.updateIdCard(name, idNo, phoneNo); int affectedRows = userDetailService.updateIdCard(name, idNo, phoneNo);
LOGGER.info("更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}", name, idNo, phoneNo, reason, affectedRows); LOGGER.info("更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}", name, idNo, phoneNo, reason, affectedRows);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("phoneNo", phoneNo);
builder.put("name", name);
builder.put("idNo", idNo);
builder.put("reason", reason);
builder.put("content", content);
LOGGER.info("去函谷关修改用户身份证号或姓名");
Map<String, String> param = builder.build();
httpService.get(hanguguanUrl.concat("/innerapi/updateIdCard"), param);
return JsonResult.buildSuccessResult("修改用户身份证号或姓名成功", affectedRows); return JsonResult.buildSuccessResult("修改用户身份证号或姓名成功", affectedRows);
} }
...@@ -1117,14 +1102,6 @@ public class InnerController implements IBaseController { ...@@ -1117,14 +1102,6 @@ public class InnerController implements IBaseController {
int affectedRows = userService.forbiddenUser(enable, phoneNo); int affectedRows = userService.forbiddenUser(enable, phoneNo);
LOGGER.info("禁用或者重启用户的理由,reason:{},手机号phoneNo:{},受影响的行数affectedRows:{}", reason, phoneNo, affectedRows); LOGGER.info("禁用或者重启用户的理由,reason:{},手机号phoneNo:{},受影响的行数affectedRows:{}", reason, phoneNo, affectedRows);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("phoneNo", phoneNo);
builder.put("enable", String.valueOf(enable));
builder.put("reason", reason);
builder.put("content", content);
LOGGER.info("去函谷关禁用或者重启用户");
Map<String, String> param = builder.build();
httpService.get(hanguguanUrl.concat("/innerapi/forbiddenUserOrNot"), param);
return JsonResult.buildSuccessResult("用户禁用或重启成功成功", affectedRows); return JsonResult.buildSuccessResult("用户禁用或重启成功成功", affectedRows);
} }
......
...@@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSON; ...@@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -25,21 +24,15 @@ import org.slf4j.Logger; ...@@ -25,21 +24,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Arrays; import java.util.*;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
/** /**
* Created by 11 on 2017/1/17. * Created by 11 on 2017/1/17.
...@@ -66,23 +59,26 @@ public class WeChatController implements IBaseController { ...@@ -66,23 +59,26 @@ public class WeChatController implements IBaseController {
@Autowired @Autowired
private IUserService userService; private IUserService userService;
// https://passport.xyqb.com/landing?key=xxx&target=cashTarget5&registerFrom=198&channelId=%d /**
@Value("${xyqb-user.ui}") * 用户中心UI的http协议头域名
private String userUIAddr; * http://passport.xyqb.com
*/
@Value("${passport.http}")
private String userUiDomain;
@Value("${xyqb.user.domain}") /**
private String userDomainStr; * 用户中心UI的https协议头域名
* https://passport.xyqb.com
*/
@Value("${passport.https}")
private String userUiDomainS;
@Value("${xyqb.domain}") @Value("${api.http}")
private String xyqbDomainStr; private String xyqbDomainStr;
@Autowired @Autowired
private IHttpService httpService; private IHttpService httpService;
//加https地址
@Value("${xyqb-user.ui-s}")
private String userUIAddrS;
/** /**
* 开发者资质认证,有必要吗? * 开发者资质认证,有必要吗?
* *
...@@ -169,209 +165,72 @@ public class WeChatController implements IBaseController { ...@@ -169,209 +165,72 @@ public class WeChatController implements IBaseController {
* @return * @return
*/ */
@RequestMapping("/receiveCode/extdata/{key}/{extdata}") @RequestMapping("/receiveCode/extdata/{key}/{extdata}")
public void receiveCodeWithExtData( public void receiveCodeWithExtData(String code, @PathVariable(value = "key") String systemKey,
String code, @PathVariable(value = "key") String systemKey, @PathVariable(value = "extdata") String extData, HttpServletResponse response) {
@PathVariable(value = "extdata") String extData, HttpServletResponse response Long registerFrom = null;
) { String redirect = null;
String schema = null;
try { try {
String schema = getProtocol(); extData = new String(Base64.decodeBase64(extData), "UTF-8");
try {
extData = new String(Base64.decodeBase64(extData), "UTF-8");
} catch (Exception ex) {
extData = "";
}
String protocol="http:";
LOGGER.info("从微信extdata版本接口进入:{}, extData:{}", schema, extData);
if (StringUtils.isEmpty(extData)) {
// 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return;
}
WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return;
}
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo,
Constants.Channel.WECHAT,protocol);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,protocol);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,protocol);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl =
createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
} else {
HashMap<String, Object> extDataObj;
try {
extDataObj =
JSON.parseObject(extData, new TypeReference<HashMap<String, Object>>() {
});
} catch (Exception ex) {
LOGGER.error("解析extData发生错误", ex);
// 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return;
}
WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol);
return;
}
WechatUserInfo userInfoInDb =
wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo,
Constants.Channel.WECHAT,protocol);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,protocol);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,protocol);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl =
createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
return;
}
protocol = extDataObj.getOrDefault("protocol", "http:").toString();
LOGGER.info("从微信登录extData中获得协议信息,protocol:{}", protocol);
Long registerFrom = Long.valueOf(extDataObj.getOrDefault("registerFrom", "1").toString());
String redirect = (String) extDataObj.getOrDefault("redirect", "redirect");
LOGGER.info("从微信登录,registerFrom:{}, redirect:{}", registerFrom, redirect);
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, registerFrom,protocol);
return;
}
WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, registerFrom,protocol);
return;
}
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, registerFrom,protocol);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom,protocol);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom,protocol);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant, redirect, schema, registerFrom);
LOGGER.info("Location:[{}]",redirectUrl);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
}
} catch (Exception ex) { } catch (Exception ex) {
LOGGER.error("发生异常", ex); extData = "";
throw ex;
} }
if (StringUtils.isBlank(extData)) {
receiveCodeWithDefault(code, systemKey, schema, registerFrom, redirect, response);
return;
}
LOGGER.info("从微信extdata版本接口进入:{}, extData:{}", schema, extData);
HashMap<String, Object> extDataObj;
try {
extDataObj = JSON.parseObject(extData, new TypeReference<HashMap<String, Object>>(){});
} catch (Exception ex) {
LOGGER.error("解析extData发生错误", ex);
receiveCodeWithDefault(code, systemKey, schema, registerFrom, redirect, response);
return;
}
schema = extDataObj.getOrDefault("protocol", "http:").toString();
LOGGER.info("从微信登录extData中获得协议信息,protocol:{}", schema);
registerFrom = Long.valueOf(extDataObj.getOrDefault("registerFrom", "1").toString());
redirect = (String) extDataObj.getOrDefault("redirect", "redirect");
LOGGER.info("从微信登录,registerFrom:{}, redirect:{}", registerFrom, redirect);
receiveCodeWithDefault(code, systemKey, schema, registerFrom, redirect, response);
} }
/** /**
* 通过redirect_url获取code * 前端微信跳转页面
* * @param code
* @param systemKey
* @param schema
* @param registerFrom
* @param redirect
* @param response * @param response
* @return
*/ */
@RequestMapping("/receiveCode/{key}") private void receiveCodeWithDefault(String code, String systemKey, String schema, Long registerFrom, String redirect, HttpServletResponse response){
public void receiveCodeNoRedirect(String code, @PathVariable(value = "key") String systemKey, HttpServletRequest request, HttpServletResponse response) { /*
String schema = request.getScheme(); * 预处理(容错)
String protocol="http:"; */
LOGGER.info("HTTP协议no redirect:" + schema); registerFrom = Optional.ofNullable(registerFrom).orElse(Constants.Channel.WECHAT);
redirect = Optional.ofNullable(redirect).orElse("");
schema = StringUtils.isBlank(schema) ? getProtocol() : schema;
String domain = userUiDomain;
if(Objects.equals(schema, "https:")){
domain = userUiDomainS;
}
// 从code获取token // 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey); Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code); AccessTokenResponse token = wechatService.getToken(code);
if (token == null) { if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol); redirectNormalUrl(response, merchant, registerFrom,domain);
return; return;
} }
WechatUserInfo userInfo = wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(), token.getOpenId()); WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) { if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url // 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,protocol); redirectNormalUrl(response, merchant, registerFrom, domain);
return; return;
} }
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId()); WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
...@@ -383,113 +242,110 @@ public class WeChatController implements IBaseController { ...@@ -383,113 +242,110 @@ public class WeChatController implements IBaseController {
userInfo.setNickName(nickName); userInfo.setNickName(nickName);
} }
userInfo = wechatService.saveWechatUserInfo(userInfo); userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, Constants.Channel.WECHAT,protocol); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, registerFrom, domain);
return; return;
} }
if (userInfoInDb.getUserId() == null) { if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面 // 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT,protocol); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom, domain);
return; return;
} }
User user = userService.findById(userInfoInDb.getUserId()); User user = userService.findById(userInfoInDb.getUserId());
if (user == null) { if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT,protocol); redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom, domain);
return; return;
} }
// 已经关联了用户 // 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。 // create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT); String redirectUrl = createUserSession(user, merchant, redirect, domain, registerFrom);
LOGGER.info("Location=[{}]", redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(301);
} }
private String createUserSession(User user, Merchant merchant, String redirect, String schema, Long registerFrom) { /**
//String url = "http://passport.xyqb.com"; * 通过redirect_url获取code
String url = "http://"+userDomainStr; *
if ("https:".equals(schema)) { * @param response
url = "https://"+userDomainStr; * @return
*/
@RequestMapping("/receiveCode/{key}")
public void receiveCodeNoRedirect(String code, @PathVariable(value = "key") String systemKey, HttpServletRequest request, HttpServletResponse response) {
Long registerFrom = null;
String redirect = null;
String schema = "http:";
if(Objects.equals("https:", request.getScheme())){
schema = "https:";
} }
receiveCodeWithDefault(code, systemKey, schema, registerFrom, redirect, response);
}
private String createUserSession(User user, Merchant merchant, String redirect, String domain, Long registerFrom) {
if (StringUtils.isEmpty(redirect) || "redirect".equals(redirect)) { if (StringUtils.isEmpty(redirect) || "redirect".equals(redirect)) {
LOGGER.info("微信登录:redirect为null,走正常流程."); LOGGER.info("微信登录:redirect为null,走正常流程.");
if ("baitiao".equals(merchant.getName())) { if ("baitiao".equals(merchant.getName())) {
return loginInWechatWithSessionCreated(user, merchant, "cashTarget5", Constants.Channel.BAITIAO, url, Constants.Channel.WECHAT); return loginInWechatWithSessionCreated(user, merchant, "cashTarget5", Constants.Channel.BAITIAO, domain, Constants.Channel.WECHAT);
} else if ("wechat-pay".equals(merchant.getName())) { } else if ("wechat-pay".equals(merchant.getName())) {
AuthBean authBean = sessionService.createSession(Constants.Channel.WECHAT, registerFrom, "", user, merchant); AuthBean authBean = sessionService.createSession(Constants.Channel.WECHAT, registerFrom, "", user, merchant);
return url + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + "&channelId=" + Constants.Channel.WECHAT + "&key=" + merchant.getName() + "&target=cashTarget5"; return domain + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + "&channelId=" + Constants.Channel.WECHAT + "&key=" + merchant.getName() + "&target=cashTarget5";
} else { } else {
return loginInWechatWithSessionCreated(user, merchant, "cashTarget4", 1L, url, registerFrom); return loginInWechatWithSessionCreated(user, merchant, "cashTarget4", 1L, domain, registerFrom);
} }
} else if ("local".equals(redirect)) { } else if ("local".equals(redirect)) {
LOGGER.info("微信登录:redirect不为null,创建session跳到指定前端页面."); LOGGER.info("微信登录:redirect不为null,创建session跳到指定前端页面.");
AuthBean authBean = sessionService.createSession(Constants.Channel.WECHAT, Constants.Channel.WECHAT, "", user, merchant); AuthBean authBean = sessionService.createSession(Constants.Channel.WECHAT, Constants.Channel.WECHAT, "", user, merchant);
LOGGER.info("微信登录:跳转地址{}", url + "/weixin/callback?phoneNo=" + user.getPhoneNo() + "&token=" + authBean.getToken()); LOGGER.info("微信登录:跳转地址{}", domain + "/weixin/callback?phoneNo=" + user.getPhoneNo() + "&token=" + authBean.getToken());
Long channelId = "baitiao".equals(merchant.getName()) ? 222L : 1L; Long channelId = "baitiao".equals(merchant.getName()) ? 222L : 1L;
String target = "baitiao".equals(merchant.getName()) ? "cashTarget5" : "cashTarget4"; String target = "baitiao".equals(merchant.getName()) ? "cashTarget5" : "cashTarget4";
return url + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + return domain + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom +
"&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target + "&isWechat=true"; "&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target + "&isWechat=true";
} }
return null; return null;
} }
private String loginInWechatWithSessionCreated(User user, Merchant merchant, String target, Long channelId, String domain, Long registerFrom) {
private String loginInWechatWithSessionCreated(User user, Merchant merchant, String target, Long channelId, String url, Long registerFrom) {
AuthBean authBean = sessionService.createSession(channelId, registerFrom, "", user, merchant); AuthBean authBean = sessionService.createSession(channelId, registerFrom, "", user, merchant);
return url + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + "&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target; return domain + "/landing?token=" + authBean.getToken() + "&registerFrom=" + registerFrom + "&channelId=" + channelId + "&key=" + merchant.getName() + "&target=" + target;
} }
private void redirectWechatLoginUrlWithoutLogin(HttpServletResponse response, Merchant merchant, WechatUserInfo userInfo, Long registerFrom,String protocol) { private void redirectWechatLoginUrlWithoutLogin(HttpServletResponse response, Merchant merchant, WechatUserInfo userInfo, Long registerFrom,String domain) {
String redirectUrl = assembleWechatRedirectUrl(merchant, userInfo, registerFrom,protocol); String redirectUrl = assembleWechatRedirectUrl(merchant, userInfo, registerFrom,domain);
LOGGER.info("redirectWechatLoginUrlWithoutLogin redirectUrl:[{}]",redirectUrl); LOGGER.info("redirectWechatLoginUrlWithoutLogin redirectUrl:[{}]",redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(301);
} }
private void redirectNormalUrl(HttpServletResponse response, Merchant merchant, Long registerFrom,String protocol) { private void redirectNormalUrl(HttpServletResponse response, Merchant merchant, Long registerFrom,String domain) {
String redirectUrl = assembleNormalRedirectUrl(merchant, registerFrom,protocol); String redirectUrl = assembleNormalRedirectUrl(merchant, registerFrom,domain);
LOGGER.info("redirectNormalUrl redirectUrl:[{}]",redirectUrl); LOGGER.info("redirectNormalUrl redirectUrl:[{}]",redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(301);
} }
private String assembleNormalRedirectUrl(Merchant merchant, Long registerFrom,String protocol) { private String assembleNormalRedirectUrl(Merchant merchant, Long registerFrom,String domain) {
String domains=userUIAddr;
if(protocol!=null&&protocol.equals("https:")){
domains=userUIAddrS;
}
if ("baitiao".equals(merchant.getName())) { if ("baitiao".equals(merchant.getName())) {
if(registerFrom==58l||registerFrom==198l){ if(registerFrom == 58L || registerFrom == 198L){
return domains + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom="+registerFrom; return domain + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom="+registerFrom;
}else{ }else{
return domains + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom=198"; return domain + "/landing?key=baitiao&target=cashTarget5&channelId=222&registerFrom=198";
} }
} else if ("wechat-pay".equals(merchant.getName())) { } else if ("wechat-pay".equals(merchant.getName())) {
return domains + "/landing?key=wechat-pay&target=cashTarget5&channelId=1&page=landing/4&registerFrom" + registerFrom; return domain + "/landing?key=wechat-pay&target=cashTarget5&channelId=1&page=landing/4&registerFrom=" + registerFrom;
} else { } else {
return domains + "/landing?key=xyqb&target=cashTarget4&channelId=1&registerFrom=" + registerFrom; return domain + "/landing?key=xyqb&target=cashTarget4&channelId=1&registerFrom=" + registerFrom;
} }
} }
private String assembleWechatRedirectUrl(Merchant merchant, WechatUserInfo userInfo, Long registerFrom,String protocol) { private String assembleWechatRedirectUrl(Merchant merchant, WechatUserInfo userInfo, Long registerFrom,String domain) {
String domains=userUIAddr;
if(protocol!=null&&protocol.equals("https:")){
domains=userUIAddrS;
}
if ("baitiao".equals(merchant.getName())) { if ("baitiao".equals(merchant.getName())) {
if(registerFrom==58l||registerFrom==198l){ if(registerFrom == 58L || registerFrom == 198L){
return domain + "/landing?key=baitiao&target=cashTarget5&registerFrom=" + registerFrom + "&channelId=222&isWechat=true&openId=" + userInfo.getOpenId();
return domains + "/landing?key=baitiao&target=cashTarget5&registerFrom=" + registerFrom + "&channelId=222&isWechat=true&openId=" + userInfo.getOpenId();
}else{ }else{
return domains + "/landing?key=baitiao&target=cashTarget5&registerFrom=198&channelId=222&isWechat=true&openId=" + userInfo.getOpenId(); return domain + "/landing?key=baitiao&target=cashTarget5&registerFrom=198&channelId=222&isWechat=true&openId=" + userInfo.getOpenId();
} }
} else if ("wechat-pay".equals(merchant.getName())) { } else if ("wechat-pay".equals(merchant.getName())) {
return domains + "/landing?key=wechat-pay&target=cashTarget5&page=landing/4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId(); return domain + "/landing?key=wechat-pay&target=cashTarget5&page=landing/4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId();
} else { } else {
return domains + "/landing?key=xyqb&target=cashTarget4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId(); return domain + "/landing?key=xyqb&target=cashTarget4&registerFrom= " + registerFrom + "&channelId=1&isWechat=true&openId=" + userInfo.getOpenId();
} }
} }
......
...@@ -2,7 +2,6 @@ package cn.quantgroup.xyqb.controller.internal.sms; ...@@ -2,7 +2,6 @@ package cn.quantgroup.xyqb.controller.internal.sms;
import cn.quantgroup.sms.MsgParams; import cn.quantgroup.sms.MsgParams;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.captcha.CaptchaNewValidator;
import cn.quantgroup.xyqb.aspect.captcha.CaptchaValidator; import cn.quantgroup.xyqb.aspect.captcha.CaptchaValidator;
import cn.quantgroup.xyqb.controller.IBaseController; import cn.quantgroup.xyqb.controller.IBaseController;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
...@@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -201,7 +199,7 @@ public class SmsController implements IBaseController { ...@@ -201,7 +199,7 @@ public class SmsController implements IBaseController {
/** /**
* 快速登陆发送验证码新版 * 快速登陆发送验证码新版
*/ */
@CaptchaNewValidator @CaptchaValidator
@RequestMapping("/send_login_code_voice_new") @RequestMapping("/send_login_code_voice_new")
public JsonResult sendLoginCodeVoiceNew(@RequestParam String phoneNo, @RequestParam(required = false) String registerFrom, public JsonResult sendLoginCodeVoiceNew(@RequestParam String phoneNo, @RequestParam(required = false) String registerFrom,
String usage, @RequestParam(required = false) String deviceId) { String usage, @RequestParam(required = false) String deviceId) {
...@@ -217,7 +215,7 @@ public class SmsController implements IBaseController { ...@@ -217,7 +215,7 @@ public class SmsController implements IBaseController {
/** /**
* 快速登陆发送短信验证码 * 快速登陆发送短信验证码
*/ */
@CaptchaNewValidator @CaptchaValidator
@RequestMapping("/send_login_code_new") @RequestMapping("/send_login_code_new")
public JsonResult sendLoginSmsCodeNew(@RequestParam String phoneNo, @RequestParam(required = false) String registerFrom, @RequestParam(required = false) String deviceId,@RequestParam(required = false,defaultValue = "")String appName) { public JsonResult sendLoginSmsCodeNew(@RequestParam String phoneNo, @RequestParam(required = false) String registerFrom, @RequestParam(required = false) String deviceId,@RequestParam(required = false,defaultValue = "")String appName) {
LOGGER.info("快速登陆-发送验证码, phoneNo:{}, registerFrom:{}", phoneNo, registerFrom); LOGGER.info("快速登陆-发送验证码, phoneNo:{}, registerFrom:{}", phoneNo, registerFrom);
...@@ -226,7 +224,7 @@ public class SmsController implements IBaseController { ...@@ -226,7 +224,7 @@ public class SmsController implements IBaseController {
/** /**
* 快速登陆发送短信验证码 * 快速登陆发送短信验证码
*/ */
@CaptchaNewValidator @CaptchaValidator
@RequestMapping("/send_login_code_new_forH5") @RequestMapping("/send_login_code_new_forH5")
public JsonResult sendLoginSmsCodeNewForH5(@RequestParam String phoneNo, @RequestParam(required = false) String registerFrom, @RequestParam(required = false) String deviceId,@RequestParam(required = false,defaultValue = "")String appName) { public JsonResult sendLoginSmsCodeNewForH5(@RequestParam String phoneNo, @RequestParam(required = false) String registerFrom, @RequestParam(required = false) String deviceId,@RequestParam(required = false,defaultValue = "")String appName) {
LOGGER.info("快速登陆-发送验证码, phoneNo:{}, registerFrom:{}", phoneNo, registerFrom); LOGGER.info("快速登陆-发送验证码, phoneNo:{}, registerFrom:{}", phoneNo, registerFrom);
......
...@@ -77,25 +77,4 @@ public class UserDetailController implements IBaseController { ...@@ -77,25 +77,4 @@ public class UserDetailController implements IBaseController {
} }
} }
/**
* 修复老数据的性别
* @return
*/
@RequestMapping("/fix_user_gender")
public JsonResult fixUserGender() {
String redisLock= "fix_user_gender";
Long ret = stringRedisTemplate.opsForValue().increment(redisLock, 1L);
if (MAX_COUNTER < ret) { //重复提交
return JsonResult.buildSuccessResult("error_multisubmission",null);
}
try {
userDetailService.fixedIdNoAndGender();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
stringRedisTemplate.delete(redisLock);
}
return JsonResult.buildSuccessResult("开始执行",null);
}
} }
...@@ -9,11 +9,13 @@ import cn.quantgroup.xyqb.service.auth.IUserAuthorizedService; ...@@ -9,11 +9,13 @@ import cn.quantgroup.xyqb.service.auth.IUserAuthorizedService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.util.Objects;
/** /**
* @author xufei on 2018/1/5. * @author xufei on 2018/1/5.
...@@ -27,6 +29,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -27,6 +29,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Resource @Resource
private IUserAuthorizedRepository userAuthorizedRepository; private IUserAuthorizedRepository userAuthorizedRepository;
@Cacheable(value = "user_authorized_idno_cache", key = "#idNo", unless = "#result == null", cacheManager = "cacheManager")
@Override @Override
public Boolean hasUserAuthorized(String idNo) { public Boolean hasUserAuthorized(String idNo) {
try { try {
...@@ -35,6 +38,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -35,6 +38,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
} }
} catch (ParseException e) { } catch (ParseException e) {
LOGGER.error("[hasUserAuthorized]参数异常e:{}", e); LOGGER.error("[hasUserAuthorized]参数异常e:{}", e);
return Boolean.FALSE;
} }
UserAuthorized userAuthorized = userAuthorizedRepository.findByIdNo(idNo); UserAuthorized userAuthorized = userAuthorizedRepository.findByIdNo(idNo);
...@@ -62,6 +66,10 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -62,6 +66,10 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
@Override @Override
public UserAuthorized createUserAuthorized(UserAuthorizedParam userAuthorizedParam) { public UserAuthorized createUserAuthorized(UserAuthorizedParam userAuthorizedParam) {
// 数据检查
if(Objects.isNull(userAuthorizedParam) || this.hasUserAuthorized(userAuthorizedParam.getIdNo())){
return null;
}
AuthPattern authPatternEnum = AuthPattern.valueOf(userAuthorizedParam.getAuthPattern()); AuthPattern authPatternEnum = AuthPattern.valueOf(userAuthorizedParam.getAuthPattern());
UserAuthorized userAuthorized = new UserAuthorized(); UserAuthorized userAuthorized = new UserAuthorized();
...@@ -84,6 +92,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService { ...@@ -84,6 +92,7 @@ public class UserAuthorizedServiceImpl implements IUserAuthorizedService {
} }
} }
@Cacheable(value = "user_authorized_uuid_2_id_cache", key = "#userUuid", unless = "#result == null", cacheManager = "cacheManager")
@Override @Override
public String getUserAuthorizedId(String userUuid) { public String getUserAuthorizedId(String userUuid) {
if (StringUtils.isBlank(userUuid)) { if (StringUtils.isBlank(userUuid)) {
......
...@@ -173,6 +173,7 @@ public class HttpServiceImpl implements IHttpService { ...@@ -173,6 +173,7 @@ public class HttpServiceImpl implements IHttpService {
.register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory()) .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
.register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory()) .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory())
.register("easy", httpContext -> new BrowserCompatSpec() { .register("easy", httpContext -> new BrowserCompatSpec() {
@Override
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException { public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
} }
}).build(); }).build();
......
...@@ -32,6 +32,7 @@ public class IPUtil { ...@@ -32,6 +32,7 @@ public class IPUtil {
String jvmTest = System.getProperty("test"); String jvmTest = System.getProperty("test");
if(Boolean.valueOf(jvmTest)){ if(Boolean.valueOf(jvmTest)){
WHITE_ADDRESS.add("192.168."); WHITE_ADDRESS.add("192.168.");
WHITE_ADDRESS.add("10.");
WHITE_ADDRESS.add(LOCAL_ADDRESS); WHITE_ADDRESS.add(LOCAL_ADDRESS);
} }
} }
......
app.id=xyqb-user2 app.id=xyqb-user2
namespace=application,tech.msg.sdk,cash.common,tech.service.urls namespace=application,cash.common,tech.common,tech.sleuth,tech.service.urls,tech.msg.sdk
\ No newline at end of file \ No newline at end of file
security.sessions=if_required
spring.aop.proxy-target-class=true
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
</layout>
</appender>
<logger name="com.atomikos" level="warn"/>
<logger name="org.springframework" level="warn"/>
<logger name="org.hibernate" level="warn"/>
<logger name="org.apache" level="warn"/>
<logger name="ch.qos.logback" level="warn"/>
<logger name="feign" level="debug"/>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
\ No newline at end of file
security.sessions=if_required
spring.aop.proxy-target-class=true
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/quant_group/logs/xyqb_user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/home/quant_group/logs/xyqb_user.log.%d{yyyy-MM-dd}</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
</layout>
</appender>
<logger name="com.atomikos" level="warn"/>
<logger name="org.springframework" level="warn"/>
<logger name="org.hibernate" level="warn"/>
<logger name="org.apache" level="warn"/>
<logger name="ch.qos.logback" level="warn"/>
<root level="info">
<appender-ref ref="FILE"/>
</root>
</configuration>
\ No newline at end of file
security.sessions=if_required
spring.aop.proxy-target-class=true
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/quant_group/logs/xyqb_user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/home/quant_group/logs/xyqb_user.log.%d{yyyy-MM-dd}</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{ISO8601} [%thread] [%-5level] %logger - %msg%n</pattern>
</layout>
</appender>
<logger name="com.atomikos" level="warn"/>
<logger name="org.springframework" level="warn"/>
<logger name="org.hibernate" level="warn"/>
<logger name="org.apache" level="warn"/>
<logger name="ch.qos.logback" level="warn"/>
<root level="info">
<appender-ref ref="FILE"/>
<!-- <appender-ref ref="STDOUT"/>-->
</root>
</configuration>
\ No newline at end of file
configserver.disable=1
configserver.system=xyqb-user
xyqb.data.mysql.jdbc-url=jdbc:mysql://192.168.4.104:3306/xyqb_user?useUnicode=true&characterEncoding=UTF8
xyqb.data.mysql.password=qatest
xyqb.data.mysql.user=qa
xyqb.data.mysql.max-pool-size=20
# CORS
xyqb.filter.allowedOrigin=*
xyqb.filter.allowedHeaders=Origin, No-Cache, x-auth-token, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type,Authorization
xyqb.data.redis.defaultExpiration=3600
# redis
xyqb.redis.master.host=192.168.4.103
xyqb.redis.master.port=6379
xyqb.redis.master.name=
xyqb.redis.sentinel1.host=
xyqb.redis.sentinel1.port=0
xyqb.redis.sentinel2.host=
xyqb.redis.sentinel2.port=0
xyqb.redis.sentinel3.host=
xyqb.redis.sentinel3.port=0
# 短信平台配置
sms.is.debug=1
# LKB client
lkb.client.url=http://192.168.192.251:8082/LKBClient/openapi
lkb.client.user.register.app=/new/register/registerApp.json
lkb.client.user.update=/new/register/updateUser.json
lkb.client.user.push=/user/push.json
# LKB import
lkb.import.url=http://spider.quantgroup.cn
# LKB
lkb.url=http://192.168.192.251:8081/LKB
# xyqb
xyqb.url=http://192.168.192.206:8999
xyqb.api.url=http://192.168.192.206:9004
# 图形验证码
# 是否启用超级验证码 "__SUPERQG__", 用于测试环境自动化测试, 线上环境可忽略此参数
xyqb.auth.captcha.super.enable=1
#首参数校验
xyqb.fplock.limit.byhour=3
xyqb.fplock.limit.byday=5
#sdk
model.quantgroup.url=http://model.quantgroup.cn
xyqb.auth.url=http://192.168.192.206:9001
usersys.url=http://localhost:9001
xyqb-user.ui=http://192.168.12.40:8080
wechat.appid=wxcdf6077af8127559
wechat.secret=16eaec16084d0d9c52d4114f359cc72c
#xyqb-user-域名
xyqb.user.domain=passport.xyqb.com
xyqb.user.query.url=http://userqry.xyqb.com
xyqb.domain = http://192.168.4.153:7003
#马甲包
loanvest.rabbitmq.connection.virtual-host=/loan_order
#loanvest.rabbitmq.stateMsgQueue=loan_vest_msg_queue
loanvest.rabbitmq.queue=loan_user_queue
loanvest.rabbitmq.exchange=loan_vest_exchange
loanvest.rabbitmq.connection.host=192.168.4.46
loanvest.rabbitmq.connection.port=5672
loanvest.rabbitmq.connection.user=qa
loanvest.rabbitmq.connection.password=qatest
#用户注册广播
register.rabbitmq.connection.virtual-host=/user_register
register.rabbitmq.queue=user_register_queue
register.rabbitmq.exchange=user_register_exchange
register.rabbitmq.connection.host=192.168.4.24
register.rabbitmq.connection.port=5672
register.rabbitmq.connection.user=qa
register.rabbitmq.connection.password=qatest
\ No newline at end of file
app.id=xyqb-user2 app.id=xyqb-user2
namespace=application,tech.msg.sdk,cash.common,tech.service.urls namespace=application,tech.msg.sdk,tech.sleuth,tech.common,tech.service.urls,cash.common
\ No newline at end of file \ No newline at end of file
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