diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/edu/SupplierController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/edu/SupplierController.java index 1660c08..0e1dfd9 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/edu/SupplierController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/edu/SupplierController.java @@ -56,10 +56,14 @@ public class SupplierController extends BaseController { List images = supplierVO.getWxLicenseImg(); if(!CollectionUtils.isEmpty( images)){ supplierVO.setLicenseImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + supplierVO.setLicenseImg(null); } images = supplierVO.getWxFoodLicenseImg(); if(!CollectionUtils.isEmpty( images)){ supplierVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + supplierVO.setFoodLicenseImg(null); } return supplierService.saveVO(supplierVO); } @@ -78,10 +82,14 @@ public class SupplierController extends BaseController { List images = supplierVO.getWxLicenseImg(); if(!CollectionUtils.isEmpty( images)){ supplierVO.setLicenseImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + supplierVO.setLicenseImg(null); } images = supplierVO.getWxFoodLicenseImg(); if(!CollectionUtils.isEmpty( images)){ supplierVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + supplierVO.setFoodLicenseImg(null); } return supplierService.updateVO(supplierVO); } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/AccompanyMealController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/AccompanyMealController.java index 0cad90f..3f91660 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/AccompanyMealController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/AccompanyMealController.java @@ -58,6 +58,8 @@ public class AccompanyMealController extends BaseController { List imageList = accompanyMealVO.getWxAccompanyImage(); if(!CollectionUtils.isEmpty(imageList)){ accompanyMealVO.setAccompanyImage(ArrayStringUtils.wxImgToArray(accompanyMealVO.getWxAccompanyImage())); + }else{ + accompanyMealVO.setAccompanyImage(null); } return accompanyMealService.saveVO(accompanyMealVO); } @@ -75,6 +77,8 @@ public class AccompanyMealController extends BaseController { List imageList = accompanyMealVO.getWxAccompanyImage(); if(!CollectionUtils.isEmpty(imageList)){ accompanyMealVO.setAccompanyImage(ArrayStringUtils.wxImgToArray(accompanyMealVO.getWxAccompanyImage())); + }else{ + accompanyMealVO.setAccompanyImage(null); } return accompanyMealService.updateVO(accompanyMealVO); } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/CattenController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/CattenController.java index 2ca3f7e..5770e6c 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/CattenController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/CattenController.java @@ -42,6 +42,12 @@ public class CattenController extends BaseController { return getDataTable(list); } + /** + * 营业执照,食品许可证图片不能为空 + * @param cattenVO + * @return + */ + @PostMapping("/add") public AjaxResult add(@Validated(AddGroup.class) @RequestBody CattenVO cattenVO) { SysUser user = getLoginUser().getUser(); @@ -51,18 +57,29 @@ public class CattenController extends BaseController { return error("非学校账号无法添加食堂"); } } + // 图片校验不能为空 // wxImage形式 List imageList = cattenVO.getWxLicenseImg(); - if(!CollectionUtils.isEmpty(imageList)){ + if(CollectionUtils.isEmpty(imageList)){ + return error("营业执照图片不能为空"); + }else{ cattenVO.setLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxLicenseImg())); } + imageList = cattenVO.getWxFoodLicenseImg(); - if(!CollectionUtils.isEmpty(imageList)){ + if(CollectionUtils.isEmpty(imageList)){ + return error("食品许可证图片不能为空"); + }else{ cattenVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxFoodLicenseImg())); } return cattenService.saveVO(cattenVO); } + /** + * 营业执照,食品许可证图片不能为空 + * @param cattenVO + * @return + */ @PostMapping("/update") public AjaxResult update(@Validated(UpdateGroup.class) @RequestBody CattenVO cattenVO) { SysUser user = getLoginUser().getUser(); @@ -72,13 +89,19 @@ public class CattenController extends BaseController { return error("非学校账号无法修改食堂信息"); } } + // 图片校验不能为空 // wxImage形式 List imageList = cattenVO.getWxLicenseImg(); - if(!CollectionUtils.isEmpty(imageList)){ + if(CollectionUtils.isEmpty(imageList)){ + return error("营业执照图片不能为空"); + }else{ cattenVO.setLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxLicenseImg())); } + imageList = cattenVO.getWxFoodLicenseImg(); - if(!CollectionUtils.isEmpty(imageList)){ + if(CollectionUtils.isEmpty(imageList)){ + return error("食品许可证图片不能为空"); + }else{ cattenVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxFoodLicenseImg())); } return cattenService.updateVO(cattenVO); diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/FoodSampleController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/FoodSampleController.java index 1749850..f284320 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/FoodSampleController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/FoodSampleController.java @@ -56,6 +56,8 @@ public class FoodSampleController extends BaseController { List imageList = foodSampleVO.getWxSaveImg(); if(!CollectionUtils.isEmpty(imageList)){ foodSampleVO.setSaveImg(ArrayStringUtils.wxImgToArray(imageList)); + }else{ + return error("留样图片不能为空"); } return foodSampleService.saveVO(foodSampleVO); } @@ -73,6 +75,8 @@ public class FoodSampleController extends BaseController { List imageList = foodSampleVO.getWxSaveImg(); if(!CollectionUtils.isEmpty(imageList)){ foodSampleVO.setSaveImg(ArrayStringUtils.wxImgToArray(imageList)); + }else{ + return error("留样图片不能为空"); } return foodSampleService.updateVO(foodSampleVO); } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/MorningInspectionDetailController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/MorningInspectionDetailController.java index 52f20c4..7be6f5a 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/MorningInspectionDetailController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/MorningInspectionDetailController.java @@ -95,6 +95,8 @@ public class MorningInspectionDetailController extends BaseController { List images = morningInspectionDetailVO.getWxAbnormalImg(); if(!CollectionUtils.isEmpty( images)){ morningInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + morningInspectionDetailVO.setAbnormalImg(null); } return morningInspectionDetailService.saveVO(morningInspectionDetailVO); } @@ -112,6 +114,8 @@ public class MorningInspectionDetailController extends BaseController { List images = morningInspectionDetailVO.getWxAbnormalImg(); if(!CollectionUtils.isEmpty( images)){ morningInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + morningInspectionDetailVO.setAbnormalImg(null); } return morningInspectionDetailService.updateVO(morningInspectionDetailVO); } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/RubbishDealController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/RubbishDealController.java index 566531f..bf4abb0 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/RubbishDealController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/RubbishDealController.java @@ -56,6 +56,8 @@ public class RubbishDealController extends BaseController { List imageList = rubbishDealVO.getWxDealImg(); if(!CollectionUtils.isEmpty(imageList)){ rubbishDealVO.setDealImg(ArrayStringUtils.wxImgToArray(rubbishDealVO.getWxDealImg())); + }else{ + rubbishDealVO.setDealImg(null); } return rubbishDealService.saveVO(rubbishDealVO); } @@ -73,6 +75,8 @@ public class RubbishDealController extends BaseController { List imageList = rubbishDealVO.getWxDealImg(); if(!CollectionUtils.isEmpty(imageList)){ rubbishDealVO.setDealImg(ArrayStringUtils.wxImgToArray(rubbishDealVO.getWxDealImg())); + }else{ + rubbishDealVO.setDealImg(null); } return rubbishDealService.updateVO(rubbishDealVO); } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SchoolStaffController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SchoolStaffController.java index aeced88..896bbe5 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SchoolStaffController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SchoolStaffController.java @@ -61,6 +61,8 @@ public class SchoolStaffController extends BaseController { List imageList = schoolStaffVO.getWxHealthCertImg(); if(!CollectionUtils.isEmpty(imageList)){ schoolStaffVO.setHealthCertImg(ArrayStringUtils.wxImgToArray(schoolStaffVO.getWxHealthCertImg())); + }else{ + return error("健康证图片不能为空"); } return schoolStaffService.saveVO(schoolStaffVO); } @@ -78,6 +80,8 @@ public class SchoolStaffController extends BaseController { List imageList = schoolStaffVO.getWxHealthCertImg(); if(!CollectionUtils.isEmpty(imageList)){ schoolStaffVO.setHealthCertImg(ArrayStringUtils.wxImgToArray(schoolStaffVO.getWxHealthCertImg())); + }else{ + return error("健康证图片不能为空"); } return schoolStaffService.updateVO(schoolStaffVO); } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SelfInspectionRecordController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SelfInspectionRecordController.java index 5edab7f..72c759b 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SelfInspectionRecordController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/school/SelfInspectionRecordController.java @@ -60,6 +60,8 @@ public class SelfInspectionRecordController extends BaseController { List images = selfInspectionDetailVO.getWxAbnormalImg(); if(!CollectionUtils.isEmpty( images)){ selfInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + selfInspectionDetailVO.setAbnormalImg(null); } } } @@ -82,6 +84,8 @@ public class SelfInspectionRecordController extends BaseController { List images = selfInspectionDetailVO.getWxAbnormalImg(); if(!CollectionUtils.isEmpty( images)){ selfInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images)); + }else{ + selfInspectionDetailVO.setAbnormalImg(null); } } } diff --git a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/supplier/SupplierDeliveryItemController.java b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/supplier/SupplierDeliveryItemController.java index f141593..fbf5632 100644 --- a/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/supplier/SupplierDeliveryItemController.java +++ b/fp-admin/src/main/java/com/zf/foodpurchase/fdsafe/web/supplier/SupplierDeliveryItemController.java @@ -67,6 +67,8 @@ public class SupplierDeliveryItemController extends BaseController { List images = supplierDeliveryItemUpdateVO.getWxCheckReportImage(); if(!CollectionUtils.isEmpty( images)){ supplierDeliveryItemUpdateVO.setCheckReportImage(ArrayStringUtils.wxImgToArray(images)); + }else{ + supplierDeliveryItemUpdateVO.setCheckReportImage(null); } return supplierDeliveryItemService.updateVO(supplierDeliveryItemUpdateVO); } diff --git a/fp-framework/src/main/java/com/zf/foodpurchase/framework/web/exception/GlobalExceptionHandler.java b/fp-framework/src/main/java/com/zf/foodpurchase/framework/web/exception/GlobalExceptionHandler.java index 08ac4e2..754dcb5 100644 --- a/fp-framework/src/main/java/com/zf/foodpurchase/framework/web/exception/GlobalExceptionHandler.java +++ b/fp-framework/src/main/java/com/zf/foodpurchase/framework/web/exception/GlobalExceptionHandler.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.exc.InvalidFormatException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.http.HttpMessage; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.security.access.AccessDeniedException; @@ -24,6 +25,8 @@ import com.zf.foodpurchase.common.exception.ServiceException; import com.zf.foodpurchase.common.utils.StringUtils; import com.zf.foodpurchase.common.utils.html.EscapeUtil; +import java.sql.DataTruncation; + /** * 全局异常处理器 * @@ -34,6 +37,31 @@ public class GlobalExceptionHandler { private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class); + /** + * JSON入参序列化异常HttpMessageNotReadableException + */ + /** + * 权限校验异常 + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + public AjaxResult handleHttpMessageNotReadableException(HttpMessageNotReadableException e, HttpServletRequest request) + { + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',JSON入参序列化异常'{}'", requestURI, e.getMessage()); + return AjaxResult.error(HttpStatus.ERROR, "系统异常,请联系管理员"); + } + + /** + * 数据库异常处理:DataTruncation + */ + @ExceptionHandler(DataIntegrityViolationException.class) + public AjaxResult handleDataIntegrityViolationException(DataIntegrityViolationException e, HttpServletRequest request) + { + String requestURI = request.getRequestURI(); + log.error("请求地址'{}',数据库异常'{}'", requestURI, e.getMessage()); + return AjaxResult.error(HttpStatus.ERROR, "系统异常,请联系管理员"); + } + /** * 权限校验异常 */ diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/AccompanyMeal.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/AccompanyMeal.java index 39eef6d..e136b0a 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/AccompanyMeal.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/AccompanyMeal.java @@ -1,10 +1,8 @@ package com.zf.foodpurchase.fdsafe.entity; -import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.util.Date; @@ -85,8 +83,9 @@ public class AccompanyMeal implements Serializable { private String feedBack; /** - * 陪餐照片 + * 陪餐照片: 为空时也会进行更新 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String accompanyImage; /** diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/MorningInspectionDetail.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/MorningInspectionDetail.java index 714b4c3..c976f29 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/MorningInspectionDetail.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/MorningInspectionDetail.java @@ -1,10 +1,8 @@ package com.zf.foodpurchase.fdsafe.entity; -import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.util.Date; @@ -56,8 +54,9 @@ public class MorningInspectionDetail implements Serializable { private String remark; /** - * 问题照片 + * 问题照片:为null也修改 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String abnormalImg; /** diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/RubbishDeal.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/RubbishDeal.java index bc4c339..3fa0c62 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/RubbishDeal.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/RubbishDeal.java @@ -1,10 +1,8 @@ package com.zf.foodpurchase.fdsafe.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.util.Date; @@ -64,8 +62,9 @@ public class RubbishDeal implements Serializable { private String recycleCompany; /** - * 回收图片 + * 回收图片,为空时也会更新 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String dealImg; /** diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SelfInspectionDetail.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SelfInspectionDetail.java index 2736333..dbefba2 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SelfInspectionDetail.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SelfInspectionDetail.java @@ -1,10 +1,8 @@ package com.zf.foodpurchase.fdsafe.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.util.Date; @@ -53,8 +51,9 @@ public class SelfInspectionDetail implements Serializable { private String remark; /** - * 问题图片 + * 问题图片:为null也更新 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String abnormalImg; /** diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/Supplier.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/Supplier.java index c540366..43f8407 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/Supplier.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/Supplier.java @@ -1,10 +1,8 @@ package com.zf.foodpurchase.fdsafe.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.util.Date; @@ -64,13 +62,15 @@ public class Supplier implements Serializable { private String concatPhone; /** - * 营业执照照片 + * 营业执照照片:为null也进行更新 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String licenseImg; /** - * 食品经营许可证照片 + * 食品经营许可证照片:为null也进行更新 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String foodLicenseImg; /** diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SupplierDeliveryItem.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SupplierDeliveryItem.java index 9879787..ced1712 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SupplierDeliveryItem.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/entity/SupplierDeliveryItem.java @@ -1,10 +1,8 @@ package com.zf.foodpurchase.fdsafe.entity; -import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import java.util.Date; @@ -64,8 +62,9 @@ public class SupplierDeliveryItem implements Serializable { private String inImage; /** - * 检测报告图片 + * 检测报告图片:为null时也进行更新 */ + @TableField(updateStrategy = FieldStrategy.IGNORED) private String checkReportImage; /** diff --git a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/vo/SupplierVO.java b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/vo/SupplierVO.java index e090e26..5e2b156 100644 --- a/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/vo/SupplierVO.java +++ b/fp-system/src/main/java/com/zf/foodpurchase/fdsafe/vo/SupplierVO.java @@ -75,7 +75,7 @@ public class SupplierVO extends CommonVO implements Serializable { * 联系电话 */ @NotBlank(message = "联系电话不能为空", groups = {UpdateGroup.class, AddGroup.class}) - @Phone(message = "联系电话格式不正确") + @Phone(message = "联系电话格式不正确", groups = {UpdateGroup.class, AddGroup.class}) private String concatPhone; /**