tao.mo

common-dependencies、biz-customer | 修改 | 国际化文件配置调整

mt
2024年11月11日18:11:23
Showing 32 changed files with 202 additions and 265 deletions
......@@ -3,6 +3,7 @@ package com.fedex.connect.customer.controller.base;
import com.fedex.connect.common.dependencies.common.BasicController;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.service.biz.*;
import com.fedex.connect.customer.validate.controller.biz.AttachmentValidate;
......@@ -23,6 +24,9 @@ public class BaseController extends BasicController {
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected ResponseUtils responseUtils;
@Autowired
protected IConsignmentService consignmentService;
@Autowired
......
......@@ -7,7 +7,6 @@ import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IConsignmentController;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
......@@ -26,12 +25,9 @@ public class ConsignmentController extends BaseController implements IConsignmen
@Override
@PostMapping("/add")
@ApiOperation(value = "ResponseVo", notes = "上传运单")
@OperationMethodLog(describe = "con_add_oper")
@OperationMethodLog(describe = "business_log_20001")
public ResponseVo addConsignment(@RequestBody ConsignmentBo bo){
ResponseVo responseResultVo = consignmentValidate.preCheckAdd(bo);
if (responseResultVo != null){
return responseResultVo;
}
consignmentValidate.preCheckAdd(bo);
/**
* 获取当前用户信息
*/
......@@ -42,7 +38,7 @@ public class ConsignmentController extends BaseController implements IConsignmen
@Override
@PostMapping("/submit")
@ApiOperation(value = "ResponseVo", notes = "运单提交")
@OperationMethodLog(describe = "con_submit_oper")
@OperationMethodLog(describe = "business_log_20002")
public ResponseVo submitConsignment(@RequestParam("fileUpload") MultipartFile[] files,
@RequestParam("consignmentJson") String consignmentJson) {
ConsignmentBo consignmentBo = JSONObject.parseObject(consignmentJson,ConsignmentBo.class);
......
......@@ -7,11 +7,18 @@ package com.fedex.connect.customer.enums;
*/
public enum ResponseCode {
//********************biz_customer模块
MESSAGE_CODE_30001(30001,"business_exception_30001"),
MESSAGE_CODE_30002(30002,"business_exception_30002"),
MESSAGE_CODE_30003(30003,"business_exception_30003"),
MESSAGE_CODE_30004(30004,"business_exception_30004"),
MESSAGE_CODE_30005(30005,"business_exception_30005"),
MESSAGE_CODE_30006(30006,"business_exception_30006"),
/******打个样,编写样例*****/
MESSAGE_CODE_10001(10001,"business_exception_10001"),
// MESSAGE_CODE_10002(10002,"business_success_10002"),
// MESSAGE_CODE_10003(10003,"system_exception_10003"),
// MESSAGE_CODE_10004(10004,"system_success_10004"),
// MESSAGE_CODE_30001(30001,"business_exception_30001"),
// MESSAGE_CODE_30002(30002,"business_success_30002"),
// MESSAGE_CODE_30003(30003,"system_exception_30003"),
// MESSAGE_CODE_30004(30004,"system_success_30004"),
// MESSAGE_CODE_30005(30005,"business_log_30005"),
;
private Integer code;
private String msg;
......
package com.fedex.connect.customer.service.base;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.customer.repository.repo.IAttachmentRepository;
import com.fedex.connect.customer.repository.repo.IConsignmentRepository;
import com.fedex.connect.customer.repository.repo.IUploadRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
public class BaseService {
@Resource
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected ResponseUtils responseUtils;
@Autowired
protected IConsignmentRepository consignmentRepository;
......
......@@ -24,6 +24,6 @@ public class AttachmentQueryServiceImpl extends BaseService implements IAttachme
*/
public ResponseVo queryInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){
Attachment attachment = attachmentRepository.queryInfo(userConsignmentInfoQuery);
return ResponseVo.succ(attachment);
return responseUtils.success(attachment);
}
}
\ No newline at end of file
......
......@@ -8,6 +8,7 @@ import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.customer.data.dto.FindConsignmentsDto;
import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
import com.fedex.connect.customer.data.query.ConsignmentQuery;
import com.fedex.connect.customer.enums.ResponseCode;
import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IConsignmentQueryService;
import org.springframework.stereotype.Service;
......@@ -32,7 +33,7 @@ public class ConsignmentQueryServiceImpl extends BaseService implements IConsign
public ResponseVo findConsignments(ConsignmentQuery query) {
List<String> consignmentCodeList = query.getConsignmentCodeList();
if (Utils.isNotEmpty(consignmentCodeList) && consignmentCodeList.size() > GlobalConstantFedex.DECLARE_COUNT) {
return ResponseVo.fail(localeMessageUtil.getMessage("conl_cus_declare_count_max"));
responseUtils.fail(ResponseCode.MESSAGE_CODE_30002);
}
//查询数量
......@@ -46,7 +47,7 @@ public class ConsignmentQueryServiceImpl extends BaseService implements IConsign
List<FindConsignmentsDto> consignments = consignmentRepository.findConsignments(query);
pageResult.setList(consignments);
}
return ResponseVo.succ(pageResult);
return responseUtils.success(pageResult);
}
/**
......@@ -69,6 +70,6 @@ public class ConsignmentQueryServiceImpl extends BaseService implements IConsign
consignmentTemp.setDestinationCountry(consignment.getDestinationCountry());
consignment = consignmentTemp;
}
return ResponseVo.succ(consignment);
return responseUtils.success(consignment);
}
}
......
package com.fedex.connect.customer.service.biz.impl;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
......@@ -22,6 +23,9 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
@Autowired
private ConsignmentUtil consignmentUtil;
@Autowired
private ResponseUtils responseUtils;
/**
* @Author Szl
* @Description 功能说明 新增运单
......@@ -35,18 +39,13 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
Consignment consignment = consignmentRepository.findByConsignmentCode(bo.getConsignmentCode());
if (consignment != null && consignment.getId() != null){
//如果存在则进行bo基础校验
ResponseVo responseResultVo = consignmentUtil.consignmentCreatorCheck(consignment,bo);
if (responseResultVo != null){
return responseResultVo;
}
consignmentUtil.consignmentCreatorCheck(consignment,bo);
//校验是否是本账号的运单
ResponseVo responseVo = consignmentUtil.consignmentUuidCheck(consignment, user);
if (responseVo != null){
return responseVo;
}
return responseVo;
}
//如果不存在直接返回
return ResponseVo.succ(null);
return responseUtils.success();
}
/**
......
......@@ -44,6 +44,6 @@ public class UploadRecordServiceImpl extends BaseService implements IUploadRecor
PageResult pageResult = new PageResult();
pageResult.setList(history != null ? history : Collections.emptyList());
return ResponseVo.succ(pageResult);
return responseUtils.success(pageResult);
}
}
......
......@@ -4,6 +4,7 @@ import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
......@@ -25,6 +26,10 @@ import java.util.Objects;
public class ConsignmentUtil {
@Autowired
private LocaleMessageUtil localeMessageUtil;
@Autowired
ResponseUtils responseUtils;
/**
* @Author Szl
* @Description 功能说明 校验运单创建人
......@@ -32,21 +37,19 @@ public class ConsignmentUtil {
* @param consignment
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
public ResponseVo consignmentCreatorCheck(Consignment consignment, ConsignmentBo bo) {
public void consignmentCreatorCheck(Consignment consignment, ConsignmentBo bo) {
List<String> errList = new ArrayList<>();
// 校验字段是否匹配,并将错误信息添加到errList中
checkFieldMismatch(bo.getShipperAccount(), consignment.getShipperAccount(), "con_shipperAccount", errList);
checkFieldMismatch(bo.getShipperAccount(), consignment.getShipperAccount(), ResponseCode.MESSAGE_CODE_30006.getMsg(), errList);
//checkFieldMismatch(bo.getRecipientCountry(), consignment.getRecipientCountry(), "con_recipientCountry", errList);
//checkFieldMismatch(bo.getShipperCountry(), consignment.getShipperCountry(), "con_shipperCountry", errList);
if (!errList.isEmpty()) {
String enumResCode601 = localeMessageUtil.getMessage("enum_res_code_601");
String errResult = String.join(",", errList) + enumResCode601;
return ResponseVo.fail(BaseResponseCode.CONSIGNMENT_CREATOR_ERR, errResult);
String enumResCode = localeMessageUtil.getMessage(ResponseCode.MESSAGE_CODE_30003.getMsg());
String errResult = String.join(",", errList) + enumResCode;
responseUtils.fail(ResponseCode.MESSAGE_CODE_30003,errResult);
}
return null;
}
/**
......@@ -80,12 +83,12 @@ public class ConsignmentUtil {
if (!Objects.equals(consignment.getUserUuid(), user.getUserUuid())){
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO);
if (Objects.equals(consignment.getShipperAccount(),user.getAccountNo())){
return ResponseVo.succ(BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC.getCode(), BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC.getMsg(),consignmentAddDto);
return responseUtils.success(ResponseCode.MESSAGE_CODE_30004,consignmentAddDto);
}else {
return ResponseVo.succ(BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC.getCode(), BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC.getMsg(),consignmentAddDto);
return responseUtils.success(ResponseCode.MESSAGE_CODE_30005,consignmentAddDto);
}
}else {
return ResponseVo.succ(consignmentAddDto);
return responseUtils.success(consignmentAddDto);
}
}
}
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.customer.enums.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -17,6 +16,8 @@ import java.util.Objects;
@Component
public class ConsignmentInfoValidate {
@Autowired
protected ResponseUtils responseUtils;
@Autowired
protected LocaleMessageUtil localeMessageUtil;
/**
......@@ -28,8 +29,7 @@ public class ConsignmentInfoValidate {
*/
public void validateConsignmentId(Long consignmentId){
if (Objects.isNull(consignmentId)){
ResponseVo rsVo = ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.REQUEST_PARAM_NULL.getMsg()));
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg());
responseUtils.fail(ResponseCode.MESSAGE_CODE_30001);
}
}
}
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.BaseValidateUtils;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.enums.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,6 +20,8 @@ import java.util.Objects;
@Component
public class ConsignmentValidate {
@Autowired
protected ResponseUtils responseUtils;
@Autowired
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected BaseValidateUtils baseValidateUtils;
......@@ -33,13 +33,12 @@ public class ConsignmentValidate {
* @param bo
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
public ResponseVo preCheckAdd(ConsignmentBo bo){
public void preCheckAdd(ConsignmentBo bo){
if (bo == null || StringUtils.isEmpty(bo.getConsignmentCode()) ||
StringUtils.isEmpty(bo.getOriginCountryCode()) || StringUtils.isEmpty(bo.getShipperAccount()) ||
StringUtils.isEmpty(bo.getDestinationCountryCode())){
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.REQUEST_PARAM_NULL.getMsg()));
responseUtils.fail(ResponseCode.MESSAGE_CODE_30001);
}
return null;
}
/**
......@@ -51,10 +50,10 @@ public class ConsignmentValidate {
* @return void
*/
public void validateConsignmentSubmit(MultipartFile[] files,ConsignmentBo consignmentBo){
Integer code = ResponseCode.MESSAGE_CODE_10001.getCode();
String msg = ResponseCode.MESSAGE_CODE_10001.getMsg();
Integer code = ResponseCode.MESSAGE_CODE_30001.getCode();
String msg = ResponseCode.MESSAGE_CODE_30001.getMsg();
if(Objects.isNull(files)){
throw new OpErrorException(code,msg);
responseUtils.fail(ResponseCode.MESSAGE_CODE_30001);
}
/**
* 非空字段校验
......
#******************系统操作日志记录,中文展示******************
con_add_oper=添加运单
con_submit_oper=提交运单
config_aspect_length_error=提示信息过长,未保存成功
business_log_20001=添加运单
business_log_20002=提交运单
system_exception_20003=提示信息过长,未保存成功
#******************鉴权相关提示,需要做国际化******************
#authentication包
auth_exc_no_auth=没有访问权限
auth_exc_no_pass_auth=没有通过权限认证
auth_filter_user_error=登录身份异常
auth_filter_timeout=登录超过8小时,请重新登录
auth_filter_stale_dated=登录已过期
enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
system_exception_10001=没有访问权限
system_exception_10002=没有通过权限认证
system_exception_10003=登录身份异常
system_exception_10004=登录超过8小时,请重新登录
system_exception_10005=登录已过期
system_exception_10006=登录已过期,请重新登录
#******************业务相关、需要做国际化******************
con_shipperAccount=发货人计费账号
con_shipperCountry=始发国
con_recipientCountry=目的国
enum_res_code_601=不正确,请重新输入
enum_res_code_602=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
enum_res_code_603=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
conl_cus_declare_count_max=單次最多可查詢1000個運單號碼
business_exception_10001=必填字段未填写
\ No newline at end of file
business_exception_30001=必填字段未填写
business_exception_30002=单次最多可查询1000个运单号码
business_exception_30003=不正确,请重新输入
business_exception_30004=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30005=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30006=发货人计费账号
\ No newline at end of file
......
#******************系统操作日志记录,中文展示******************
con_add_oper=添加运单
con_submit_oper=提交运单
config_aspect_length_error=提示信息过长,未保存成功
business_exception_20001=添加运单
business_exception_20002=提交运单
system_exception_20003=提示信息过长,未保存成功
#******************鉴权相关提示,需要做国际化******************
#authentication包
auth_exc_no_auth=没有访问权限
auth_exc_no_pass_auth=没有通过权限认证
auth_filter_user_error=登录身份异常
auth_filter_timeout=登录超过8小时,请重新登录
auth_filter_stale_dated=登录已过期
enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
system_exception_10001=没有访问权限
system_exception_10002=没有通过权限认证
system_exception_10003=登录身份异常
system_exception_10004=登录超过8小时,请重新登录
system_exception_10005=登录已过期
system_exception_10006=登录已过期,请重新登录
#******************业务相关、需要做国际化******************
con_shipperAccount=发货人计费账号
con_shipperCountry=始发国
con_recipientCountry=目的国
enum_res_code_601=不正确,请重新输入
enum_res_code_602=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
enum_res_code_603=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
conl_cus_declare_count_max=單次最多可查詢1000個運單號碼
business_exception_10001=必填字段未填写
\ No newline at end of file
business_exception_30001=必填字段未填写
business_exception_30002=单次最多可查询1000个运单号码
business_exception_30003=不正确,请重新输入
business_exception_30004=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30005=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30006=发货人计费账号
\ No newline at end of file
......
......@@ -3,6 +3,7 @@ package com.fedex.connect.common.dependencies.aspect;
import com.fedex.connect.common.dependencies.annotation.OperationMethodLog;
import com.fedex.connect.common.dependencies.contants.AnnotationConstants;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.repository.repo.log.IOperationRepository;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
......@@ -148,7 +149,7 @@ public class OperationLogAspect {
r.remove("data");
resultJson = JsonUtils.objectToJson(r);
if (resultJson.length() > 255){
r.put("msg", localeMessageUtil.getMessage("config_aspect_length_error"));
r.put("msg", localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_20003.getMsg()));
resultJson = JsonUtils.objectToJson(r);
}
}
......
package com.fedex.connect.common.dependencies.authentication.exception;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.SpringBeanUtil;
import com.google.gson.Gson;
......@@ -28,7 +29,7 @@ public class JwtAccessDeniedHandler implements AccessDeniedHandler {
result.setCode(HttpServletResponse.SC_FORBIDDEN);
//使用context手动注入
LocaleMessageUtil localeMessageUtil = SpringBeanUtil.getBean(LocaleMessageUtil.class);
result.setMsg(localeMessageUtil.getMessage("auth_exc_no_auth"));
result.setMsg(localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10001.getMsg()));
Gson gson = new Gson();
response.getWriter().println(gson.toJson(result));
response.getWriter().flush();
......
......@@ -2,6 +2,7 @@ package com.fedex.connect.common.dependencies.authentication.exception;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.SpringBeanUtil;
import com.google.gson.Gson;
......@@ -30,7 +31,7 @@ public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
result.setCode(HttpServletResponse.SC_UNAUTHORIZED);
//使用context手动注入
LocaleMessageUtil localeMessageUtil = SpringBeanUtil.getBean(LocaleMessageUtil.class);
result.setMsg(localeMessageUtil.getMessage("auth_exc_no_pass_auth"));
result.setMsg(localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10002.getMsg()));
Gson gson = new Gson();
response.getWriter().println(gson.toJson(result));
response.getWriter().flush();
......
......@@ -2,6 +2,7 @@ package com.fedex.connect.common.dependencies.authentication.filter;
import com.fedex.connect.common.dependencies.authentication.SecurityConstants;
import com.fedex.connect.common.dependencies.contants.RedisConstants;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.service.sys.IRedisSlabService;
import com.fedex.connect.common.dependencies.util.JsonUtils;
......@@ -72,10 +73,6 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
//使用context手动注入
LocaleMessageUtil localeMessageUtil = SpringBeanUtil.getBean(LocaleMessageUtil.class);
IRedisSlabService redisSlabService = SpringBeanUtil.getBean(IRedisSlabService.class);
String str = localeMessageUtil.getMessage("auth_filter_user_error");
System.out.println(str);
if (token == null || !token.startsWith(SecurityConstants.TOKEN_PREFIX)) {
SecurityContextHolder.clearContext();
......@@ -90,9 +87,9 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
}
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_user_error"));
logger.info("CODE_301 requestURL:{} ,reason:{}" , request.getRequestURL()," 非白名单url路径登录");
result.put("code", BaseResponseCode.MESSAGE_CODE_10003.getCode());
result.put("msg", localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10003.getMsg()));
logger.info("CODE : {} requestURL:{} ,reason:{}", BaseResponseCode.MESSAGE_CODE_10003.getCode() , request.getRequestURL()," 非白名单url路径登录");
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
......@@ -114,9 +111,9 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
if (StringUtils.isEmpty(tokenRedis)) {
//redis没有,超过8小时,踢出去
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_timeout"));
logger.info("CODE_301 requestURL:{} ,reason:{}" , request.getRequestURL() ,"tokenRedis is empty");
result.put("code", BaseResponseCode.MESSAGE_CODE_10004.getCode());
result.put("msg", localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10004.getMsg()));
logger.info("CODE : {} requestURL:{} ,reason:{}", BaseResponseCode.MESSAGE_CODE_10004.getCode() , request.getRequestURL() ,"tokenRedis is empty");
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
......@@ -132,12 +129,12 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
response.setHeader("Token", newToken);*/
} catch (ExpiredJwtException ee) {
//已经过期了,直接踢
logger.error("CODE_301 requestURL:{},reason:{}" , request.getRequestURL(),"ExpiredJwtException ",ee);
logger.error("CODE : {} requestURL:{},reason:{}",BaseResponseCode.MESSAGE_CODE_10004.getCode() , request.getRequestURL(),"ExpiredJwtException ",ee);
Claims claims = ee.getClaims();
String id = claims.getId();
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_stale_dated"));
result.put("code", BaseResponseCode.MESSAGE_CODE_10005.getCode());
result.put("msg", localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10005.getMsg()));
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
......@@ -145,8 +142,8 @@ public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
} catch (Exception e) {
logger.error("*********************token 异常 : *******************************", e);
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_user_error"));
result.put("code", BaseResponseCode.MESSAGE_CODE_10003.getCode());
result.put("msg", localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10003.getMsg()));
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
......
......@@ -17,10 +17,10 @@ public class BasicController {
try {
user = CurrentUserInfo.getUser();
} catch (Exception e) {
throw new OpErrorException(BaseResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(BaseResponseCode.TOKEN_FORMAT_ERROR.getMsg()),e);
throw new OpErrorException(BaseResponseCode.MESSAGE_CODE_10003.getCode(),localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10003.getMsg()),e);
}
if (user == null) {
throw new OpErrorException(BaseResponseCode.OVERDUE_TOKEN_CODE.getCode(),localeMessageUtil.getMessage(BaseResponseCode.OVERDUE_TOKEN_CODE.getMsg()));
throw new OpErrorException(BaseResponseCode.MESSAGE_CODE_10006.getCode(),localeMessageUtil.getMessage(BaseResponseCode.MESSAGE_CODE_10006.getMsg()));
}
return user;
}
......
......@@ -41,10 +41,10 @@ public class ResponseVo<T> {
this.data = null;
}
public ResponseVo(String code,String message){
public ResponseVo(Integer code,String message,T data){
this.success = true;
this.code = DigitConstants.DIGIT_TWO_HUNDRED;
this.code = code;
this.msg = message;
this.data = null;
this.data = data;
}
}
}
\ No newline at end of file
......
......@@ -6,56 +6,13 @@ package com.fedex.connect.common.dependencies.enums;
*/
public enum BaseResponseCode {
/**
* 200=操作成功
* 201=操作失败
* 202=API接口请求异常
* 203=后台程序发生异常
* 204=请求方式错误
* 205=api接口请求错误
* 206=api接口请求结果为空
* 207=系统异常!
*
* 301=登录身份异常
* 302=登录已过期
* 303=用户不存在
* 304=用户已禁用,不能登录!
* 305=登录token过期,请重新登录!
* 306=该角色下有用户存在,是否确认删除?
*
* 601=数据被占用
* 602=记录已存在,请勿重复添加
* 603=导出数据量过大,请不要超过10W条
*
* 604=请求参数为空
* 605=ID为空
* 606=数据不存在
* 607=请求参数值不合理
*/
SUCCESS_CODE(200,"enum_res_code_200"),
FAIL_CODE(201,"enum_res_code_201"),
API_EXCEPTION(202, "enum_res_code_202"),
PROGRAM_ERROR(203,"enum_res_code_203"),
METHOD_EXCEPTION_CODE(204, "enum_res_code_204"),
HTTP_CLIENT_ERROR(205, "enum_res_code_205"),
HTTP_CLIENT_EMPTY(206, "enum_res_code_206"),
SYSTEM_EXECEPTION_CODE(207,"enum_res_code_207"),
TOKEN_FORMAT_ERROR(301, "enum_res_code_301"),
TOKEN_EXPIRE(302, "enum_res_code_302"),
USER_IS_NULL(303, "enum_res_code_303"),
USER_DISABLED(304, "enum_res_code_304"),
OVERDUE_TOKEN_CODE(305,"enum_res_code_305"),
ROLE_CONFIRM_DEL(306, "enum_res_code_306"),
REQUEST_PARAM_NULL(604, "enum_res_code_604"),
REQUEST_ID_NULL(605, "enum_res_code_605"),
REQUEST_OBJECT_NULL(606, "enum_res_code_606"),
REQUEST_PARAM_UNREASONABLE(606, "enum_res_code_607"),
CONSIGNMENT_CREATOR_ERR(601,"enum_res_code_601"),
CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC(602,"enum_res_code_602"),
CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC(603,"enum_res_code_603"),
MESSAGE_CODE_20003(20003,"system_exception_20003"),
MESSAGE_CODE_10001(10001,"system_exception_10001"),
MESSAGE_CODE_10002(10002,"system_exception_10002"),
MESSAGE_CODE_10003(10003,"system_exception_10003"),
MESSAGE_CODE_10004(10004,"system_exception_10004"),
MESSAGE_CODE_10005(10005,"system_exception_10005"),
MESSAGE_CODE_10006(10006,"system_exception_10006"),
;
private Integer code;
private String msg;
......@@ -69,9 +26,7 @@ public enum BaseResponseCode {
return code;
}
public String getMsg() {
return msg;
}
}
}
\ No newline at end of file
......
package com.fedex.connect.common.dependencies.enums.biz;
public enum ConsignmentEnum {
SHIPPER_ACCOUNT(01,"con_shipperAccount"),
SHIPPER_COUNTRY(02,"con_shipperCountry"),
RECIPIENT_COUNTRY(03,"con_recipientCountry"),
;
private Integer code;
private String msg;
ConsignmentEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
......@@ -6,7 +6,6 @@ import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -28,13 +27,19 @@ public class ResponseUtils {
* @param codeEnum
* @return void
*/
public void fail(T codeEnum) {
public void fail(Object codeEnum) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum);
log.error(responseCodeBo.getErrMsg());
throw new OpErrorException(responseCodeBo.getCode(), responseCodeBo.getErrMsg());
}
public void fail(T codeEnum,Throwable e) {
public void fail(Object codeEnum,String errMsg) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum);
log.error(errMsg);
throw new OpErrorException(responseCodeBo.getCode(), errMsg);
}
public void fail(Object codeEnum,Throwable e) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum);
log.error(responseCodeBo.getErrMsg());
throw new OpErrorException(responseCodeBo.getCode(), responseCodeBo.getErrMsg(),e);
......@@ -44,7 +49,12 @@ public class ResponseUtils {
return new ResponseVo<>();
}
public ResponseVo success(T data) {
public <T> ResponseVo success(Object codeEnum,T data) {
ResponseCodeBo responseCodeBo = this.ref(codeEnum);
return new ResponseVo<>(responseCodeBo.getCode(),responseCodeBo.getMsg(),data);
}
public <T> ResponseVo success(T data) {
return new ResponseVo<>(data);
}
......@@ -53,7 +63,7 @@ public class ResponseUtils {
return message;
}
private ResponseCodeBo ref(T obj){
private ResponseCodeBo ref(Object obj){
ResponseCodeBo responseCodeBo = new ResponseCodeBo();
try {
Object codeObj = AssignmentFieldUtils.getFieldValue(obj, BaseConstants.RESPONSE_CODE_KEYS.CODE);
......
#******************系统操作日志记录,中文展示******************
config_aspect_length_error=提示信息过长,未保存成功
#******************鉴权相关提示,需要做国际化******************
#authentication包
auth_exc_no_auth=没有访问权限
auth_exc_no_pass_auth=没有通过权限认证
auth_filter_user_error=登录身份异常
auth_filter_timeout=登录超过8小时,请重新登录
auth_filter_stale_dated=登录已过期
enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
system_exception_10001=没有访问权限
system_exception_10002=没有通过权限认证
system_exception_10003=登录身份异常
system_exception_10004=登录超过8小时,请重新登录
system_exception_10005=登录已过期
system_exception_10006=登录身份异常
system_exception_10007=登录已过期,请重新登录
\ No newline at end of file
......
#******************系统操作日志记录,中文展示******************
config_aspect_length_error=提示信息过长,未保存成功
#******************鉴权相关提示,需要做国际化******************
#authentication包
auth_exc_no_auth=没有访问权限
auth_exc_no_pass_auth=没有通过权限认证
auth_filter_user_error=登录身份异常
auth_filter_timeout=登录超过8小时,请重新登录
auth_filter_stale_dated=登录已过期
enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
\ No newline at end of file
system_exception_10001=没有访问权限
system_exception_10002=没有通过权限认证
system_exception_10003=登录身份异常
system_exception_10004=登录超过8小时,请重新登录
system_exception_10005=登录已过期
system_exception_10006=登录身份异常
system_exception_10007=登录已过期,请重新登录
\ No newline at end of file
......
......@@ -3,6 +3,7 @@ package com.fedex.connect.manager.controller.base;
import com.fedex.connect.common.dependencies.common.BasicController;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.config.PropertiesConfig;
import com.fedex.connect.manager.service.bi.IDicEntriesService;
......@@ -20,6 +21,8 @@ public class BaseController extends BasicController {
@Resource
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected ResponseUtils responseUtils;
@Autowired
protected PropertiesConfig propertiesConfig;
@Autowired
protected ISysUserService sysUserService;
......
......@@ -15,6 +15,7 @@ import com.fedex.connect.manager.controller.sys.ISysAuthController;
import com.fedex.connect.manager.data.dto.LogLoginDto;
import com.fedex.connect.manager.data.dto.LoginRequest;
import com.fedex.connect.manager.data.dto.SysUserDto;
import com.fedex.connect.manager.enums.ResponseCode;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -50,7 +51,7 @@ public class SysAuthController extends BaseController implements ISysAuthControl
@PostMapping("/init")
@ApiOperation(value = "ResponseVo", notes = "初始化进入首页获取FCL登录地址")
public ResponseVo init(){
return ResponseVo.succ(fclIndexLoginUrl);
return responseUtils.success(fclIndexLoginUrl);
}
......@@ -148,7 +149,7 @@ public class SysAuthController extends BaseController implements ISysAuthControl
DictionaryEntries dicUserLoginType = cacheSystem.getDicUserLoginType(UserLoginTypeEnum.FCLLOGINREGISTRATION.getEnMsg());
//记录日志
LogLoginDto dto = new LogLoginDto(loginUser.getId(), dicUserLoginType.getId(),
localeMessageUtil.getMessage("auth_login_desc"));
localeMessageUtil.getMessage(ResponseCode.MESSAGE_CODE_40002.getMsg()));
logLoginService.saveLoginLog(dto);
try{
......
package com.fedex.connect.manager.data.dto;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.util.Utils;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
......@@ -22,24 +19,6 @@ public class LoginRequest implements Serializable {
}
/**
* 验证用户登录信息
* @param dto
* @return
*/
public static ResponseVo validate(LoginRequest dto){
if (dto == null){
ResponseVo.fail(BaseResponseCode.REQUEST_PARAM_NULL.getMsg());
}
if (StringUtils.isBlank(dto.getAccNo())){
ResponseVo.fail("auth_login_accno_null");
}
if (StringUtils.isBlank(dto.getPassword())){
ResponseVo.fail("auth_login_pwd_null");
}
return ResponseVo.succ(null);
}
/**
* 用户账号
*/
private String accNo;
......
......@@ -7,11 +7,15 @@ package com.fedex.connect.manager.enums;
*/
public enum ResponseCode {
//********************manager-server模块
MESSAGE_CODE_40001(40001,"business_exception_40001"),
MESSAGE_CODE_40002(40002,"business_log_40002"),
MESSAGE_CODE_40003(40003,"system_exception_40003"),
/******打个样,编写样例*****/
// MESSAGE_CODE_20001(20001,"business_exception_20001"),
// MESSAGE_CODE_20002(20002,"business_success_20002"),
// MESSAGE_CODE_20003(20003,"system_exception_20003"),
// MESSAGE_CODE_20004(20004,"system_success_20004"),
// MESSAGE_CODE_40001(40001,"business_exception_40001"),
// MESSAGE_CODE_40002(40002,"business_success_40002"),
// MESSAGE_CODE_40003(40003,"system_exception_40003"),
// MESSAGE_CODE_40004(40004,"system_success_40004"),
// MESSAGE_CODE_40005(40005,"business_log_40005"),
;
private Integer code;
private String msg;
......
package com.fedex.connect.manager.service.base;
import com.fedex.connect.common.dao.log.UserLoginInfoMapper;
import com.fedex.connect.common.dao.sys.RoleMapper;
import com.fedex.connect.common.dao.sys.UserMapper;
import com.fedex.connect.common.dao.sys.UserRoleMapper;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.manager.repository.repo.bi.IDicEntriesRepository;
import com.fedex.connect.manager.repository.repo.log.IUserLoginLogRepository;
import com.fedex.connect.manager.repository.repo.sys.*;
import com.fedex.connect.manager.repository.repo.sys.IRedisSlabRepository;
import com.fedex.connect.manager.repository.repo.sys.IRoleRepository;
import com.fedex.connect.manager.repository.repo.sys.IUserRepository;
import com.fedex.connect.manager.repository.repo.sys.IUserRoleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
......@@ -18,6 +18,9 @@ public class BaseService {
@Resource
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected ResponseUtils responseUtils;
/**
* repository
*/
......
......@@ -11,6 +11,7 @@ import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.common.model.sys.Role;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.data.dto.LoginRequest;
import com.fedex.connect.manager.enums.ResponseCode;
import com.fedex.connect.manager.service.base.BaseService;
import com.fedex.connect.manager.service.sys.IRedisUtilService;
import com.fedex.connect.manager.service.sys.ISysAuthService;
......@@ -65,10 +66,10 @@ public class SysAuthServiceImpl extends BaseService implements ISysAuthService {
redisUtilService.set(RedisConstants.REDIS_KEY_TOKEN + user.getId(), token, redisExpireTime);
} catch (NullPointerException e) {
logger.error("***************** redis 异常:{} *********************", e);
return ResponseVo.fail(BaseResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
responseUtils.fail(ResponseCode.MESSAGE_CODE_40003);
}
return ResponseVo.succ(token);
return responseUtils.success(token);
}
......@@ -84,10 +85,10 @@ public class SysAuthServiceImpl extends BaseService implements ISysAuthService {
redisUtilService.set(RedisConstants.REDIS_KEY_TOKEN + tokenKey, GsonUtils.beanToString(token), 1);
} catch (NullPointerException e) {
logger.error("***************** redis 异常:{} *********************", e);
return ResponseVo.fail(BaseResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
responseUtils.fail(ResponseCode.MESSAGE_CODE_40001);
}
return ResponseVo.succ(tokenKey);
return responseUtils.success(tokenKey);
}
/**
......
#******************鉴权相关提示,需要做国际化******************
#authentication包
auth_exc_no_auth=没有访问权限
auth_exc_no_pass_auth=没有通过权限认证
auth_filter_user_error=登录身份异常
auth_filter_timeout=登录超过8小时,请重新登录
auth_filter_stale_dated=登录已过期
enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
system_exception_10001=没有访问权限
system_exception_10002=没有通过权限认证
system_exception_10003=登录身份异常
system_exception_10004=登录超过8小时,请重新登录
system_exception_10005=登录已过期
system_exception_10006=登录身份异常
system_exception_10007=登录已过期,请重新登录
#******************业务相关、需要做国际化******************
business_exception_40001=存入token失败
business_log_40002=用户登录
system_exception_40003=系统异常,请联系清关部门
\ No newline at end of file
......
#******************鉴权相关提示,需要做国际化******************
#authentication包
auth_exc_no_auth=没有访问权限
auth_exc_no_pass_auth=没有通过权限认证
auth_filter_user_error=登录身份异常
auth_filter_timeout=登录超过8小时,请重新登录
auth_filter_stale_dated=登录已过期
enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
system_exception_10001=没有访问权限
system_exception_10002=没有通过权限认证
system_exception_10003=登录身份异常
system_exception_10004=登录超过8小时,请重新登录
system_exception_10005=登录已过期
system_exception_10006=登录身份异常
system_exception_10007=登录已过期,请重新登录
#******************业务相关、需要做国际化******************
business_exception_40001=存入token失败
business_log_40002=用户登录
system_exception_40003=系统异常,请联系清关部门
\ No newline at end of file
......