tao.mo

biz-customer | 修改 | 异常编码放自己模块

mt
2024年11月7日10:34:27
Showing 17 changed files with 105 additions and 53 deletions
package com.fedex.connect.customer.controller.biz.impl;
import com.fedex.connect.common.dependencies.date.model.LogShowModel;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IAttachmentController;
import com.fedex.connect.customer.data.bo.LongBo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......
......@@ -2,7 +2,7 @@ package com.fedex.connect.customer.controller.biz.impl;
import com.fedex.connect.common.dependencies.date.model.LogShowModel;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IAttachmentQueryController;
......@@ -40,7 +40,7 @@ public class AttachmentQueryController extends BaseController implements IAttach
//userId = 0L;
} catch (Exception e) {
log.error(LogShowModel.showException("Exception", e));
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
}
return attachmentQueryService.findHistory(userId,bo.getId());
}
......
......@@ -3,7 +3,7 @@ package com.fedex.connect.customer.controller.biz.impl;
import com.fedex.connect.common.dependencies.annotation.OperationMethodLog;
import com.fedex.connect.common.dependencies.date.model.LogShowModel;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.base.BaseController;
......@@ -43,10 +43,10 @@ public class ConsignmentController extends BaseController implements IConsignmen
user = CurrentUserInfo.getUser();
} catch (Exception e) {
logger.error(LogShowModel.showException("Exception", e));
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
}
if (user == null) {
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.OVERDUE_TOKEN_CODE.getMsg()));
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.OVERDUE_TOKEN_CODE.getMsg()));
}
return consignmentService.add(bo,user);
}
......
package com.fedex.connect.customer.controller.biz.impl;
import com.fedex.connect.common.dependencies.date.model.LogShowModel;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IConsignmentQueryController;
......@@ -48,14 +45,14 @@ public class ConsignmentQueryController extends BaseController implements IConsi
* 获取当前用户信息
*/
User user = this.getCurrentUserInfo();
/**
* 运单id校验
*/
consignmentInfoValidate.validateConsignmentId(id);
ConsignmentInfoQuery detailQuery = new ConsignmentInfoQuery();
detailQuery.setUserId(user.getId());
detailQuery.setUuid(user.getUserUuid());
detailQuery.setConsignmentId(id);
// return consignmentQueryService.findConsignmentInfo(detailQuery);
return null;
return consignmentQueryService.findConsignmentInfo(detailQuery);
}
}
......
package com.fedex.connect.customer.enums;
/**
* @Author mt
* @Description 响应编码样例
* @Date 2024/11/7
*/
public enum ResponseCode {
//********************biz_customer模块
/******打个样,编写样例*****/
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"),
;
private Integer code;
private String msg;
ResponseCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.fedex.connect.customer.service.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.customer.data.query.ConsignmentInfoQuery;
import com.fedex.connect.customer.data.query.ConsignmentQuery;
public interface IConsignmentQueryService {
......@@ -12,4 +13,6 @@ public interface IConsignmentQueryService {
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
ResponseVo findConsignments(ConsignmentQuery query);
ResponseVo findConsignmentInfo(ConsignmentInfoQuery detailQuery);
}
......
......@@ -5,6 +5,7 @@ import com.fedex.connect.common.dependencies.date.vo.PageResult;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.customer.data.dto.FindConsignmentsDto;
import com.fedex.connect.customer.data.query.ConsignmentInfoQuery;
import com.fedex.connect.customer.data.query.ConsignmentQuery;
import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IConsignmentQueryService;
......@@ -27,7 +28,6 @@ public class ConsignmentQueryServiceImpl extends BaseService implements IConsign
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
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"));
......@@ -46,4 +46,8 @@ public class ConsignmentQueryServiceImpl extends BaseService implements IConsign
}
return ResponseVo.succ(pageResult);
}
public ResponseVo findConsignmentInfo(ConsignmentInfoQuery detailQuery){
return null;
}
}
......
......@@ -2,7 +2,7 @@ package com.fedex.connect.customer.util.service.biz;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.model.sys.User;
......@@ -42,7 +42,7 @@ public class ConsignmentUtil {
if (!errList.isEmpty()) {
String enumResCode601 = localeMessageUtil.getMessage("enum_res_code_601");
String errResult = String.join(",", errList) + enumResCode601;
return ResponseVo.fail(ResponseCode.CONSIGNMENT_CREATOR_ERR, errResult);
return ResponseVo.fail(BaseResponseCode.CONSIGNMENT_CREATOR_ERR, errResult);
}
return null;
......@@ -79,9 +79,9 @@ 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(ResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC.getCode(),ResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC.getMsg(),consignmentAddDto);
return ResponseVo.succ(BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC.getCode(), BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_SUC.getMsg(),consignmentAddDto);
}else {
return ResponseVo.succ(ResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC.getCode(),ResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC.getMsg(),consignmentAddDto);
return ResponseVo.succ(BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC.getCode(), BaseResponseCode.CONSIGNMENT_CREATOR_SHIPPER_ACCOUNT_DIFF_SUC.getMsg(),consignmentAddDto);
}
}else {
return ResponseVo.succ(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.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.customer.data.bo.LongBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @Author Szl
* @Description 类说明 附件校验类
......@@ -28,7 +26,7 @@ public class AttachmentValidate {
*/
public ResponseVo preCheckForFindHistory(LongBo bo){
if (bo == null || bo.getId() == null){
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.REQUEST_PARAM_NULL.getMsg()));
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.REQUEST_PARAM_NULL.getMsg()));
}
return null;
}
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
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 org.springframework.beans.factory.annotation.Autowired;
......@@ -28,7 +28,7 @@ public class ConsignmentInfoValidate {
*/
public void validateConsignmentId(Long consignmentId){
if (Objects.isNull(consignmentId)){
ResponseVo rsVo = ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.REQUEST_PARAM_NULL.getMsg()));
ResponseVo rsVo = ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.REQUEST_PARAM_NULL.getMsg()));
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg());
}
}
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.customer.data.bo.AddBo;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,7 +29,7 @@ public class ConsignmentValidate {
if (bo == null || StringUtils.isEmpty(bo.getConsignmentCode()) ||
StringUtils.isEmpty(bo.getRecipientCountry()) || StringUtils.isEmpty(bo.getShipperAccount()) ||
StringUtils.isEmpty(bo.getShipperCountry())){
return ResponseVo.fail(localeMessageUtil.getMessage(ResponseCode.REQUEST_PARAM_NULL.getMsg()));
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.REQUEST_PARAM_NULL.getMsg()));
}
return null;
}
......
package com.fedex.connect.common.dependencies.common;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
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.CurrentUserInfo;
......@@ -18,11 +18,11 @@ public class BasicController {
try {
user = CurrentUserInfo.getUser();
} catch (Exception e) {
ResponseVo rsVo = ResponseVo.fail(ResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()),null);
ResponseVo rsVo = ResponseVo.fail(BaseResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(BaseResponseCode.TOKEN_FORMAT_ERROR.getMsg()),null);
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg(),e);
}
if (user == null) {
ResponseVo rsVo = ResponseVo.fail(ResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(ResponseCode.OVERDUE_TOKEN_CODE.getMsg()),null);
ResponseVo rsVo = ResponseVo.fail(BaseResponseCode.TOKEN_FORMAT_ERROR.getCode(),localeMessageUtil.getMessage(BaseResponseCode.OVERDUE_TOKEN_CODE.getMsg()),null);
throw new OpErrorException(rsVo.getCode(),rsVo.getMsg());
}
return user;
......
package com.fedex.connect.common.dependencies.date.vo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import javax.servlet.http.HttpServletResponse;
......@@ -49,11 +49,11 @@ public class ResponseVo<T> {
}
public static ResponseVo succ(Object data, String message) {
return succ(ResponseCode.SUCCESS_CODE.getCode(), message, data);
return succ(BaseResponseCode.SUCCESS_CODE.getCode(), message, data);
}
public static ResponseVo succ(Object data) {
return succ(ResponseCode.SUCCESS_CODE.getCode(), "SUCCESS", data);
return succ(BaseResponseCode.SUCCESS_CODE.getCode(), "SUCCESS", data);
}
public static ResponseVo succ(int code, String msg, Object data) {
......@@ -66,7 +66,7 @@ public class ResponseVo<T> {
}
public static ResponseVo fail(String msg) {
return fail(ResponseCode.FAIL_CODE.getCode(), msg,null);
return fail(BaseResponseCode.FAIL_CODE.getCode(), msg,null);
}
public static ResponseVo fail(int code, String msg, Object data) {
......@@ -78,11 +78,11 @@ public class ResponseVo<T> {
return r;
}
public static ResponseVo fail(ResponseCode resultCode) {
public static ResponseVo fail(BaseResponseCode resultCode) {
return fail(resultCode.getCode(), resultCode.getMsg(), null);
}
public static ResponseVo fail(ResponseCode resultCode, Object data) {
public static ResponseVo fail(BaseResponseCode resultCode, Object data) {
return fail(resultCode.getCode(), resultCode.getMsg(), data);
}
}
......
......@@ -5,7 +5,7 @@ package com.fedex.connect.common.dependencies.enums;
* @author erry
*/
public enum ResponseCode {
public enum BaseResponseCode {
/**
* 200=操作成功
* 201=操作失败
......@@ -56,15 +56,11 @@ public enum ResponseCode {
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"),
//********************biz_customer模块
//********************manager-server模块
;
private Integer code;
private String msg;
ResponseCode(Integer code, String msg) {
BaseResponseCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
......
......@@ -2,7 +2,7 @@ package com.fedex.connect.manager.data.dto;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.util.Utils;
import org.apache.commons.lang3.StringUtils;
......@@ -28,7 +28,7 @@ public class LoginRequest implements Serializable {
*/
public static ResponseVo validate(LoginRequest dto){
if (dto == null){
ResponseVo.fail(ResponseCode.REQUEST_PARAM_NULL.getMsg());
ResponseVo.fail(BaseResponseCode.REQUEST_PARAM_NULL.getMsg());
}
if (StringUtils.isBlank(dto.getAccNo())){
ResponseVo.fail("auth_login_accno_null");
......
package com.fedex.connect.manager.enums;
/**
* @Author mt
* @Description 响应编码样例
* @Date 2024/11/7
*/
public enum ResponseCode {
//********************manager-server模块
/******打个样,编写样例*****/
// 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"),
;
private Integer code;
private String msg;
ResponseCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ package com.fedex.connect.manager.service.sys.impl;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.contants.RedisConstants;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.util.GsonUtils;
import com.fedex.connect.common.dependencies.util.JwtTokenUtils;
import com.fedex.connect.common.model.sys.RedisSlab;
......@@ -65,7 +65,7 @@ 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(ResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
return ResponseVo.fail(BaseResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
}
return ResponseVo.succ(token);
......@@ -84,7 +84,7 @@ 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(ResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
return ResponseVo.fail(BaseResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
}
return ResponseVo.succ(tokenKey);
......