Browse Source

controller层增加信息校验更新

mashengyi 2 years ago
parent
commit
cd47b0c88a

+ 2 - 1
src/main/java/com/jkcredit/invoice/config/GlobalExceptionHandler.java

@@ -42,10 +42,11 @@ public class GlobalExceptionHandler {
      * @return RespR
      */
     @ExceptionHandler({MethodArgumentNotValidException.class, BindException.class})
-    @ResponseStatus(HttpStatus.BAD_REQUEST)
+    @ResponseStatus(HttpStatus.OK)
     public RespR bodyValidExceptionHandler(MethodArgumentNotValidException exception) {
         List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
         RespR result = new RespR();
+        result.setCode(1);
         result.setMsg(fieldErrors.get(0).getDefaultMessage());
         log.warn(fieldErrors.get(0).getDefaultMessage());
         return result;

+ 37 - 47
src/main/java/com/jkcredit/invoice/controller/business/CustomerController.java

@@ -27,11 +27,14 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.apache.ibatis.annotations.Insert;
 import org.apache.poi.util.IOUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotBlank;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -126,10 +129,7 @@ public class CustomerController {
     @GetMapping("/findCustomerRecListExport")
     @ApiOperation(value = "客户信息导出", notes = "客户信息导出")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public void findCustomerRechargeExport(String customerName, String companyName, String companyBelongName, HttpServletResponse response) throws Exception {
-        if(!checkHasAuthRole.checkMessage(customerName,companyName,companyBelongName)){
-            log.error("findCustomerRecListExport客户信息导出信息有误");
-        }
+    public void findCustomerRechargeExport(@NotBlank(message = "客户名称不能为空")String customerName, @NotBlank(message = "公司名称不能为空")String companyName, @NotBlank(message = "主体名称不能为空")String companyBelongName, HttpServletResponse response) throws Exception {
         CustomerRec customerRec = new CustomerRec();
         customerRec.setCustomerName(customerName);
         customerRec.setCompanyBelongName(companyBelongName);
@@ -174,9 +174,14 @@ public class CustomerController {
     @LoginRequired
     public RespR addCustomer(@RequestBody Customer customer, User user) {
         checkHasAuthRole.checkCustomerRole(user, customer.getCustomerName());
-        if(!checkHasAuthRole.checkMessage(customer.getCustomerName(),customer.getCompany())){
+        if (!checkHasAuthRole.checkMessage(customer.getCustomerName(), customer.getCompany())) {
             return new RespR(false, "客户添加失败,请查看数据是否维护准确");
         }
+        if (null == customer.getBussinessType()) {
+            return new RespR(false, "客户添加失败,请查看业务类型是否选择");
+        } else if (0 == customer.getBussinessType() && null == customer.getFee()) {
+            return new RespR(false, "客户添加失败,自有车业务必须添加ETC费用");
+        }
         return new RespR(customerService.addCustomers(customer), "客户添加失败,请查看是否重复");
     }
 
@@ -189,9 +194,15 @@ public class CustomerController {
     @ApiOperation(value = "更新用户", notes = "更新用户")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR updateCustomer(@RequestBody Customer customer) {
-        if(!checkHasAuthRole.checkMessage(customer.getCustomerName(),customer.getCompany())){
+        if (!checkHasAuthRole.checkMessage(customer.getCustomerName(), customer.getCompany())) {
             return new RespR(false, "客户更新失败,请查看数据是否维护准确");
         }
+        if (null == customer.getBussinessType()) {
+            return new RespR(false, "客户更新失败,请查看业务类型是否选择");
+        } else if (0 == customer.getBussinessType() && null == customer.getFee()) {
+            return new RespR(false, "客户更新失败,自有车业务必须添加ETC费用");
+        }
+
         return new RespR(customerService.updateCustomer(customer));
     }
 
@@ -204,6 +215,9 @@ public class CustomerController {
     @ApiOperation(value = "停用备案用户", notes = "停用备案用户")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR customeRecStop(@RequestBody CustomerRec customerRec) {
+        if (!checkHasAuthRole.checkMessage(customerRec.getCustomerName(), customerRec.getCompanyName())) {
+            return new RespR(false, "停用备案用户失败,请查看数据是否维护准确");
+        }
         customerRec.setRecStatus(4);
         return customerService.updateCustomerRecStatus(customerRec);
     }
@@ -217,6 +231,9 @@ public class CustomerController {
     @ApiOperation(value = "启用备案用户", notes = "启用备案用户")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR customeRecStart(@RequestBody CustomerRec customerRec) {
+        if (!checkHasAuthRole.checkMessage(customerRec.getCustomerName(), customerRec.getCompanyName())) {
+            return new RespR(false, "启用备案用户失败,请查看数据是否维护准确");
+        }
         customerRec.setRecStatus(1);
         return customerService.updateCustomerRecStatus(customerRec);
     }
@@ -229,18 +246,11 @@ public class CustomerController {
     @PostMapping("/customerRecAdd")
     @ApiOperation(value = "手工添加备案信息", notes = "手工添加备案信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR customerRecAdd(@RequestBody CustomerRec customerRec) {
-        if(!checkHasAuthRole.checkMessage(customerRec.getCustomerName(),customerRec.getCompanyLeader(),customerRec.getCompanyLeaderPhone(),
-                customerRec.getCompanyName(),customerRec.getCompanyReferencenum(),
-                customerRec.getCompanyOpenbank(),customerRec.getCompanyOpenbankAcc(),
-                customerRec.getCompanyAdress(),customerRec.getCompanyPhone(),
-                customerRec.getBussinessType())){
-            return new RespR(false, "手工添加备案信息失败,请查看数据是否维护准确");
-        }
-
+    public RespR customerRecAdd(@RequestBody @Validated CustomerRec customerRec) {
         customerRec.setInterType(1);
         List<CustomerRec> customerRecList = new ArrayList<>();
         customerRecList.add(customerRec);
+
         return lowerService.customeRec(customerRecList);
     }
 
@@ -252,11 +262,7 @@ public class CustomerController {
     @PostMapping("/customeRecQueryUpper")
     @ApiOperation(value = "查询备案信息", notes = "手工添加备案信息")
     @LoginRequired
-    public RespR customeRecQueryUpper(@RequestBody CustomerRec customerRec, User user) {
-        if(!checkHasAuthRole.checkMessage(customerRec.getCustomerName(),customerRec.getCompanyName(),customerRec.getCompanyReferencenum())){
-            return new RespR(false, "查询备案信息失败,请查看数据是否维护准确");
-        }
-
+    public RespR customeRecQueryUpper(@RequestBody @Validated({Insert.class}) CustomerRec customerRec, User user) {
         checkHasAuthRole.checkCustomerRole(user, customerRec.getCustomerName());
         RespR<List<B2bCompanyModel>> respR = customerService.customerRecQuery(customerRec);
 
@@ -300,21 +306,14 @@ public class CustomerController {
     @PostMapping("/customRecharge")
     @ApiOperation(value = "账号充值", notes = "账号充值")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR customRecharge(@RequestBody CustomerRecharge customerRecharge) {
-        if (null == customerRecharge.getRechargeMony() || "".equals(customerRecharge.getRechargeMony())) {
-            log.error("充值失败:CustomerServiceImpl.getRechargeMony:" + customerRecharge.getRechargeMony());
-            return new RespR(false,"充值记录为空");
-        }
+    public RespR customRecharge(@RequestBody @Validated CustomerRecharge customerRecharge) {
         return new RespR(customerService.customRecharge(customerRecharge));
     }
 
     @PostMapping("/customeRec")
     @ApiOperation(value = "用户备案确认", notes = "用户备案确认")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR customeRec(@RequestBody CustomerRec customerRec) {
-        if(!checkHasAuthRole.checkMessage(customerRec.getCustomerName(),customerRec.getCompanyReferencenum())){
-            return new RespR(false, "用户备案确认失败,请查看数据是否维护准确");
-        }
+    public RespR customeRec(@RequestBody @Validated CustomerRec customerRec) {
         return customerService.customeRec(customerRec);
     }
 
@@ -322,9 +321,9 @@ public class CustomerController {
     @ApiOperation(value = "协议上传确认", notes = "协议上传确认")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR contractAdd(@RequestBody CustomerRec customerRec) {
-        if(!checkHasAuthRole.checkMessage(customerRec.getCompanyNum(),
-                customerRec.getContractFileName(),customerRec.getServiceStartTime(),
-                customerRec.getServiceEndTime())){
+        if (!checkHasAuthRole.checkMessage(customerRec.getCompanyNum(),
+                customerRec.getContractFileName(), customerRec.getServiceStartTime(),
+                customerRec.getServiceEndTime())) {
             return new RespR(false, "协议上传确认失败,请查看数据是否维护准确");
         }
         return customerService.contractAdd(customerRec);
@@ -334,7 +333,7 @@ public class CustomerController {
     @ApiOperation(value = "协议上传失败状态确认", notes = "协议上传失败状态确认")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR contractStatusFail(@RequestBody CustomerRec customerRec) {
-        if(null == customerRec.getRecStatus()){
+        if (null == customerRec.getRecStatus()) {
             return new RespR(false, "协议上传失败状态确认失败,请查看数据是否维护准确");
         }
         return customerService.contractStatusFail(customerRec);
@@ -344,7 +343,7 @@ public class CustomerController {
     @ApiOperation(value = "协议上传成功,审批中状态确认", notes = "协议上传成功,审批中状态确认")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR contractStatusProcess(@RequestBody CustomerRec customerRec) {
-        if(null == customerRec.getRecStatus()){
+        if (null == customerRec.getRecStatus()) {
             return new RespR(false, "协议上传成功,审批中状态确认失败,请查看数据是否维护准确");
         }
         return customerService.contractStatusProcess(customerRec);
@@ -354,7 +353,7 @@ public class CustomerController {
     @ApiOperation(value = "备案成功状态确认", notes = "备案成功状态确认")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR contractStatusSuccess(@RequestBody CustomerRec customerRec) {
-        if(null == customerRec.getRecStatus()){
+        if (null == customerRec.getRecStatus()) {
             return new RespR(false, "备案成功状态确认失败,请查看数据是否维护准确");
         }
         return customerService.contractStatusSuccess(customerRec);
@@ -363,10 +362,7 @@ public class CustomerController {
     @GetMapping("/contractDownload")
     @ApiOperation(value = "协议下载", notes = "协议下载")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR contractDownload(String customerRecId, HttpServletResponse response) {
-        if(!checkHasAuthRole.checkMessage(customerRecId)){
-            return new RespR(false, "协议下载失败,请查看数据是否维护准确");
-        }
+    public RespR contractDownload(@NotBlank(message = "企业绑定ID不能为空")String customerRecId, HttpServletResponse response) {
 
         CustomerRec customerRec = (CustomerRec) customerService.contractDownload(customerRecId).getData();
         String fileName = customerRec.getLowerFileName();
@@ -396,10 +392,7 @@ public class CustomerController {
     @GetMapping("/generateWord")
     @ApiOperation(value = "文档下载", notes = "文档下载")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR generateWord(String customerRecId, HttpServletResponse response) {
-        if(!checkHasAuthRole.checkMessage(customerRecId)){
-            return new RespR(false, "文档下载失败,请查看数据是否维护准确");
-        }
+    public RespR generateWord(@NotBlank(message = "企业绑定ID不能为空")String customerRecId, HttpServletResponse response) {
 
         CustomerRec customerRec = (CustomerRec) customerService.generateWordDownload(customerRecId).getData();
         if (null == customerRec || null == customerRec.getServiceStartTime() || null == customerRec.getServiceEndTime()) {
@@ -533,10 +526,7 @@ public class CustomerController {
     @PostMapping("/customerChangeInfo")
     @ApiOperation(value = "用户换卡信息查询", notes = "用户换卡信息查询")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR customerChangeInfo(String applyId) {
-        if(!checkHasAuthRole.checkMessage(applyId)){
-            return new RespR(false, "用户换卡信息查询失败,请查看数据是否维护准确");
-        }
+    public RespR customerChangeInfo(@NotBlank(message = "申请Id不能为空") String applyId) {
         List<Map<String, String>> cards = customerChangeInfoService.selectChangeCards(applyId);
         return new RespR(cards);
     }

+ 12 - 28
src/main/java/com/jkcredit/invoice/controller/business/NoCarController.java

@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotNull;
 import java.io.*;
 import java.net.URLEncoder;
 import java.text.DateFormat;
@@ -225,11 +226,7 @@ public class NoCarController {
     @PostMapping("/updateStatus")
     @ApiOperation(value = "重新获取发票并更新状态", notes = "重新获取发票并更新状态")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateStatus(String noCarWayBillStr) {
-        if(!checkHasAuthRole.checkMessage(noCarWayBillStr)){
-            return new RespR(false, "重新获取发票并更新状态失败,请查看数据是否维护准确");
-        }
-
+    public RespR updateStatus(@NotNull(message = "发票更新状态失败,不能为空") String noCarWayBillStr) {
         List<NoCarWayBill> noCarWayBills = JSON.parseArray(noCarWayBillStr, NoCarWayBill.class);
 
         if (noCarWayBills != null && noCarWayBills.size() > 0) {
@@ -238,7 +235,7 @@ public class NoCarController {
                     noCarWayBill.setBillwayStatus(-5);
                     noCarService.getInvoiceByWayBillNumReal(noCarWayBill, false);
                 } catch (Exception e) {
-                    log.info("1111111111222222" + e.getMessage());
+                    log.info("重新获取发票并更新状态失败" + e.getMessage());
                 }
             });
         }
@@ -339,7 +336,7 @@ public class NoCarController {
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR batchImportNocarInvoices(@RequestParam("file") MultipartFile file) {
         try {
-            if(null == file){
+            if (null == file) {
                 return new RespR(false, "批量查询无车发票信息失败,请查看数据是否维护准确");
             }
 
@@ -368,7 +365,7 @@ public class NoCarController {
     public RespR batchImportNocarBillWay(@RequestParam("file") MultipartFile file) {
         try {
 
-            if(null == file){
+            if (null == file) {
                 return new RespR(false, "批量查询无车运单信息失败,请查看数据是否维护准确");
             }
 
@@ -424,16 +421,13 @@ public class NoCarController {
     @PostMapping("/batchImprotBillWay")
     @ApiOperation(value = "批量运单导入", notes = "批量运单导入")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
-    public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file, String customerName, User user) {
+    public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName, User user) {
         try {
 
-            if(null == file){
+            if (null == file) {
                 return new RespR(false, "批量运单导入失败,请查看数据是否维护准确");
             }
 
-            if(!checkHasAuthRole.checkMessage(customerName)){
-                return new RespR(false, "批量运单导入失败,请查看数据是否维护准确");
-            }
             checkHasAuthRole.checkCustomerRole(user, customerName);
             ImportParams params = new ImportParams();
             params.setTitleRows(1);
@@ -458,16 +452,13 @@ public class NoCarController {
     @PostMapping("/batchImprotHistoryBillWay")
     @ApiOperation(value = "批量历史运单导入", notes = "批量历史运单导入")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
-    public RespR batchImprotHistoryBillWay(@RequestParam("file") MultipartFile file, String customerName, User user) {
+    public RespR batchImprotHistoryBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName, User user) {
         try {
 
-            if(null == file){
+            if (null == file) {
                 return new RespR(false, "批量历史运单导入失败,请查看数据是否维护准确");
             }
 
-            if(!checkHasAuthRole.checkMessage(customerName)){
-                return new RespR(false, "批量历史运单导入失败,请查看数据是否维护准确");
-            }
             checkHasAuthRole.checkCustomerRole(user, customerName);
             ImportParams params = new ImportParams();
             params.setTitleRows(1);
@@ -493,13 +484,9 @@ public class NoCarController {
     @PostMapping("/batchImprotEndBillWay")
     @ApiOperation(value = "批量运单结束", notes = "批量运单结束")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
-    public RespR batchImprotEndBillWay(@RequestParam("file") MultipartFile file, String customerName, User user) {
+    public RespR batchImprotEndBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName, User user) {
 
-        if(null == file){
-            return new RespR(false, "批量运单结束失败,请查看数据是否维护准确");
-        }
-
-        if(!checkHasAuthRole.checkMessage(customerName)){
+        if (null == file) {
             return new RespR(false, "批量运单结束失败,请查看数据是否维护准确");
         }
 
@@ -707,11 +694,8 @@ public class NoCarController {
 
     @GetMapping("/templateDownload")
     @ApiOperation(value = "模板下载", notes = "模板下载")
-    public RespR contractDownload(String fileName, HttpServletResponse response) {
+    public RespR contractDownload(@NotNull(message = "模板下载,文件名称不能为空") String fileName, HttpServletResponse response) {
 
-        if(!checkHasAuthRole.checkMessage(fileName)){
-            return new RespR(false, "模板下载失败,请查看数据是否维护准确");
-        }
         if (ONE.equals(fileName)) {
             fileName = "运单模板.xlsx";
         } else if (TWO.equals(fileName)) {

+ 12 - 13
src/main/java/com/jkcredit/invoice/controller/business/SelfCarController.java

@@ -32,11 +32,13 @@ import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.hibernate.validator.constraints.Length;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.validation.constraints.NotNull;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -91,11 +93,8 @@ public class SelfCarController {
     @PostMapping("/selfCarUnBind")
     @ApiOperation(value = "解绑etc卡", notes = "解绑etc卡")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR selfCarUnBind(String etcNum) {
+    public RespR selfCarUnBind(@NotNull(message = "etc卡号不能为空") @Length(max = 20, message = "etc卡号长度不符") String etcNum) {
         try {
-            if(!checkHasAuthRole.checkMessage(etcNum)){
-                return new RespR(false, "解绑etc卡失败,请查看数据是否维护准确");
-            }
             RespR respR = selfCarBussService.selfCarUnBind(etcNum);
             return respR;
         } catch (Exception e) {
@@ -203,11 +202,8 @@ public class SelfCarController {
     @PostMapping("/updateTrades")
     @ApiOperation(value = "更新交易id状态", notes = "更新交易id状态")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_SELFCAR)
-    public void updateTrades(String selfCarTradesStr, String companyName, User user) {
+    public void updateTrades(@NotNull(message = "更新交易id状态,不能为空") String selfCarTradesStr, @NotNull(message = "更新交易id状态,不能为空") String companyName, User user) {
         try {
-            if(!checkHasAuthRole.checkMessage(selfCarTradesStr,companyName)){
-                log.error("更新交易id状态失败,请查看数据是否维护准确");
-            }
             checkHasAuthRole.checkCompanyRole(user, companyName);
             List<SelfCarTrade> selfCarTrades = JSON.parseArray(selfCarTradesStr, SelfCarTrade.class);
             if (selfCarTrades == null || selfCarTrades.size() == 0) {
@@ -387,7 +383,8 @@ public class SelfCarController {
     @LoginRequired(role = AuthenticationInterceptor.AUTH_SELFCAR)
     public RespR getTradeList(@RequestBody TradeRequestCarNumVo tradeRequestCarNumVo, User user) {
 
-        if(!checkHasAuthRole.checkMessage(tradeRequestCarNumVo.getCarNum())){
+        if (!checkHasAuthRole.checkMessage(tradeRequestCarNumVo.getCarNum(), tradeRequestCarNumVo.getCompanyName(), tradeRequestCarNumVo.getCustomerName(),
+                tradeRequestCarNumVo.getStartTime(), tradeRequestCarNumVo.getEndTime())) {
             return new RespR(false, "获取需要开票的交易Id列表失败,请查看数据是否维护准确");
         }
 
@@ -425,7 +422,8 @@ public class SelfCarController {
     @LoginRequired(role = AuthenticationInterceptor.AUTH_SELFCAR)
     public RespR applTradeList(@RequestBody TradeRequestCarNumVo tradeRequestCarNumVo, User user) {
 
-        if(!checkHasAuthRole.checkMessage(tradeRequestCarNumVo.getCarIdStr())){
+        if (!checkHasAuthRole.checkMessage(tradeRequestCarNumVo.getCarIdStr(), tradeRequestCarNumVo.getCompanyName(),
+                tradeRequestCarNumVo.getCustomerName())) {
             return new RespR(false, "根据车牌号进行开票操作失败,请查看数据是否维护准确");
         }
 
@@ -476,7 +474,8 @@ public class SelfCarController {
     public RespR findSelfcarInvoiceByTime(@RequestBody SelfcarInvoiceByTimeVo selfcarInvoiceByTimeVo, User user) {
         try {
 
-            if(!checkHasAuthRole.checkMessage(selfcarInvoiceByTimeVo.getCustomerName())){
+            if (!checkHasAuthRole.checkMessage(selfcarInvoiceByTimeVo.getCustomerName(), selfcarInvoiceByTimeVo.getCompanyName(),
+                    selfcarInvoiceByTimeVo.getCarNum(), selfcarInvoiceByTimeVo.getStartTime(), selfcarInvoiceByTimeVo.getEndTime())) {
                 return new RespR(false, "根据车牌号进行开票操作失败,请查看数据是否维护准确");
             }
 
@@ -536,7 +535,7 @@ public class SelfCarController {
     public RespR batchImportSelfcarTrades(@RequestParam("file") MultipartFile file) {
         try {
 
-            if(null == file){
+            if (null == file) {
                 return new RespR(false, "批量查询自有车交易信息失败,请查看数据是否维护准确");
             }
 
@@ -566,7 +565,7 @@ public class SelfCarController {
     public RespR batchImportSelfcarInvoices(@RequestParam("file") MultipartFile file) {
         try {
 
-            if(null == file){
+            if (null == file) {
                 return new RespR(false, "批量查询自有车发票信息失败,请查看数据是否维护准确");
             }
 

+ 3 - 2
src/main/java/com/jkcredit/invoice/controller/param/ParamController.java

@@ -9,6 +9,7 @@ import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -54,7 +55,7 @@ public class ParamController {
     @PostMapping
     @ApiOperation(value = "新增参数详细信息", notes = "新增参数详细信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR param(@RequestBody Param param) {
+    public RespR param(@RequestBody @Validated Param param) {
         Param param1 = paramService.getParamsByParamName(param.getParamName());
         if (param1 != null) {
             return new RespR<>(false, "参数名称已存在,请重新维护!");
@@ -72,7 +73,7 @@ public class ParamController {
     @PostMapping("/updateParam")
     @ApiOperation(value = "更新参数信息", notes = "更新参数信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateUser(@RequestBody Param param) {
+    public RespR updateUser(@RequestBody @Validated Param param) {
         return new RespR<>(paramService.updateParam(param));
     }
 

+ 3 - 1
src/main/java/com/jkcredit/invoice/controller/user/AuthenticationController.java

@@ -9,7 +9,9 @@ import com.jkcredit.invoice.util.Md5Util;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.ibatis.annotations.Update;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,7 +38,7 @@ public class AuthenticationController {
 
     @ApiOperation(value = "用户登录", notes = "用户登录")
     @PostMapping("")
-    public RespR login(@RequestBody User user) {
+    public RespR login(@RequestBody @Validated({Update.class}) User user) {
         //获取用户名
         String userName = user.getUserName();
         //根据用户名获取用户信息

+ 10 - 6
src/main/java/com/jkcredit/invoice/controller/user/UserController.java

@@ -11,9 +11,13 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.ibatis.annotations.Update;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * @description:
  * @author: sunzhaoning
@@ -39,7 +43,7 @@ public class UserController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "用id", required = true, dataType = "Integer")
     })
-    public RespR user(@PathVariable Integer id, User user) {
+    public RespR user(@PathVariable @NotNull(message = "用户id不能为空")Integer id, User user) {
         if (!AuthenticationInterceptor.AUTH_ADMIN.equals(user.getRoleId()) && (user.getId().compareTo(id) != 0)) {
             return new RespR<>(false, "无权限");
         }
@@ -55,7 +59,7 @@ public class UserController {
     @DeleteMapping("/{id}")
     @ApiOperation(value = "根据用户名id删除用户信息", notes = "根据用户名id删除用户信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR userDel(@PathVariable Integer id) {
+    public RespR userDel(@PathVariable @NotNull(message = "用户id不能为空") Integer id) {
         if(null == id){
             return new RespR<>(false,"根据用户名id删除用户信息失败,请检查参数是否维护准确");
         }
@@ -72,7 +76,7 @@ public class UserController {
     @PostMapping
     @ApiOperation(value = "新增用户详细信息", notes = "新增用户详细信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR user(@RequestBody User user) {
+    public RespR user(@RequestBody @Validated User user) {
         user.setPassword(Md5Util.encrypt(user.getPassword()));
         User user1 = userService.selectUserByUserName(user.getUserName());
         if (null != user1) {
@@ -90,7 +94,7 @@ public class UserController {
     @PostMapping("/updateUser")
     @ApiOperation(value = "更新用户信息", notes = "更新用户信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateUser(@RequestBody User user) {
+    public RespR updateUser(@RequestBody @Validated User user) {
         if (user.getPassword() != null) {
             user.setPassword(Md5Util.encrypt(user.getPassword()));
         }
@@ -120,7 +124,7 @@ public class UserController {
     @PutMapping("/restPassword")
     @ApiOperation(value = "重置密码", notes = "重置密码")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateUserInfoPassWord(@RequestBody User user) {
+    public RespR updateUserInfoPassWord(@RequestBody @Validated({Update.class}) User user) {
         user.setPassword(Md5Util.encrypt(user.getPassword()));
         return userService.restPassword(user);
     }
@@ -134,7 +138,7 @@ public class UserController {
     @PutMapping("/lock")
     @ApiOperation(value = "修改锁定状态", notes = "修改锁定状态")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateLock(@RequestBody User user) {
+    public RespR updateLock(@RequestBody @Validated User user) {
         return userService.updateLock(user);
     }
 }

+ 3 - 0
src/main/java/com/jkcredit/invoice/model/entity/CustomerRecharge.java

@@ -1,5 +1,7 @@
 package com.jkcredit.invoice.model.entity;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * 客户充值记录
  * @author mumuxigua
@@ -16,6 +18,7 @@ public class CustomerRecharge {
 
     private Double beforeMony;
 
+    @NotNull(message = "充值记录不能为空")
     private Double rechargeMony;
 
     private String rechargeTime;

+ 27 - 0
src/main/java/com/jkcredit/invoice/model/entity/customer/CustomerRec.java

@@ -1,6 +1,10 @@
 package com.jkcredit.invoice.model.entity.customer;
 
 import cn.afterturn.easypoi.excel.annotation.Excel;
+import org.apache.ibatis.annotations.Insert;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotNull;
 
 /**
  * 客户备案信息
@@ -11,52 +15,71 @@ public class CustomerRec {
      * 客户名称
      */
     @Excel(name = "appKey")
+    @NotNull(groups = {Insert.class},message = "用户名称不能为空")
     public String customerName;
+
     private Long id;
     /**
      * 紧急联系人
      */
+    @NotNull(message = "紧急联系人不能为空")
+    @Length(max = 50 ,message = "紧急联系人格式有误")
     private String companyLeader;
 
     /**
      * 紧急联系人电话
      */
+    @NotNull(message = "紧急联系人电话不能为空")
+    @Length(max = 13,message = "紧急联系人电话格式有误")
     private String companyLeaderPhone;
 
     /**
      * 公司名称
      */
     @Excel(name = "公司名称")
+    @NotNull(groups = {Insert.class}, message = "公司名称不能为空")
+    @Length(groups = {Insert.class},max = 150 ,message = "公司名称格式有误")
     private String companyName;
 
     /**
      * 公司税号
      */
+    @NotNull(groups = {Insert.class},message = "公司税号不能为空")
+    @Length(groups = {Insert.class},max = 50 ,message = "公司税号格式有误")
     private String companyReferencenum;
 
     /**
      * 公司开户行
      */
+    @NotNull(message = "公司开户行不能为空")
+    @Length(max = 50 ,message = "公司开户行格式有误")
     private String companyOpenbank;
 
     /**
      * 公司开户行账号
      */
+    @NotNull(message = "公司开户行账号不能为空")
+    @Length(max = 50 ,message = "公司开户行账号格式有误")
     private String companyOpenbankAcc;
 
     /**
      * 公司地址
      */
+    @NotNull(message = "公司地址不能为空")
+    @Length(max = 100 ,message = "公司地址格式有误")
     private String companyAdress;
 
     /**
      * 公司电话
      */
+    @NotNull(message = "公司电话不能为空")
+    @Length(max = 100 ,message = "公司电话格式有误")
     private String companyPhone;
 
     /**
      * 1-行业用户 2-自营平台 3-合作商户
      */
+    @NotNull(message = "公司类型不能为空")
     private Integer companyType;
     /**
      * 1-快递
@@ -67,6 +90,7 @@ public class CustomerRec {
      * 6-其他
      * 运营范围
      */
+    @NotNull(message = "业务类型不能为空")
     private Integer operatingRangeType;
 
     /**
@@ -92,6 +116,7 @@ public class CustomerRec {
      * 业务类型 0 -自有车 1-外协车 2-无车
      */
     @Excel(name = "业务类型")
+    @NotNull(message = "业务类型不能为空")
     private String bussinessType;
 
     /*协议相关字段*/
@@ -99,11 +124,13 @@ public class CustomerRec {
     /**
      * 服务开始时间
      */
+    @NotNull(message = "服务开始时间不能为空")
     private String serviceStartTime;
 
     /**
      * 服务结束时间
      */
+    @NotNull(message = "服务结束时间不能为空")
     private String serviceEndTime;
 
 

+ 3 - 0
src/main/java/com/jkcredit/invoice/model/entity/manager/Param.java

@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -28,12 +29,14 @@ public class Param implements Serializable {
      * 参数名称
      */
     @ApiModelProperty(value = "参数名称")
+    @NotNull(message = "参数名称不能为空")
     private String paramName;
 
     /**
      * 参数值
      */
     @ApiModelProperty(value = "参数值")
+    @NotNull(message = "参数值不能为空")
     private String paramValue;
 
 

+ 9 - 0
src/main/java/com/jkcredit/invoice/model/entity/user/User.java

@@ -6,7 +6,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.apache.ibatis.annotations.Update;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -28,6 +30,7 @@ public class User implements Serializable {
      * 用户名
      */
     @ApiModelProperty(value = "用户名")
+    @NotNull(groups = {Update.class},message = "用户名不能为空")
     private String userName;
 
     /**
@@ -35,18 +38,21 @@ public class User implements Serializable {
      */
     @ApiModelProperty(value = "密码")
     @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
+    @NotNull(groups = {Update.class},message = "用户密码不能为空")
     private String password;
 
     /**
      * 姓名
      */
     @ApiModelProperty(value = "姓名")
+    @NotNull(message = "姓名不能为空")
     private String name;
 
     /**
      * 手机号
      */
     @ApiModelProperty(value = "手机号")
+    @NotNull(message = "手机号不能为空")
     private String phone;
 
     /**
@@ -58,12 +64,14 @@ public class User implements Serializable {
      * 企业名称
      */
     @ApiModelProperty(value = "企业名称")
+    @NotNull(message = "企业名称不能为空")
     private String company;
 
     /**
      * 角色id
      */
     @ApiModelProperty(value = "角色id")
+    @NotNull(message = "角色id不能为空")
     private String roleId;
 
     /**
@@ -83,6 +91,7 @@ public class User implements Serializable {
      * 锁定状态 0正常 1锁定,2停用
      */
     @ApiModelProperty(value = "锁定状态")
+    @NotNull(message = "锁定状态不能为空")
     private Integer isLock;
 
     /**