tao.mo

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

mt
2024年11月11日14:13:06
...@@ -49,16 +49,12 @@ public class ConsignmentController extends BaseController implements IConsignmen ...@@ -49,16 +49,12 @@ public class ConsignmentController extends BaseController implements IConsignmen
49 /** 49 /**
50 * 运单id非空校验 50 * 运单id非空校验
51 */ 51 */
52 -// consignmentValidate.validateConsignmentId(consignmentId); 52 + consignmentValidate.validateConsignmentSubmit(files,consignmentBo);
53 /** 53 /**
54 * 获取当前用户信息 54 * 获取当前用户信息
55 */ 55 */
56 User user = this.getCurrentUserInfo(); 56 User user = this.getCurrentUserInfo();
57 - /** 57 +
58 - * 构造查询对象
59 - */
60 -// UserConsignmentInfoQuery userConsignmentInfoQuery = UserConsignmentInfoQuery.getInstance(user,consignmentId);
61 -// return uploadRecordService.findHistory(userConsignmentInfoQuery);
62 return null; 58 return null;
63 } 59 }
64 } 60 }
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.fedex.connect.customer.data.bo; 1 package com.fedex.connect.customer.data.bo;
2 2
3 +import com.fedex.connect.common.dependencies.annotation.BaseNotBlank;
3 import lombok.Data; 4 import lombok.Data;
4 5
5 @Data 6 @Data
...@@ -7,17 +8,24 @@ public class ConsignmentBo { ...@@ -7,17 +8,24 @@ public class ConsignmentBo {
7 //运单id 8 //运单id
8 private Integer id; 9 private Integer id;
9 //运单号 10 //运单号
11 + @BaseNotBlank
10 private String consignmentCode; 12 private String consignmentCode;
11 //用户录入shipperAccount 13 //用户录入shipperAccount
14 + @BaseNotBlank
12 private String shipperAccount; 15 private String shipperAccount;
13 //原产国code 16 //原产国code
17 + @BaseNotBlank
14 private String originCountryCode; 18 private String originCountryCode;
15 //原产国全程 19 //原产国全程
20 + @BaseNotBlank
16 private String originCountry; 21 private String originCountry;
17 //目的国code 22 //目的国code
23 + @BaseNotBlank
18 private String destinationCountryCode; 24 private String destinationCountryCode;
19 //目的国全称 25 //目的国全称
26 + @BaseNotBlank
20 private String destinationCountry; 27 private String destinationCountry;
21 //文件业务类型AWB,INV,PKL,OTH(分运单,发票,箱单和其它这四种类型) 28 //文件业务类型AWB,INV,PKL,OTH(分运单,发票,箱单和其它这四种类型)
29 + @BaseNotBlank
22 private String[] fileBizType; 30 private String[] fileBizType;
23 } 31 }
......
...@@ -9,9 +9,9 @@ public enum ResponseCode { ...@@ -9,9 +9,9 @@ public enum ResponseCode {
9 //********************biz_customer模块 9 //********************biz_customer模块
10 /******打个样,编写样例*****/ 10 /******打个样,编写样例*****/
11 MESSAGE_CODE_10001(10001,"business_exception_10001"), 11 MESSAGE_CODE_10001(10001,"business_exception_10001"),
12 - MESSAGE_CODE_10002(10002,"business_success_10002"), 12 +// MESSAGE_CODE_10002(10002,"business_success_10002"),
13 - MESSAGE_CODE_10003(10003,"system_exception_10003"), 13 +// MESSAGE_CODE_10003(10003,"system_exception_10003"),
14 - MESSAGE_CODE_10004(10004,"system_success_10004"), 14 +// MESSAGE_CODE_10004(10004,"system_success_10004"),
15 ; 15 ;
16 private Integer code; 16 private Integer code;
17 private String msg; 17 private String msg;
......
...@@ -2,11 +2,17 @@ package com.fedex.connect.customer.validate.controller.biz; ...@@ -2,11 +2,17 @@ package com.fedex.connect.customer.validate.controller.biz;
2 2
3 import com.fedex.connect.common.dependencies.date.vo.ResponseVo; 3 import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 import com.fedex.connect.common.dependencies.enums.BaseResponseCode; 4 import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
5 +import com.fedex.connect.common.dependencies.exception.OpErrorException;
5 import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; 6 import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
7 +import com.fedex.connect.common.dependencies.util.BaseValidateUtils;
6 import com.fedex.connect.customer.data.bo.ConsignmentBo; 8 import com.fedex.connect.customer.data.bo.ConsignmentBo;
9 +import com.fedex.connect.customer.enums.ResponseCode;
7 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
9 import org.springframework.util.StringUtils; 12 import org.springframework.util.StringUtils;
13 +import org.springframework.web.multipart.MultipartFile;
14 +
15 +import java.util.Objects;
10 16
11 /** 17 /**
12 * @Author Szl 18 * @Author Szl
...@@ -17,6 +23,8 @@ import org.springframework.util.StringUtils; ...@@ -17,6 +23,8 @@ import org.springframework.util.StringUtils;
17 public class ConsignmentValidate { 23 public class ConsignmentValidate {
18 @Autowired 24 @Autowired
19 protected LocaleMessageUtil localeMessageUtil; 25 protected LocaleMessageUtil localeMessageUtil;
26 + @Autowired
27 + protected BaseValidateUtils baseValidateUtils;
20 28
21 /** 29 /**
22 * @Author Szl 30 * @Author Szl
...@@ -33,4 +41,24 @@ public class ConsignmentValidate { ...@@ -33,4 +41,24 @@ public class ConsignmentValidate {
33 } 41 }
34 return null; 42 return null;
35 } 43 }
44 +
45 + /**
46 + * @Author mt
47 + * @Description 运单提交校验
48 + * @Date 2024/11/11
49 + * @param files
50 + * @param consignmentBo
51 + * @return void
52 + */
53 + public void validateConsignmentSubmit(MultipartFile[] files,ConsignmentBo consignmentBo){
54 + Integer code = ResponseCode.MESSAGE_CODE_10001.getCode();
55 + String msg = ResponseCode.MESSAGE_CODE_10001.getMsg();
56 + if(Objects.isNull(files)){
57 + throw new OpErrorException(code,msg);
58 + }
59 + /**
60 + * 非空字段校验
61 + */
62 + baseValidateUtils.notBlankValidate(consignmentBo,code,msg);
63 + }
36 } 64 }
......
...@@ -14,12 +14,11 @@ enum_res_code_301=登录身份异常 ...@@ -14,12 +14,11 @@ enum_res_code_301=登录身份异常
14 enum_res_code_305=登录已过期,请重新登录 14 enum_res_code_305=登录已过期,请重新登录
15 15
16 #******************业务相关、需要做国际化****************** 16 #******************业务相关、需要做国际化******************
17 +con_shipperAccount=发货人计费账号
18 +con_shipperCountry=始发国
19 +con_recipientCountry=目的国
17 enum_res_code_601=不正确,请重新输入 20 enum_res_code_601=不正确,请重新输入
18 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. 21 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.
19 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. 22 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.
20 -
21 conl_cus_declare_count_max=單次最多可查詢1000個運單號碼 23 conl_cus_declare_count_max=單次最多可查詢1000個運單號碼
22 - 24 +business_exception_10001=必填字段未填写
23 -con_shipperAccount=发货人计费账号
24 -con_shipperCountry=始发国
25 -con_recipientCountry=目的国
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -14,12 +14,11 @@ enum_res_code_301=登录身份异常 ...@@ -14,12 +14,11 @@ enum_res_code_301=登录身份异常
14 enum_res_code_305=登录已过期,请重新登录 14 enum_res_code_305=登录已过期,请重新登录
15 15
16 #******************业务相关、需要做国际化****************** 16 #******************业务相关、需要做国际化******************
17 +con_shipperAccount=发货人计费账号
18 +con_shipperCountry=始发国
19 +con_recipientCountry=目的国
17 enum_res_code_601=不正确,请重新输入 20 enum_res_code_601=不正确,请重新输入
18 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. 21 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.
19 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. 22 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.
20 -
21 conl_cus_declare_count_max=單次最多可查詢1000個運單號碼 23 conl_cus_declare_count_max=單次最多可查詢1000個運單號碼
22 - 24 +business_exception_10001=必填字段未填写
23 -con_shipperAccount=发货人计费账号
24 -con_shipperCountry=始发国
25 -con_recipientCountry=目的国
...\ No newline at end of file ...\ No newline at end of file
......
1 +package com.fedex.connect.common.dependencies.annotation;
2 +
3 +import java.lang.annotation.Retention;
4 +import java.lang.annotation.RetentionPolicy;
5 +
6 +/**
7 + * 字段非空注解
8 + */
9 +@Retention(RetentionPolicy.RUNTIME)
10 +public @interface BaseNotBlank {
11 +}
...@@ -8,6 +8,8 @@ package com.fedex.connect.common.dependencies.contants; ...@@ -8,6 +8,8 @@ package com.fedex.connect.common.dependencies.contants;
8 public interface BaseConstants { 8 public interface BaseConstants {
9 //基础字段列名 9 //基础字段列名
10 interface BASE_TABLE_COLUMN_KEYS{ 10 interface BASE_TABLE_COLUMN_KEYS{
11 + //ID
12 + String ID = "id";
11 //创建时间 13 //创建时间
12 String CREATE_TIME = "createTime"; 14 String CREATE_TIME = "createTime";
13 //创建人ID 15 //创建人ID
......
1 +package com.fedex.connect.common.dependencies.util;
2 +
3 +import com.fedex.connect.common.dependencies.annotation.BaseNotBlank;
4 +import com.fedex.connect.common.dependencies.exception.OpErrorException;
5 +import org.springframework.stereotype.Component;
6 +import org.springframework.util.StringUtils;
7 +import java.lang.annotation.Annotation;
8 +import java.lang.reflect.Field;
9 +import java.util.Objects;
10 +
11 +/**
12 + * @Author mt
13 + * @Description 非空校验类
14 + * @Date 2024/11/11
15 + */
16 +@Component
17 +public class BaseValidateUtils {
18 + /**
19 + * 字段非空校验,仅对有BaseNotBlank注解字段进行非空校验,字段类型如果为字符串,空字符串也算空
20 + * @param obj
21 + */
22 + public void notBlankValidate(Object obj,Integer code,String msg){
23 + Class cls = obj.getClass();
24 + Field[] fields = cls.getDeclaredFields();
25 + try {
26 + for (Field field : fields) {
27 + Annotation annotation = field.getAnnotation(BaseNotBlank.class);
28 + if (Objects.nonNull(annotation)) {
29 + Object value = AssignmentFieldUtils.getFieldValue(obj, field.getName());
30 + if(value instanceof String){
31 + String str = String.valueOf(value);
32 + if(!StringUtils.hasText(str)){
33 + throw new OpErrorException(code,msg);
34 + }
35 + }else{
36 + if(Objects.isNull(value)){
37 + throw new OpErrorException(code,msg);
38 + }
39 + }
40 + }
41 + }
42 + }catch(Exception ex){
43 + throw new OpErrorException(code,msg);
44 + }
45 + }
46 +}
...\ No newline at end of file ...\ No newline at end of file