web端图片上传格式修订为对象数组,与小程序共用wxXXX字段,对象字段为uid与url

This commit is contained in:
林华觞
2025-07-22 10:59:04 +08:00
parent f146dd686c
commit 4252e44e40
17 changed files with 310 additions and 13 deletions

View File

@@ -0,0 +1,84 @@
package com.zf.foodpurchase.fdsafe.common;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zf.foodpurchase.common.core.domain.AjaxResult;
import com.zf.foodpurchase.common.core.redis.RedisCache;
import com.zf.foodpurchase.common.utils.StringUtils;
import com.zf.foodpurchase.wx.entity.Area;
import com.zf.foodpurchase.wx.service.IAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 全国省市县三级行政区域信息表 前端控制器
* </p>
*
* @author lilj
* @since 2024-11-14
*/
@Api(tags = "三级区划查询")
@RestController
@RequestMapping("/wx/area")
public class AreaController {
@Autowired
private IAreaService areaService;
@Autowired
private RedisCache redisCache;
/**
* 查询所有区划数据
*
* @return
*/
@ApiOperation("查询所有区划数据")
@GetMapping("listAll")
public AjaxResult listAll() {
List<Area> provinceList = areaService.queryAllArea();
return AjaxResult.success("查询成功", provinceList);
}
@ApiOperation("查询省/市/县级区划")
@GetMapping("queryByLevel")
public AjaxResult queryByLevel(Integer level) {
if (level == null) {
return AjaxResult.error("level不能为空");
}
LambdaQueryWrapper<Area> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Area::getLevel, level);
return AjaxResult.success("查询成功", areaService.list(queryWrapper));
}
@ApiOperation("根据区划编码查询区划信息")
@GetMapping("getArea")
public AjaxResult getArea(String areaCode) {
if (StringUtils.isBlank(areaCode)) {
return AjaxResult.error("areaCode不能为空");
}
LambdaQueryWrapper<Area> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Area::getAreaCode, areaCode);
Area area = areaService.getOne(queryWrapper);
return AjaxResult.success("查询成功", area);
}
@ApiOperation("根据区划编码查询本级以及上下级区划信息")
@GetMapping("getAreaDetail")
public AjaxResult getAreaDetail(String areaCode) {
if (StringUtils.isBlank(areaCode)) {
return AjaxResult.error("areaCode不能为空");
}
Area area = areaService.getAreaDetail(areaCode);
return AjaxResult.success("查询成功", area);
}
}

View File

@@ -6,10 +6,13 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.ISupplierService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.SupplierVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -36,12 +39,30 @@ public class SupplierController extends BaseController {
@PostMapping("/add")
public AjaxResult add(@RequestBody @Validated(AddGroup.class) SupplierVO supplierVO) {
// wxImage形式
List<WxImg> images = supplierVO.getWxLicenseImg();
if(!CollectionUtils.isEmpty( images)){
supplierVO.setLicenseImg(ArrayStringUtils.wxImgToArray(images));
}
images = supplierVO.getWxFoodLicenseImg();
if(!CollectionUtils.isEmpty( images)){
supplierVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(images));
}
return supplierService.saveVO(supplierVO);
}
// 接口需要划分:上架,信息编辑.
@PostMapping("/update")
public AjaxResult update(@RequestBody @Validated(UpdateGroup.class) SupplierVO supplierVO) {
// wxImage形式
List<WxImg> images = supplierVO.getWxLicenseImg();
if(!CollectionUtils.isEmpty( images)){
supplierVO.setLicenseImg(ArrayStringUtils.wxImgToArray(images));
}
images = supplierVO.getWxFoodLicenseImg();
if(!CollectionUtils.isEmpty( images)){
supplierVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(images));
}
return supplierService.updateVO(supplierVO);
}

View File

@@ -8,8 +8,11 @@ import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.entity.AccompanyMeal;
import com.zf.foodpurchase.fdsafe.service.IAccompanyMealService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.AccompanyMealVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,11 +43,21 @@ public class AccompanyMealController extends BaseController {
@RequestMapping("/add")
public AjaxResult add(@RequestBody @Validated(AddGroup.class) AccompanyMealVO accompanyMealVO) {
// wxImage形式
List<WxImg> imageList = accompanyMealVO.getWxAccompanyImage();
if(!CollectionUtils.isEmpty(imageList)){
accompanyMealVO.setAccompanyImage(ArrayStringUtils.wxImgToArray(accompanyMealVO.getWxAccompanyImage()));
}
return accompanyMealService.saveVO(accompanyMealVO);
}
@RequestMapping("/update")
public AjaxResult update(@RequestBody @Validated(UpdateGroup.class) AccompanyMealVO accompanyMealVO) {
// wxImage形式
List<WxImg> imageList = accompanyMealVO.getWxAccompanyImage();
if(!CollectionUtils.isEmpty(imageList)){
accompanyMealVO.setAccompanyImage(ArrayStringUtils.wxImgToArray(accompanyMealVO.getWxAccompanyImage()));
}
return accompanyMealService.updateVO(accompanyMealVO);
}

View File

@@ -7,8 +7,11 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.ICattenService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.CattenVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -16,7 +19,7 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author lilj
@@ -37,17 +40,35 @@ public class CattenController extends BaseController {
@PostMapping("/add")
public AjaxResult add(@Validated(AddGroup.class) @RequestBody CattenVO cattenVO) {
// wxImage形式
List<WxImg> imageList = cattenVO.getWxLicenseImg();
if(!CollectionUtils.isEmpty(imageList)){
cattenVO.setLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxLicenseImg()));
}
imageList = cattenVO.getWxFoodLicenseImg();
if(!CollectionUtils.isEmpty(imageList)){
cattenVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxFoodLicenseImg()));
}
return cattenService.saveVO(cattenVO);
}
@PostMapping("/update")
public AjaxResult update(@Validated(UpdateGroup.class) @RequestBody CattenVO cattenVO) {
// wxImage形式
List<WxImg> imageList = cattenVO.getWxLicenseImg();
if(!CollectionUtils.isEmpty(imageList)){
cattenVO.setLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxLicenseImg()));
}
imageList = cattenVO.getWxFoodLicenseImg();
if(!CollectionUtils.isEmpty(imageList)){
cattenVO.setFoodLicenseImg(ArrayStringUtils.wxImgToArray(cattenVO.getWxFoodLicenseImg()));
}
return cattenService.updateVO(cattenVO);
}
@GetMapping("/delete")
public AjaxResult delete(Integer cattenId) {
if(cattenId == null){
if (cattenId == null) {
return error("请选择要删除的食堂");
}
return cattenService.removeById(cattenId) ? success("删除成功") : error("删除失败");

View File

@@ -7,8 +7,11 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.IFoodSampleService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.FoodSampleVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -38,11 +41,21 @@ public class FoodSampleController extends BaseController {
@PostMapping("/add")
public AjaxResult add(@RequestBody @Validated(AddGroup.class) FoodSampleVO foodSampleVO) {
// wxImage形式
List<WxImg> imageList = foodSampleVO.getWxSaveImage();
if(!CollectionUtils.isEmpty(imageList)){
foodSampleVO.setSaveImg(ArrayStringUtils.wxImgToArray(imageList));
}
return foodSampleService.saveVO(foodSampleVO);
}
@PostMapping("/update")
public AjaxResult update(@RequestBody @Validated(UpdateGroup.class) FoodSampleVO foodSampleVO) {
// wxImage形式
List<WxImg> imageList = foodSampleVO.getWxSaveImage();
if(!CollectionUtils.isEmpty(imageList)){
foodSampleVO.setSaveImg(ArrayStringUtils.wxImgToArray(imageList));
}
return foodSampleService.updateVO(foodSampleVO);
}

View File

@@ -11,10 +11,13 @@ import com.zf.foodpurchase.fdsafe.mapper.MorningCheckInMapper;
import com.zf.foodpurchase.fdsafe.service.IMorningInspectionContentService;
import com.zf.foodpurchase.fdsafe.service.IMorningInspectionDetailService;
import com.zf.foodpurchase.fdsafe.service.impl.MorningInspectionContentServiceImpl;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.MorningInspectionDetailVO;
import com.zf.foodpurchase.fdsafe.vo.MorningTableHeaderVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.apache.commons.math3.analysis.function.Add;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -75,11 +78,21 @@ public class MorningInspectionDetailController extends BaseController {
@PostMapping("/add")
public AjaxResult add(@RequestBody @Validated({AddGroup.class}) MorningInspectionDetailVO morningInspectionDetailVO){
// wxImage形式
List<WxImg> images = morningInspectionDetailVO.getWxAbnormalImg();
if(!CollectionUtils.isEmpty( images)){
morningInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images));
}
return morningInspectionDetailService.saveVO(morningInspectionDetailVO);
}
@PostMapping("/update")
public AjaxResult update(@RequestBody @Validated({UpdateGroup.class}) MorningInspectionDetailVO morningInspectionDetailVO){
// wxImage形式
List<WxImg> images = morningInspectionDetailVO.getWxAbnormalImg();
if(!CollectionUtils.isEmpty( images)){
morningInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images));
}
return morningInspectionDetailService.updateVO(morningInspectionDetailVO);
}

View File

@@ -7,8 +7,11 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.IRubbishDealService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.RubbishDealVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -38,11 +41,21 @@ public class RubbishDealController extends BaseController {
@PostMapping("/add")
public AjaxResult add(@Validated(AddGroup.class) @RequestBody RubbishDealVO rubbishDealVO) {
// wxImage形式
List<WxImg> imageList = rubbishDealVO.getWxDealImg();
if(!CollectionUtils.isEmpty(imageList)){
rubbishDealVO.setDealImg(ArrayStringUtils.wxImgToArray(rubbishDealVO.getWxDealImg()));
}
return rubbishDealService.saveVO(rubbishDealVO);
}
@PostMapping("/update")
public AjaxResult update(@Validated(UpdateGroup.class) @RequestBody RubbishDealVO rubbishDealVO) {
// wxImage形式
List<WxImg> imageList = rubbishDealVO.getWxDealImg();
if(!CollectionUtils.isEmpty(imageList)){
rubbishDealVO.setDealImg(ArrayStringUtils.wxImgToArray(rubbishDealVO.getWxDealImg()));
}
return rubbishDealService.updateVO(rubbishDealVO);
}

View File

@@ -13,6 +13,7 @@ import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.ISchoolStaffService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.SchoolStaffVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
@@ -24,7 +25,7 @@ import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author lilj
@@ -40,27 +41,32 @@ public class SchoolStaffController extends BaseController {
public TableDataInfo pageList(SchoolStaffVO schoolStaffVO) {
startPage();
List<SchoolStaffVO> list = schoolStaffService.querySchoolStaffVO(schoolStaffVO);
if(!CollectionUtils.isEmpty(list)){
list.forEach(item->{
item.setHealthCertImg(ArrayStringUtils.stringToArray(item.getHealthCertImgStr()));
});
}
return getDataTable(list);
}
@PostMapping("/add")
public AjaxResult add(@Validated(AddGroup.class) @RequestBody SchoolStaffVO schoolStaffVO) {
// wxImage形式
List<WxImg> imageList = schoolStaffVO.getWxHealthCertImg();
if(!CollectionUtils.isEmpty(imageList)){
schoolStaffVO.setHealthCertImg(ArrayStringUtils.wxImgToArray(schoolStaffVO.getWxHealthCertImg()));
}
return schoolStaffService.saveVO(schoolStaffVO);
}
@PostMapping("/update")
public AjaxResult update(@Validated(UpdateGroup.class) @RequestBody SchoolStaffVO schoolStaffVO) {
return schoolStaffService.updateVO(schoolStaffVO);
// wxImage形式
List<WxImg> imageList = schoolStaffVO.getWxHealthCertImg();
if(!CollectionUtils.isEmpty(imageList)){
schoolStaffVO.setHealthCertImg(ArrayStringUtils.wxImgToArray(schoolStaffVO.getWxHealthCertImg()));
}
return schoolStaffService.updateVO(schoolStaffVO);
}
@GetMapping("/delete")
public AjaxResult delete(Integer staffId) {
if(staffId == null){
if (staffId == null) {
return error("请选择要删除的学校人员");
}
boolean flag = schoolStaffService.removeById(staffId);

View File

@@ -7,9 +7,12 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.ISelfInspectionRecordService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.SelfInspectionDetailVO;
import com.zf.foodpurchase.fdsafe.vo.SelfInspectionRecordVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -39,11 +42,31 @@ public class SelfInspectionRecordController extends BaseController {
@PostMapping("/add")
public AjaxResult add(@RequestBody @Validated(AddGroup.class) SelfInspectionRecordVO selfInspectionRecordVO) {
// wxImage形式
List<SelfInspectionDetailVO> selfInspectionDetailVOList = selfInspectionRecordVO.getSelfInspectionDetailVOList();
if(!CollectionUtils.isEmpty(selfInspectionDetailVOList)){
for (SelfInspectionDetailVO selfInspectionDetailVO : selfInspectionDetailVOList) {
List<WxImg> images = selfInspectionDetailVO.getWxAbnormalImg();
if(!CollectionUtils.isEmpty( images)){
selfInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images));
}
}
}
return selfInspectionRecordService.saveVO(selfInspectionRecordVO);
}
@PostMapping("/update")
public AjaxResult update(@RequestBody @Validated(UpdateGroup.class) SelfInspectionRecordVO selfInspectionRecordVO) {
// wxImage形式
List<SelfInspectionDetailVO> selfInspectionDetailVOList = selfInspectionRecordVO.getSelfInspectionDetailVOList();
if(!CollectionUtils.isEmpty(selfInspectionDetailVOList)){
for (SelfInspectionDetailVO selfInspectionDetailVO : selfInspectionDetailVOList) {
List<WxImg> images = selfInspectionDetailVO.getWxAbnormalImg();
if(!CollectionUtils.isEmpty( images)){
selfInspectionDetailVO.setAbnormalImg(ArrayStringUtils.wxImgToArray(images));
}
}
}
return selfInspectionRecordService.updateVO(selfInspectionRecordVO);
}

View File

@@ -8,10 +8,13 @@ import com.zf.foodpurchase.common.valigroud.AddGroup;
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
import com.zf.foodpurchase.fdsafe.service.ISupplierDeliveryService;
import com.zf.foodpurchase.fdsafe.service.ISupplierService;
import com.zf.foodpurchase.fdsafe.utils.ArrayStringUtils;
import com.zf.foodpurchase.fdsafe.vo.SchoolDeliveryVO;
import com.zf.foodpurchase.fdsafe.vo.SupplierDeliveryAddUpdateVO;
import com.zf.foodpurchase.fdsafe.vo.SupplierDeliveryVO;
import com.zf.foodpurchase.fdsafe.vo.WxImg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -49,6 +52,11 @@ public class SupplierDeliveryController extends BaseController {
@PostMapping("/schoolSignDelivery")
public AjaxResult schoolUpdateDelivery(@RequestBody @Validated(UpdateGroup.class) SchoolDeliveryVO schoolDeliveryVO){
// wxImage形式
List<WxImg> images = schoolDeliveryVO.getWxSignImage();
if(!CollectionUtils.isEmpty( images)){
schoolDeliveryVO.setSignImage(ArrayStringUtils.wxImgToArray(images));
}
return supplierDeliveryService.schoolUpdateDelivery(schoolDeliveryVO);
}