فهرست منبع

controller层增加信息校验

mashengyi 2 سال پیش
والد
کامیت
e104b181b6

+ 13 - 1
src/main/java/com/jkcredit/invoice/controller/business/CustomerController.java

@@ -127,6 +127,9 @@ public class CustomerController {
     @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客户信息导出信息有误");
+        }
         CustomerRec customerRec = new CustomerRec();
         customerRec.setCustomerName(customerName);
         customerRec.setCompanyBelongName(companyBelongName);
@@ -171,6 +174,9 @@ public class CustomerController {
     @LoginRequired
     public RespR addCustomer(@RequestBody Customer customer, User user) {
         checkHasAuthRole.checkCustomerRole(user, customer.getCustomerName());
+        if(!checkHasAuthRole.checkMessage(customer.getCustomerName())){
+            return new RespR(false, "客户添加失败,请查看数据是否维护准确");
+        }
         return new RespR(customerService.addCustomers(customer), "客户添加失败,请查看是否重复");
     }
 
@@ -281,7 +287,10 @@ public class CustomerController {
     @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,"充值记录为空");
+        }
         return new RespR(customerService.customRecharge(customerRecharge));
     }
 
@@ -486,6 +495,9 @@ public class CustomerController {
     @ApiOperation(value = "用户换卡信息查询", notes = "用户换卡信息查询")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR customerChangeInfo(String applyId) {
+        if(!checkHasAuthRole.checkMessage(applyId)){
+            return new RespR(false, "用户换卡信息查询失败,请查看数据是否维护准确");
+        }
         List<Map<String, String>> cards = customerChangeInfoService.selectChangeCards(applyId);
         return new RespR(cards);
     }

+ 15 - 0
src/main/java/com/jkcredit/invoice/controller/business/NoCarController.java

@@ -226,6 +226,10 @@ public class NoCarController {
     @ApiOperation(value = "重新获取发票并更新状态", notes = "重新获取发票并更新状态")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR updateStatus(String noCarWayBillStr) {
+        if(!checkHasAuthRole.checkMessage(noCarWayBillStr)){
+            return new RespR(false, "重新获取发票并更新状态失败,请查看数据是否维护准确");
+        }
+
         List<NoCarWayBill> noCarWayBills = JSON.parseArray(noCarWayBillStr, NoCarWayBill.class);
 
         if (noCarWayBills != null && noCarWayBills.size() > 0) {
@@ -413,6 +417,9 @@ public class NoCarController {
     @LoginRequired
     public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file, String customerName, User user) {
         try {
+            if(!checkHasAuthRole.checkMessage(customerName)){
+                return new RespR(false, "批量运单导入失败,请查看数据是否维护准确");
+            }
             checkHasAuthRole.checkCustomerRole(user, customerName);
             ImportParams params = new ImportParams();
             params.setTitleRows(1);
@@ -439,6 +446,9 @@ public class NoCarController {
     @LoginRequired
     public RespR batchImprotHistoryBillWay(@RequestParam("file") MultipartFile file, String customerName, User user) {
         try {
+            if(!checkHasAuthRole.checkMessage(customerName)){
+                return new RespR(false, "批量历史运单导入失败,请查看数据是否维护准确");
+            }
             checkHasAuthRole.checkCustomerRole(user, customerName);
             ImportParams params = new ImportParams();
             params.setTitleRows(1);
@@ -465,6 +475,11 @@ public class NoCarController {
     @ApiOperation(value = "批量运单结束", notes = "批量运单结束")
     @LoginRequired
     public RespR batchImprotEndBillWay(@RequestParam("file") MultipartFile file, String customerName, User user) {
+
+        if(!checkHasAuthRole.checkMessage(customerName)){
+            return new RespR(false, "批量运单结束失败,请查看数据是否维护准确");
+        }
+
         checkHasAuthRole.checkCustomerRole(user, customerName);
         try {
             ImportParams params = new ImportParams();

+ 8 - 0
src/main/java/com/jkcredit/invoice/controller/business/SelfCarController.java

@@ -31,6 +31,7 @@ import com.jkcredit.invoice.service.selfcar.SelfCarTradeService;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
@@ -45,6 +46,7 @@ import static com.jkcredit.invoice.common.CommonConst.NULL;
 @Api(tags = "自有车操作")
 @RestController
 @RequestMapping(value = {"/selfCar"})
+@Slf4j
 /**
  * @Description 自有车操作
  * @Author mashengyi
@@ -91,6 +93,9 @@ public class SelfCarController {
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR selfCarUnBind(String etcNum) {
         try {
+            if(!checkHasAuthRole.checkMessage(etcNum)){
+                return new RespR(false, "解绑etc卡失败,请查看数据是否维护准确");
+            }
             RespR respR = selfCarBussService.selfCarUnBind(etcNum);
             return respR;
         } catch (Exception e) {
@@ -200,6 +205,9 @@ public class SelfCarController {
     @LoginRequired
     public void updateTrades(String selfCarTradesStr, 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) {

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

@@ -27,7 +27,6 @@ public class UserController {
 
     @Autowired
     private UserService userService;
-
     /**
      * 通过ID查询用户信息
      *
@@ -57,6 +56,9 @@ public class UserController {
     @ApiOperation(value = "根据用户名id删除用户信息", notes = "根据用户名id删除用户信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR userDel(@PathVariable Integer id) {
+        if(null == id){
+            return new RespR<>(false,"根据用户名id删除用户信息失败,请检查参数是否维护准确");
+        }
         User sysUser = userService.getById(id);
         return new RespR<>(userService.deleteUserById(sysUser));
     }

+ 8 - 0
src/main/java/com/jkcredit/invoice/service/lowerservice/CheckHasAuthRole.java

@@ -23,4 +23,12 @@ public interface CheckHasAuthRole {
      * @param customerName
      */
     void checkCustomerRole(User user, String customerName);
+
+
+    /**
+     * 空信息校验
+     *
+     * @param args
+     */
+    boolean checkMessage(String ... args);
 }

+ 11 - 0
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/CheckHasAuthRoleImpl.java

@@ -5,6 +5,7 @@ import com.jkcredit.invoice.mapper.customer.CustomerRecMapper;
 import com.jkcredit.invoice.model.entity.customer.CustomerRec;
 import com.jkcredit.invoice.model.entity.user.User;
 import com.jkcredit.invoice.service.lowerservice.CheckHasAuthRole;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -40,4 +41,14 @@ public class CheckHasAuthRoleImpl implements CheckHasAuthRole {
             throw new RuntimeException("非法的资源请求");
         }
     }
+
+    @Override
+    public boolean checkMessage(String... args) {
+        for (String arg : args) {
+            if (StringUtils.isBlank(arg)){
+                return false;
+            }
+        }
+        return true;
+    }
 }