tao.mo

common-dependencies、biz-customer | 修改 | 运单提交相关

mt
2024年11月11日14:13:06
......@@ -49,16 +49,12 @@ public class ConsignmentController extends BaseController implements IConsignmen
/**
* 运单id非空校验
*/
// consignmentValidate.validateConsignmentId(consignmentId);
consignmentValidate.validateConsignmentSubmit(files,consignmentBo);
/**
* 获取当前用户信息
*/
User user = this.getCurrentUserInfo();
/**
* 构造查询对象
*/
// UserConsignmentInfoQuery userConsignmentInfoQuery = UserConsignmentInfoQuery.getInstance(user,consignmentId);
// return uploadRecordService.findHistory(userConsignmentInfoQuery);
return null;
}
}
\ No newline at end of file
......
package com.fedex.connect.customer.data.bo;
import com.fedex.connect.common.dependencies.annotation.BaseNotBlank;
import lombok.Data;
@Data
......@@ -7,17 +8,24 @@ public class ConsignmentBo {
//运单id
private Integer id;
//运单号
@BaseNotBlank
private String consignmentCode;
//用户录入shipperAccount
@BaseNotBlank
private String shipperAccount;
//原产国code
@BaseNotBlank
private String originCountryCode;
//原产国全程
@BaseNotBlank
private String originCountry;
//目的国code
@BaseNotBlank
private String destinationCountryCode;
//目的国全称
@BaseNotBlank
private String destinationCountry;
//文件业务类型AWB,INV,PKL,OTH(分运单,发票,箱单和其它这四种类型)
@BaseNotBlank
private String[] fileBizType;
}
......
......@@ -9,9 +9,9 @@ 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"),
// 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;
......
......@@ -2,11 +2,17 @@ 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.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.enums.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.util.Objects;
/**
* @Author Szl
......@@ -17,6 +23,8 @@ import org.springframework.util.StringUtils;
public class ConsignmentValidate {
@Autowired
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected BaseValidateUtils baseValidateUtils;
/**
* @Author Szl
......@@ -33,4 +41,24 @@ public class ConsignmentValidate {
}
return null;
}
/**
* @Author mt
* @Description 运单提交校验
* @Date 2024/11/11
* @param files
* @param consignmentBo
* @return void
*/
public void validateConsignmentSubmit(MultipartFile[] files,ConsignmentBo consignmentBo){
Integer code = ResponseCode.MESSAGE_CODE_10001.getCode();
String msg = ResponseCode.MESSAGE_CODE_10001.getMsg();
if(Objects.isNull(files)){
throw new OpErrorException(code,msg);
}
/**
* 非空字段校验
*/
baseValidateUtils.notBlankValidate(consignmentBo,code,msg);
}
}
......
......@@ -14,12 +14,11 @@ enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
#******************业务相关、需要做国际化******************
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個運單號碼
con_shipperAccount=发货人计费账号
con_shipperCountry=始发国
con_recipientCountry=目的国
business_exception_10001=必填字段未填写
\ No newline at end of file
......
......@@ -14,12 +14,11 @@ enum_res_code_301=登录身份异常
enum_res_code_305=登录已过期,请重新登录
#******************业务相关、需要做国际化******************
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個運單號碼
con_shipperAccount=发货人计费账号
con_shipperCountry=始发国
con_recipientCountry=目的国
business_exception_10001=必填字段未填写
\ No newline at end of file
......
package com.fedex.connect.common.dependencies.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* 字段非空注解
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface BaseNotBlank {
}
......@@ -8,6 +8,8 @@ package com.fedex.connect.common.dependencies.contants;
public interface BaseConstants {
//基础字段列名
interface BASE_TABLE_COLUMN_KEYS{
//ID
String ID = "id";
//创建时间
String CREATE_TIME = "createTime";
//创建人ID
......
package com.fedex.connect.common.dependencies.util;
import com.fedex.connect.common.dependencies.annotation.BaseNotBlank;
import com.fedex.connect.common.dependencies.exception.OpErrorException;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Objects;
/**
* @Author mt
* @Description 非空校验类
* @Date 2024/11/11
*/
@Component
public class BaseValidateUtils {
/**
* 字段非空校验,仅对有BaseNotBlank注解字段进行非空校验,字段类型如果为字符串,空字符串也算空
* @param obj
*/
public void notBlankValidate(Object obj,Integer code,String msg){
Class cls = obj.getClass();
Field[] fields = cls.getDeclaredFields();
try {
for (Field field : fields) {
Annotation annotation = field.getAnnotation(BaseNotBlank.class);
if (Objects.nonNull(annotation)) {
Object value = AssignmentFieldUtils.getFieldValue(obj, field.getName());
if(value instanceof String){
String str = String.valueOf(value);
if(!StringUtils.hasText(str)){
throw new OpErrorException(code,msg);
}
}else{
if(Objects.isNull(value)){
throw new OpErrorException(code,msg);
}
}
}
}
}catch(Exception ex){
throw new OpErrorException(code,msg);
}
}
}
\ No newline at end of file