web端图片上传格式修订为对象数组,与小程序共用wxXXX字段,对象字段为uid与url
This commit is contained in:
@@ -39,6 +39,8 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
|
||||
list.forEach(item -> {
|
||||
item.setLicenseImg(ArrayStringUtils.stringToArray(item.getLicenseImgStr()));
|
||||
item.setFoodLicenseImg(ArrayStringUtils.stringToArray(item.getFoodLicenseImgStr()));
|
||||
item.setWxLicenseImg(ArrayStringUtils.arrayToWxImgList(item.getLicenseImg()));
|
||||
item.setWxFoodLicenseImg(ArrayStringUtils.arrayToWxImgList(item.getFoodLicenseImg()));
|
||||
|
||||
String areaCodeStr = item.getAreaCodeStr();
|
||||
if(StringUtils.isNotBlank(areaCodeStr)){
|
||||
|
||||
@@ -5,7 +5,9 @@ package com.zf.foodpurchase.fdsafe.utils;
|
||||
* @date:2025/5/9
|
||||
*/
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.zf.foodpurchase.common.utils.StringUtils;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ImageVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.WxImg;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -71,4 +73,61 @@ public class ArrayStringUtils {
|
||||
}
|
||||
return wxImgList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转ImageVO数组
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static List<ImageVO> stringToImageVOArray(String str) {
|
||||
List<ImageVO> imageVOList = new ArrayList<>();
|
||||
if(StringUtils.isBlank(str)){
|
||||
return imageVOList;
|
||||
}
|
||||
|
||||
if(!str.contains(",")){
|
||||
ImageVO imageVO = new ImageVO();
|
||||
imageVO.setUrl(str);
|
||||
imageVOList.add(imageVO);
|
||||
return imageVOList;
|
||||
}
|
||||
String[] strArray = str.trim().split(",");
|
||||
for (int i = 0; i < strArray.length; i++){
|
||||
ImageVO imageVO = new ImageVO();
|
||||
imageVO.setUrl(strArray[i].trim());
|
||||
imageVOList.add(imageVO);
|
||||
}
|
||||
return imageVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageVO数组转字符串
|
||||
* @param imageVOList
|
||||
* @return
|
||||
*/
|
||||
public static String imageVOArrayToString(List<ImageVO> imageVOList) {
|
||||
if(imageVOList == null || imageVOList.size() == 0){
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int size = imageVOList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ImageVO imageVO = imageVOList.get(i);
|
||||
if(imageVO != null && StringUtils.isNotBlank(imageVO.getUrl())){
|
||||
String url = imageVO.getUrl();
|
||||
sb.append(url.trim());
|
||||
if(i != size - 1){
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String urls = "http://1,http://2";
|
||||
List<ImageVO> imageVOList = stringToImageVOArray(urls);
|
||||
System.out.println(JSONObject.toJSONString(imageVOList));
|
||||
System.out.println(imageVOArrayToString(imageVOList));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class CattenVO extends CommonVO implements Serializable {
|
||||
/**
|
||||
* 营业执照
|
||||
*/
|
||||
@NotEmpty(message = "营业执照图片不能为空", groups = { AddGroup.class, UpdateGroup.class})
|
||||
// @NotEmpty(message = "营业执照图片不能为空", groups = { AddGroup.class, UpdateGroup.class})
|
||||
private String[] licenseImg;
|
||||
private String licenseImgStr;
|
||||
// @NotEmpty(message = "营业执照图片不能为空", groups = { AddGroup.class, UpdateGroup.class, WxAddGroup.class, WxUpdateGroup.class})
|
||||
@@ -77,7 +77,7 @@ public class CattenVO extends CommonVO implements Serializable {
|
||||
/**
|
||||
* 食品许可证
|
||||
*/
|
||||
@NotEmpty(message = "食品许可证图片不能为空", groups = { AddGroup.class, UpdateGroup.class})
|
||||
// @NotEmpty(message = "食品许可证图片不能为空", groups = { AddGroup.class, UpdateGroup.class})
|
||||
private String[] foodLicenseImg;
|
||||
private String foodLicenseImgStr;
|
||||
// @NotEmpty(message = "食品许可证图片不能为空", groups = { AddGroup.class, UpdateGroup.class, WxAddGroup.class, WxUpdateGroup.class})
|
||||
|
||||
@@ -71,7 +71,7 @@ public class FoodSampleVO extends CommonVO implements Serializable {
|
||||
/**
|
||||
* 留样照片
|
||||
*/
|
||||
@NotEmpty(message = "留样照片不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
// @NotEmpty(message = "留样照片不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
private String[] saveImg;
|
||||
private String saveImgStr;
|
||||
// @NotEmpty(message = "留样照片不能为空", groups = {WxUpdateGroup.class, WxAddGroup.class})
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
import com.zf.foodpurchase.common.utils.uuid.UUID;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2025/7/21
|
||||
*/
|
||||
@Data
|
||||
public class ImageVO {
|
||||
private String uid=UUID.fastUUID().toString();
|
||||
private String url;
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
@@ -82,12 +83,15 @@ public class SupplierVO extends CommonVO implements Serializable {
|
||||
*/
|
||||
private String[] licenseImg;
|
||||
private String licenseImgStr;
|
||||
private List<WxImg> wxLicenseImg;
|
||||
|
||||
/**
|
||||
* 食品经营许可证照片
|
||||
*/
|
||||
private String[] foodLicenseImg;
|
||||
private String foodLicenseImgStr;
|
||||
private List<WxImg> wxFoodLicenseImg;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
import com.zf.foodpurchase.common.utils.uuid.UUID;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -9,4 +10,5 @@ import lombok.Data;
|
||||
@Data
|
||||
public class WxImg {
|
||||
private String url;
|
||||
private String uid= UUID.fastUUID().toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user