Commit bf527954 authored by 技术部-任文超's avatar 技术部-任文超

HttpStatus码统一使用apache的常量类

parent 97b6d969
...@@ -166,8 +166,6 @@ public interface Constants { ...@@ -166,8 +166,6 @@ public interface Constants {
interface Channel { interface Channel {
long BAITIAO = 222L; long BAITIAO = 222L;
// 量化派channnel_code
String LKB_CODE = "0002";
long WECHAT = 198L; long WECHAT = 198L;
long HENGCHANG = 58L; long HENGCHANG = 58L;
} }
......
...@@ -27,7 +27,7 @@ public class ExceptionHandlingController implements IBaseController { ...@@ -27,7 +27,7 @@ public class ExceptionHandlingController implements IBaseController {
private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionHandlingController.class); private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionHandlingController.class);
private static final JsonResult EXCEPTION_RESULT = new JsonResult("internal error", 500L, ""); private static final JsonResult EXCEPTION_RESULT = new JsonResult("internal error", (long)HttpStatus.INTERNAL_SERVER_ERROR.value(), "");
/** /**
* 密码错误次数达到上限异常 * 密码错误次数达到上限异常
...@@ -62,8 +62,8 @@ public class ExceptionHandlingController implements IBaseController { ...@@ -62,8 +62,8 @@ public class ExceptionHandlingController implements IBaseController {
@ExceptionHandler(UserNotExistException.class) @ExceptionHandler(UserNotExistException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseStatus(HttpStatus.UNAUTHORIZED)
public JsonResult userNotExistException(UserNotExistException unee) { public JsonResult userNotExistException(UserNotExistException unee) {
LOGGER.info("throw UserNotExistException,msg={},businessCode={},code={}", unee.getMessage(), 1L, 401L); LOGGER.info("throw UserNotExistException,msg={},businessCode={},code={}", unee.getMessage(), 1L, (long)HttpStatus.UNAUTHORIZED.value());
return new JsonResult(unee.getMessage(), 401L, null); return new JsonResult(unee.getMessage(), (long)HttpStatus.UNAUTHORIZED.value(), null);
} }
/** /**
...@@ -87,8 +87,8 @@ public class ExceptionHandlingController implements IBaseController { ...@@ -87,8 +87,8 @@ public class ExceptionHandlingController implements IBaseController {
@ExceptionHandler(WechatRelateUserException.class) @ExceptionHandler(WechatRelateUserException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseStatus(HttpStatus.UNAUTHORIZED)
public JsonResult wechatRelateUserException(WechatRelateUserException wrue) { public JsonResult wechatRelateUserException(WechatRelateUserException wrue) {
LOGGER.info("throw WechatRelateUserException,msg={},businessCode={},code={}", wrue.getMessage(), 1L, 401L); LOGGER.info("throw WechatRelateUserException,msg={},businessCode={},code={}", wrue.getMessage(), 1L, (long)HttpStatus.UNAUTHORIZED.value());
return new JsonResult(wrue.getMessage(), 401L, null); return new JsonResult(wrue.getMessage(), (long)HttpStatus.UNAUTHORIZED.value(), null);
} }
/** /**
......
...@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; ...@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
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;
import org.apache.http.HttpStatus;
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.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -267,7 +268,7 @@ public class WeChatController implements IBaseController { ...@@ -267,7 +268,7 @@ public class WeChatController implements IBaseController {
// create session, 登进去,该怎么玩怎么玩。 // create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant, redirect, domain, registerFrom); String redirectUrl = createUserSession(user, merchant, redirect, domain, registerFrom);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
} }
@RequestMapping("/redirectForTest") @RequestMapping("/redirectForTest")
...@@ -353,14 +354,14 @@ public class WeChatController implements IBaseController { ...@@ -353,14 +354,14 @@ public class WeChatController implements IBaseController {
String redirectUrl = assembleWechatRedirectUrl(merchant, userInfo, registerFrom, domain); String redirectUrl = assembleWechatRedirectUrl(merchant, userInfo, registerFrom, domain);
log.info("[WeChatController][redirectWechatLoginUrlWithoutLogin]微信授权及跳转:redirectUrl:[{}]", redirectUrl); log.info("[WeChatController][redirectWechatLoginUrlWithoutLogin]微信授权及跳转:redirectUrl:[{}]", redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
} }
private void redirectNormalUrl(HttpServletResponse response, Merchant merchant, Long registerFrom, String domain) { private void redirectNormalUrl(HttpServletResponse response, Merchant merchant, Long registerFrom, String domain) {
String redirectUrl = assembleNormalRedirectUrl(merchant, registerFrom, domain); String redirectUrl = assembleNormalRedirectUrl(merchant, registerFrom, domain);
log.info("[WeChatController][redirectNormalUrl]微信授权及跳转: redirectUrl:[{}]", redirectUrl); log.info("[WeChatController][redirectNormalUrl]微信授权及跳转: redirectUrl:[{}]", redirectUrl);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
} }
private String assembleNormalRedirectUrl(Merchant merchant, Long registerFrom, String domain) { private String assembleNormalRedirectUrl(Merchant merchant, Long registerFrom, String domain) {
...@@ -402,6 +403,6 @@ public class WeChatController implements IBaseController { ...@@ -402,6 +403,6 @@ public class WeChatController implements IBaseController {
} }
redirectUrl = redirectUrl.concat(Joiner.on("&").join(builder.build())); redirectUrl = redirectUrl.concat(Joiner.on("&").join(builder.build()));
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
} }
} }
...@@ -98,7 +98,7 @@ public class UserQueryLogController { ...@@ -98,7 +98,7 @@ public class UserQueryLogController {
PageModel<UserQueryLog> uqp = new PageModel<>(); PageModel<UserQueryLog> uqp = new PageModel<>();
uqp.setTotal(total); uqp.setTotal(total);
if (pageSize == 0 || pageSize < 0) { if (pageSize == 0 || pageSize < 0) {
pageSize = Constants.PAGE_SIZE_MIN; pageSize = Constants.PAGE_SIZE_DEFAULT;
} else if (pageSize > Constants.PAGE_SIZE_MAX) { } else if (pageSize > Constants.PAGE_SIZE_MAX) {
pageSize = Constants.PAGE_SIZE_MAX; pageSize = Constants.PAGE_SIZE_MAX;
} }
...@@ -140,7 +140,7 @@ public class UserQueryLogController { ...@@ -140,7 +140,7 @@ public class UserQueryLogController {
List<UserDetail> userDetails = new ArrayList<>(); List<UserDetail> userDetails = new ArrayList<>();
Page<UserDetail> userDetailPage = null; Page<UserDetail> userDetailPage = null;
if (pageSize == 0 || pageSize < 0) { if (pageSize == 0 || pageSize < 0) {
pageSize = Constants.PAGE_SIZE_MIN; pageSize = Constants.PAGE_SIZE_DEFAULT;
} else if (pageSize > Constants.PAGE_SIZE_MAX) { } else if (pageSize > Constants.PAGE_SIZE_MAX) {
pageSize = Constants.PAGE_SIZE_MAX; pageSize = Constants.PAGE_SIZE_MAX;
} }
......
...@@ -778,9 +778,9 @@ public class InnerController implements IBaseController { ...@@ -778,9 +778,9 @@ public class InnerController implements IBaseController {
} }
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "Nice!", responseContainer = "UserAssociationModel = {Long id, String uuid, String phoneNo, String idNo, String name, String gender, String marryStatus, String educationEnum, String occupationEnum, String qq, Long registerFrom, Long merchantId, List<AddressModel> addressList, List<ContactModel> contactList}"), @ApiResponse(code = HttpStatus.SC_OK, message = "Nice!", responseContainer = "UserAssociationModel = {Long id, String uuid, String phoneNo, String idNo, String name, String gender, String marryStatus, String educationEnum, String occupationEnum, String qq, Long registerFrom, Long merchantId, List<AddressModel> addressList, List<ContactModel> contactList}"),
@ApiResponse(code = 400, message = "Invalid params supplied", response = cn.quantgroup.xyqb.model.ApiResponse.class), @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = "Invalid params supplied", response = cn.quantgroup.xyqb.model.ApiResponse.class),
@ApiResponse(code = 404, message = "User not found", response = cn.quantgroup.xyqb.model.ApiResponse.class) @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = "User not found", response = cn.quantgroup.xyqb.model.ApiResponse.class)
}) })
@ApiOperation(notes = "用户全量信息查询接口", value = "用户全量信息查询接口", nickname = "findUserAssociationModel") @ApiOperation(notes = "用户全量信息查询接口", value = "用户全量信息查询接口", nickname = "findUserAssociationModel")
@RequestMapping(path = "/user-association/search/userId", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(path = "/user-association/search/userId", method = {RequestMethod.GET, RequestMethod.POST})
......
...@@ -6,6 +6,7 @@ import cn.quantgroup.xyqb.model.session.SessionStruct; ...@@ -6,6 +6,7 @@ import cn.quantgroup.xyqb.model.session.SessionStruct;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.session.XyqbSessionContextHolder; import cn.quantgroup.xyqb.session.XyqbSessionContextHolder;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
...@@ -49,7 +50,7 @@ public class RequestFilter implements Filter { ...@@ -49,7 +50,7 @@ public class RequestFilter implements Filter {
SessionStruct sessionStruct = XyqbSessionContextHolder.getXSessionFromRedis(); SessionStruct sessionStruct = XyqbSessionContextHolder.getXSessionFromRedis();
if (Objects.isNull(sessionStruct)) { if (Objects.isNull(sessionStruct)) {
/* 如果没有获取到session信息则返回错误信息 */ /* 如果没有获取到session信息则返回错误信息 */
response.setStatus(401); response.setStatus(HttpStatus.SC_UNAUTHORIZED);
response.setHeader("Content-Type", "application/json;charset=utf-8"); response.setHeader("Content-Type", "application/json;charset=utf-8");
PrintWriter writer = response.getWriter(); PrintWriter writer = response.getWriter();
writer.print(UNAUTH_RESULT); writer.print(UNAUTH_RESULT);
......
...@@ -8,8 +8,6 @@ import cn.quantgroup.xyqb.util.PasswordUtil; ...@@ -8,8 +8,6 @@ import cn.quantgroup.xyqb.util.PasswordUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
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.Service; import org.springframework.stereotype.Service;
...@@ -26,9 +24,8 @@ import java.util.Optional; ...@@ -26,9 +24,8 @@ import java.util.Optional;
@Slf4j @Slf4j
public class LkbUserviceImpl implements ILkbUserService { public class LkbUserviceImpl implements ILkbUserService {
private static final Logger LOGGER = LoggerFactory.getLogger(LkbUserviceImpl.class);
private static final String TOKEN_PATTERN = "timeunit=%sappkey=lkb010203#$%%"; private static final String TOKEN_PATTERN = "timeunit=%sappkey=lkb010203#$%%";
private static final String LKB_CODE = "0002";
@Autowired @Autowired
private IHttpService httpService; private IHttpService httpService;
...@@ -41,7 +38,7 @@ public class LkbUserviceImpl implements ILkbUserService { ...@@ -41,7 +38,7 @@ public class LkbUserviceImpl implements ILkbUserService {
String timeunit = System.currentTimeMillis() + ""; String timeunit = System.currentTimeMillis() + "";
String token = PasswordUtil.MD5(String.format(TOKEN_PATTERN, timeunit)); String token = PasswordUtil.MD5(String.format(TOKEN_PATTERN, timeunit));
Map<String, String> parameters = Maps.newHashMap(); Map<String, String> parameters = Maps.newHashMap();
parameters.put("appId", Constants.Channel.LKB_CODE); parameters.put("appId", LKB_CODE);
parameters.put("timeunit", timeunit); parameters.put("timeunit", timeunit);
parameters.put("token", token); parameters.put("token", token);
parameters.put("userId", uuid); parameters.put("userId", uuid);
...@@ -55,7 +52,7 @@ public class LkbUserviceImpl implements ILkbUserService { ...@@ -55,7 +52,7 @@ public class LkbUserviceImpl implements ILkbUserService {
String response = httpService.post(clientUrl + "/user/push.json", parameters); String response = httpService.post(clientUrl + "/user/push.json", parameters);
Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class); Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class);
if (!resultOptional.isPresent() || !Constants.SUCCESS_CODE.equals(resultOptional.get().get(Constants.RESULT_CODE))) { if (!resultOptional.isPresent() || !Constants.SUCCESS_CODE.equals(resultOptional.get().get(Constants.RESULT_CODE))) {
LOGGER.error("[lkb_user_push]向LKB同步用户失败,phoneNo:{},response={}", phoneNo, response); log.error("[lkb_user_push]向LKB同步用户失败,phoneNo:{},response={}", phoneNo, response);
return false; return false;
} }
return true; return true;
......
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