farm模块-多个图片地址转换为集合

This commit is contained in:
顾君禹
2025-08-17 18:38:33 +08:00
parent 626560d6e2
commit ee02652a71
25 changed files with 907 additions and 351 deletions

View File

@@ -5,6 +5,7 @@ import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import cn.idev.excel.annotation.*;
@Schema(description = "管理后台 - 企业信息 Response VO")
@@ -48,14 +49,20 @@ public class CompanyInfoRespVO {
@ExcelProperty("网店地址")
private String introduce;
@Schema(description = "宣传图片")
@Schema(description = "宣传图片(逗号分隔的字符串)")
@ExcelProperty("宣传图片")
private String publicityImage;
@Schema(description = "企业logo")
@Schema(description = "宣传图片集合")
private List<String> publicityImageList;
@Schema(description = "企业logo(逗号分隔的字符串)")
@ExcelProperty("企业logo")
private String logoImage;
@Schema(description = "企业logo集合")
private List<String> logoImageList;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;

View File

@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.farm.controller.admin.companyinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List;
@Schema(description = "管理后台 - 企业信息新增/修改 Request VO")
@Data
public class CompanyInfoSaveReqVO {
@@ -34,12 +36,18 @@ public class CompanyInfoSaveReqVO {
@Schema(description = "网店地址")
private String introduce;
@Schema(description = "宣传图片")
@Schema(description = "宣传图片(逗号分隔的字符串)")
private String publicityImage;
@Schema(description = "企业logo")
@Schema(description = "宣传图片集合")
private List<String> publicityImageList;
@Schema(description = "企业logo(逗号分隔的字符串)")
private String logoImage;
@Schema(description = "企业logo集合")
private List<String> logoImageList;
@Schema(description = "基地id", example = "25213")
private String baseId;

View File

@@ -5,6 +5,7 @@ import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import cn.idev.excel.annotation.*;
@Schema(description = "管理后台 - 种植中心-农事基地-农事记录 Response VO")
@@ -56,10 +57,13 @@ public class FarmingRecordRespVO {
@ExcelProperty("执行反馈-备注")
private String feedbackNotes;
@Schema(description = "执行反馈-图片URL", example = "https://www.iocoder.cn")
@Schema(description = "执行反馈-图片URL(逗号分隔的字符串)", example = "https://www.iocoder.cn")
@ExcelProperty("执行反馈-图片URL")
private String feedbackImageUrl;
@Schema(description = "执行反馈-图片URL集合")
private List<String> feedbackImageUrlList;
@Schema(description = "逻辑删除标识符", example = "1")
@ExcelProperty("逻辑删除标识符")
private Boolean delStatus;

View File

@@ -5,6 +5,7 @@ import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 种植中心-农事基地-农事记录新增/修改 Request VO")
@Data
@@ -43,9 +44,12 @@ public class FarmingRecordSaveReqVO {
@Schema(description = "执行反馈-备注")
private String feedbackNotes;
@Schema(description = "执行反馈-图片URL", example = "https://www.iocoder.cn")
@Schema(description = "执行反馈-图片URL(逗号分隔的字符串)", example = "https://www.iocoder.cn")
private String feedbackImageUrl;
@Schema(description = "执行反馈-图片URL集合")
private List<String> feedbackImageUrlList;
@Schema(description = "逻辑删除标识符", example = "1")
private Boolean delStatus;

View File

@@ -5,6 +5,7 @@ import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import cn.idev.excel.annotation.*;
@Schema(description = "管理后台 - 基础信息 Response VO")
@@ -12,7 +13,7 @@ import cn.idev.excel.annotation.*;
@ExcelIgnoreUnannotated
public class FoundationInfoRespVO {
@Schema(description = "基础id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22602")
@Schema(description = "基础id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@ExcelProperty("基础id")
private String id;
@@ -20,19 +21,22 @@ public class FoundationInfoRespVO {
@ExcelProperty("标题")
private String title;
@Schema(description = "农场名称", example = "芋艿")
@Schema(description = "农场名称")
@ExcelProperty("农场名称")
private String farmName;
@Schema(description = "农场Logo")
@Schema(description = "农场Logo(逗号分隔的字符串)")
@ExcelProperty("农场Logo")
private String image;
@Schema(description = "农场介绍", example = "你猜")
@Schema(description = "农场Logo集合")
private List<String> imageList;
@Schema(description = "农场介绍")
@ExcelProperty("农场介绍")
private String description;
@Schema(description = "企业人员总数", example = "1057")
@Schema(description = "企业人员总数")
@ExcelProperty("企业人员总数")
private Integer employeeCount;
@@ -40,23 +44,23 @@ public class FoundationInfoRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "基地id", example = "21166")
@Schema(description = "基地id")
@ExcelProperty("基地id")
private String baseId;
@Schema(description = "基地", example = "王五")
@Schema(description = "基地")
@ExcelProperty("基地")
private String baseName;
@Schema(description = "地块ID", example = "27402")
@Schema(description = "地块ID")
@ExcelProperty("地块ID")
private String plotId;
@Schema(description = "地块", example = "张三")
@Schema(description = "地块")
@ExcelProperty("地块")
private String plotName;
@Schema(description = "租户id", example = "12964")
@Schema(description = "租户id")
@ExcelProperty("租户id")
private String tenantId;

View File

@@ -3,41 +3,46 @@ package cn.iocoder.yudao.module.farm.controller.admin.foundationinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List;
@Schema(description = "管理后台 - 基础信息新增/修改 Request VO")
@Data
public class FoundationInfoSaveReqVO {
@Schema(description = "基础id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22602")
@Schema(description = "基础id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private String id;
@Schema(description = "标题")
private String title;
@Schema(description = "农场名称", example = "芋艿")
@Schema(description = "农场名称")
private String farmName;
@Schema(description = "农场Logo")
@Schema(description = "农场Logo(逗号分隔的字符串)")
private String image;
@Schema(description = "农场介绍", example = "你猜")
@Schema(description = "农场Logo集合")
private List<String> imageList;
@Schema(description = "农场介绍")
private String description;
@Schema(description = "企业人员总数", example = "1057")
@Schema(description = "企业人员总数")
private Integer employeeCount;
@Schema(description = "基地id", example = "21166")
@Schema(description = "基地id")
private String baseId;
@Schema(description = "基地", example = "王五")
@Schema(description = "基地")
private String baseName;
@Schema(description = "地块ID", example = "27402")
@Schema(description = "地块ID")
private String plotId;
@Schema(description = "地块", example = "张三")
@Schema(description = "地块")
private String plotName;
@Schema(description = "租户id", example = "12964")
@Schema(description = "租户id")
private String tenantId;
}

View File

@@ -5,6 +5,7 @@ import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import cn.idev.excel.annotation.*;
@Schema(description = "管理后台 - 人员管理 Response VO")
@@ -32,10 +33,13 @@ public class PersonnelManagementRespVO {
@ExcelProperty("角色id用,隔开")
private String role;
@Schema(description = "头像")
@Schema(description = "头像(逗号分隔的字符串)")
@ExcelProperty("头像")
private String picture;
@Schema(description = "头像集合")
private List<String> pictureList;
@Schema(description = "0=启用,1=停用", example = "2")
@ExcelProperty("0=启用,1=停用")
private Integer accountStatus;

View File

@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.farm.controller.admin.personnelmanagement.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List;
@Schema(description = "管理后台 - 人员管理新增/修改 Request VO")
@Data
public class PersonnelManagementSaveReqVO {
@@ -22,9 +24,12 @@ public class PersonnelManagementSaveReqVO {
@Schema(description = "角色id用,隔开")
private String role;
@Schema(description = "头像")
@Schema(description = "头像(逗号分隔的字符串)")
private String picture;
@Schema(description = "头像集合")
private List<String> pictureList;
@Schema(description = "0=启用,1=停用", example = "2")
private Integer accountStatus;

View File

@@ -64,10 +64,13 @@ public class TraceabilityCodeRespVO {
@ExcelProperty("商品规格")
private String packingSpec;
@Schema(description = "商品图片")
@Schema(description = "商品图片(逗号分隔的字符串)")
@ExcelProperty("商品图片")
private String productImage;
@Schema(description = "商品图片集合")
private List<String> productImageList;
@Schema(description = "商标名称", example = "芋艿")
@ExcelProperty("商标名称")
private String brandName;
@@ -116,10 +119,13 @@ public class TraceabilityCodeRespVO {
@ExcelProperty("是否显示企业地址")
private Long isShowBusinessAddress;
@Schema(description = "宣传图片")
@Schema(description = "宣传图片(逗号分隔的字符串)")
@ExcelProperty("宣传图片")
private String publicityImage;
@Schema(description = "宣传图片集合")
private List<String> publicityImageList;
@Schema(description = "是否显示宣传图片")
@ExcelProperty("是否显示宣传图片")
private Long isShowPublicityImage;
@@ -136,10 +142,13 @@ public class TraceabilityCodeRespVO {
@ExcelProperty("批次检验报告")
private String inspectionReport;
@Schema(description = "批次采收图片")
@Schema(description = "批次采收图片(逗号分隔的字符串)")
@ExcelProperty("批次采收图片")
private String collectImages;
@Schema(description = "批次采收图片集合")
private List<String> collectImagesList;
@Schema(description = "摄像头信息")
@ExcelProperty("摄像头信息")
private String cameraInformation;

View File

@@ -50,9 +50,12 @@ public class TraceabilityCodeSaveReqVO {
@Schema(description = "商品规格")
private String packingSpec;
@Schema(description = "商品图片")
@Schema(description = "商品图片(逗号分隔的字符串)")
private String productImage;
@Schema(description = "商品图片集合")
private List<String> productImageList;
@Schema(description = "商标名称", example = "芋艿")
private String brandName;
@@ -89,9 +92,12 @@ public class TraceabilityCodeSaveReqVO {
@Schema(description = "是否显示企业地址")
private Long isShowBusinessAddress;
@Schema(description = "宣传图片")
@Schema(description = "宣传图片(逗号分隔的字符串)")
private String publicityImage;
@Schema(description = "宣传图片集合")
private List<String> publicityImageList;
@Schema(description = "是否显示宣传图片")
private Long isShowPublicityImage;
@@ -104,9 +110,12 @@ public class TraceabilityCodeSaveReqVO {
@Schema(description = "批次检验报告")
private String inspectionReport;
@Schema(description = "批次采收图片")
@Schema(description = "批次采收图片(逗号分隔的字符串)")
private String collectImages;
@Schema(description = "批次采收图片集合")
private List<String> collectImagesList;
@Schema(description = "摄像头信息")
private String cameraInformation;

View File

@@ -4,8 +4,10 @@ import lombok.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
/**
* 企业信息 DO
@@ -60,13 +62,29 @@ public class CompanyInfoDO extends BaseDO {
*/
private String introduce;
/**
* 宣传图片
* 宣传图片(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "publicity_image")
private String publicityImage;
/**
* 企业logo
* 宣传图片集合(业务层使用)
*/
@TableField(exist = false)
private List<String> publicityImageList;
/**
* 企业logo(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "logo_image")
private String logoImage;
/**
* 企业logo集合(业务层使用)
*/
@TableField(exist = false)
private List<String> logoImageList;
/**
* 基地id
*/
@@ -85,4 +103,40 @@ public class CompanyInfoDO extends BaseDO {
private String plotName;
private String tenantId;
/**
* 获取宣传图片集合
*/
public List<String> getPublicityImageList() {
if (publicityImageList == null) {
publicityImageList = ImageCollectionUtil.toImageList(this.publicityImage);
}
return publicityImageList;
}
/**
* 设置宣传图片集合
*/
public void setPublicityImageList(List<String> publicityImageList) {
this.publicityImageList = publicityImageList;
this.publicityImage = ImageCollectionUtil.toDatabaseString(publicityImageList);
}
/**
* 获取企业logo集合
*/
public List<String> getLogoImageList() {
if (logoImageList == null) {
logoImageList = ImageCollectionUtil.toImageList(this.logoImage);
}
return logoImageList;
}
/**
* 设置企业logo集合
*/
public void setLogoImageList(List<String> logoImageList) {
this.logoImageList = logoImageList;
this.logoImage = ImageCollectionUtil.toDatabaseString(logoImageList);
}
}

View File

@@ -5,8 +5,10 @@ import lombok.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
/**
* 种植中心-农事基地-农事记录 DO
@@ -69,9 +71,17 @@ public class FarmingRecordDO extends BaseDO {
*/
private String feedbackNotes;
/**
* 执行反馈-图片URL
* 执行反馈-图片URL(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "feedback_image_url")
private String feedbackImageUrl;
/**
* 执行反馈-图片URL集合(业务层使用)
*/
@TableField(exist = false)
private List<String> feedbackImageUrlList;
/**
* 逻辑删除标识符
*/
@@ -90,4 +100,22 @@ public class FarmingRecordDO extends BaseDO {
private String plotName;
private String tenantId;
/**
* 获取执行反馈图片URL集合
*/
public List<String> getFeedbackImageUrlList() {
if (feedbackImageUrlList == null) {
feedbackImageUrlList = ImageCollectionUtil.toImageList(this.feedbackImageUrl);
}
return feedbackImageUrlList;
}
/**
* 设置执行反馈图片URL集合
*/
public void setFeedbackImageUrlList(List<String> feedbackImageUrlList) {
this.feedbackImageUrlList = feedbackImageUrlList;
this.feedbackImageUrl = ImageCollectionUtil.toDatabaseString(feedbackImageUrlList);
}
}

View File

@@ -4,8 +4,10 @@ import lombok.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
/**
* 基础信息 DO
@@ -36,9 +38,17 @@ public class FoundationInfoDO extends BaseDO {
*/
private String farmName;
/**
* 农场Logo
* 农场Logo(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "image")
private String image;
/**
* 农场Logo集合(业务层使用)
*/
@TableField(exist = false)
private List<String> imageList;
/**
* 农场介绍
*/
@@ -65,4 +75,22 @@ public class FoundationInfoDO extends BaseDO {
private String plotName;
private String tenantId;
/**
* 获取农场Logo集合
*/
public List<String> getImageList() {
if (imageList == null) {
imageList = ImageCollectionUtil.toImageList(this.image);
}
return imageList;
}
/**
* 设置农场Logo集合
*/
public void setImageList(List<String> imageList) {
this.imageList = imageList;
this.image = ImageCollectionUtil.toDatabaseString(imageList);
}
}

View File

@@ -4,8 +4,10 @@ import lombok.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
/**
* 人员管理 DO
@@ -44,9 +46,17 @@ public class PersonnelManagementDO extends BaseDO {
*/
private String role;
/**
* 头像
* 头像(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "picture")
private String picture;
/**
* 头像集合(业务层使用)
*/
@TableField(exist = false)
private List<String> pictureList;
/**
* 0=启用,1=停用
*/
@@ -69,4 +79,22 @@ public class PersonnelManagementDO extends BaseDO {
private String plotName;
private String tenantId;
/**
* 获取头像集合
*/
public List<String> getPictureList() {
if (pictureList == null) {
pictureList = ImageCollectionUtil.toImageList(this.picture);
}
return pictureList;
}
/**
* 设置头像集合
*/
public void setPictureList(List<String> pictureList) {
this.pictureList = pictureList;
this.picture = ImageCollectionUtil.toDatabaseString(pictureList);
}
}

View File

@@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.traceabilitycode;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
import java.util.List;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
/**
* 溯源-溯源码 DO
@@ -74,9 +77,17 @@ public class TraceabilityCodeDO extends BaseDO {
*/
private String packingSpec;
/**
* 商品图片
* 商品图片(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "product_image")
private String productImage;
/**
* 商品图片集合(业务层使用)
*/
@TableField(exist = false)
private List<String> productImageList;
/**
* 商标名称
*/
@@ -126,9 +137,17 @@ public class TraceabilityCodeDO extends BaseDO {
*/
private Long isShowBusinessAddress;
/**
* 宣传图片
* 宣传图片(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "publicity_image")
private String publicityImage;
/**
* 宣传图片集合(业务层使用)
*/
@TableField(exist = false)
private List<String> publicityImageList;
/**
* 是否显示宣传图片
*/
@@ -146,9 +165,17 @@ public class TraceabilityCodeDO extends BaseDO {
*/
private String inspectionReport;
/**
* 批次采收图片
* 批次采收图片(数据库存储为逗号分隔的字符串)
*/
@TableField(value = "collect_images")
private String collectImages;
/**
* 批次采收图片集合(业务层使用)
*/
@TableField(exist = false)
private List<String> collectImagesList;
/**
* 摄像头信息
*/
@@ -171,4 +198,58 @@ public class TraceabilityCodeDO extends BaseDO {
private String codeOutBatch;
private Long scanCodeCount;
/**
* 获取商品图片集合
*/
public List<String> getProductImageList() {
if (productImageList == null) {
productImageList = ImageCollectionUtil.toImageList(this.productImage);
}
return productImageList;
}
/**
* 设置商品图片集合
*/
public void setProductImageList(List<String> productImageList) {
this.productImageList = productImageList;
this.productImage = ImageCollectionUtil.toDatabaseString(productImageList);
}
/**
* 获取宣传图片集合
*/
public List<String> getPublicityImageList() {
if (publicityImageList == null) {
publicityImageList = ImageCollectionUtil.toImageList(this.publicityImage);
}
return publicityImageList;
}
/**
* 设置宣传图片集合
*/
public void setPublicityImageList(List<String> publicityImageList) {
this.publicityImageList = publicityImageList;
this.publicityImage = ImageCollectionUtil.toDatabaseString(publicityImageList);
}
/**
* 获取批次采收图片集合
*/
public List<String> getCollectImagesList() {
if (collectImagesList == null) {
collectImagesList = ImageCollectionUtil.toImageList(this.collectImages);
}
return collectImagesList;
}
/**
* 设置批次采收图片集合
*/
public void setCollectImagesList(List<String> collectImagesList) {
this.collectImagesList = collectImagesList;
this.collectImages = ImageCollectionUtil.toDatabaseString(collectImagesList);
}
}

View File

@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.companyinfo.vo.CompanyInfoP
import cn.iocoder.yudao.module.farm.controller.admin.companyinfo.vo.CompanyInfoSaveReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.companyinfo.CompanyInfoDO;
import cn.iocoder.yudao.module.farm.dal.mysql.companyinfo.CompanyInfoMapper;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -37,6 +38,10 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
CompanyInfoDO companyInfo = BeanUtils.toBean(createReqVO, CompanyInfoDO.class);
companyInfo.setId(IdUtil.fastUUID());
companyInfo.setTenantId(String.valueOf(user.getTenantId()));
// 处理图片集合转换
handleImageConversion(companyInfo, createReqVO);
companyInfoMapper.insert(companyInfo);
// 返回
@@ -49,6 +54,10 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
validateCompanyInfoExists(updateReqVO.getId());
// 更新
CompanyInfoDO updateObj = BeanUtils.toBean(updateReqVO, CompanyInfoDO.class);
// 处理图片集合转换
handleImageConversion(updateObj, updateReqVO);
companyInfoMapper.updateById(updateObj);
}
@@ -74,12 +83,47 @@ private void validateCompanyInfoExists(String id) {
@Override
public CompanyInfoDO getCompanyInfo(String id) {
return companyInfoMapper.selectById(id);
CompanyInfoDO companyInfo = companyInfoMapper.selectById(id);
if (companyInfo != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
companyInfo.getPublicityImageList();
companyInfo.getLogoImageList();
}
return companyInfo;
}
@Override
public PageResult<CompanyInfoDO> getCompanyInfoPage(CompanyInfoPageReqVO pageReqVO) {
return companyInfoMapper.selectPage(pageReqVO);
PageResult<CompanyInfoDO> pageResult = companyInfoMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(companyInfo -> {
if (companyInfo != null) {
companyInfo.getPublicityImageList();
companyInfo.getLogoImageList();
}
});
}
return pageResult;
}
/**
* 处理图片集合转换
* 优先使用图片集合,如果图片集合为空则使用字符串
*/
private void handleImageConversion(CompanyInfoDO companyInfo, CompanyInfoSaveReqVO reqVO) {
// 处理宣传图片
if (reqVO.getPublicityImageList() != null && !reqVO.getPublicityImageList().isEmpty()) {
companyInfo.setPublicityImageList(reqVO.getPublicityImageList());
} else if (reqVO.getPublicityImage() != null) {
companyInfo.setPublicityImage(reqVO.getPublicityImage());
}
// 处理企业logo
if (reqVO.getLogoImageList() != null && !reqVO.getLogoImageList().isEmpty()) {
companyInfo.setLogoImageList(reqVO.getLogoImageList());
} else if (reqVO.getLogoImage() != null) {
companyInfo.setLogoImage(reqVO.getLogoImage());
}
}
}

View File

@@ -81,12 +81,30 @@ private void validateDeviceInfoExists(String id) {
@Override
public DeviceInfoDO getDeviceInfo(String id) {
return deviceInfoMapper.selectById(id);
DeviceInfoDO deviceInfo = deviceInfoMapper.selectById(id);
if (deviceInfo != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
deviceInfo.getImageList();
deviceInfo.getAlarmImageList();
deviceInfo.getOfflineImageList();
}
return deviceInfo;
}
@Override
public PageResult<DeviceInfoDO> getDeviceInfoPage(DeviceInfoPageReqVO pageReqVO) {
return deviceInfoMapper.selectPage(pageReqVO);
PageResult<DeviceInfoDO> pageResult = deviceInfoMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(deviceInfo -> {
if (deviceInfo != null) {
deviceInfo.getImageList();
deviceInfo.getAlarmImageList();
deviceInfo.getOfflineImageList();
}
});
}
return pageResult;
}
}

View File

@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRec
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecord.FarmingRecordMapper;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -37,6 +38,10 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
FarmingRecordDO farmingRecord = BeanUtils.toBean(createReqVO, FarmingRecordDO.class);
farmingRecord.setId(IdUtil.fastUUID());
farmingRecord.setTenantId(String.valueOf(user.getTenantId()));
// 处理图片集合转换
handleImageConversion(farmingRecord, createReqVO);
farmingRecordMapper.insert(farmingRecord);
// 返回
@@ -49,6 +54,10 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
validateFarmingRecordExists(updateReqVO.getId());
// 更新
FarmingRecordDO updateObj = BeanUtils.toBean(updateReqVO, FarmingRecordDO.class);
// 处理图片集合转换
handleImageConversion(updateObj, updateReqVO);
farmingRecordMapper.updateById(updateObj);
}
@@ -74,12 +83,38 @@ private void validateFarmingRecordExists(String id) {
@Override
public FarmingRecordDO getFarmingRecord(String id) {
return farmingRecordMapper.selectById(id);
FarmingRecordDO farmingRecord = farmingRecordMapper.selectById(id);
if (farmingRecord != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
farmingRecord.getFeedbackImageUrlList();
}
return farmingRecord;
}
@Override
public PageResult<FarmingRecordDO> getFarmingRecordPage(FarmingRecordPageReqVO pageReqVO) {
return farmingRecordMapper.selectPage(pageReqVO);
PageResult<FarmingRecordDO> pageResult = farmingRecordMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(farmingRecord -> {
if (farmingRecord != null) {
farmingRecord.getFeedbackImageUrlList();
}
});
}
return pageResult;
}
/**
* 处理图片集合转换
* 优先使用图片集合,如果图片集合为空则使用字符串
*/
private void handleImageConversion(FarmingRecordDO farmingRecord, FarmingRecordSaveReqVO reqVO) {
// 处理执行反馈图片URL
if (reqVO.getFeedbackImageUrlList() != null && !reqVO.getFeedbackImageUrlList().isEmpty()) {
farmingRecord.setFeedbackImageUrlList(reqVO.getFeedbackImageUrlList());
} else if (reqVO.getFeedbackImageUrl() != null) {
farmingRecord.setFeedbackImageUrl(reqVO.getFeedbackImageUrl());
}
}
}

View File

@@ -16,6 +16,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.farm.dal.mysql.foundationinfo.FoundationInfoMapper;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
import java.util.List;
@@ -44,6 +45,10 @@ public class FoundationInfoServiceImpl implements FoundationInfoService {
FoundationInfoDO foundationInfo = BeanUtils.toBean(createReqVO, FoundationInfoDO.class);
foundationInfo.setId(IdUtil.fastUUID());
foundationInfo.setTenantId(String.valueOf(user.getTenantId()));
// 处理图片集合转换
handleImageConversion(foundationInfo, createReqVO);
foundationInfoMapper.insert(foundationInfo);
// 返回
@@ -56,6 +61,10 @@ public class FoundationInfoServiceImpl implements FoundationInfoService {
validateFoundationInfoExists(updateReqVO.getId());
// 更新
FoundationInfoDO updateObj = BeanUtils.toBean(updateReqVO, FoundationInfoDO.class);
// 处理图片集合转换
handleImageConversion(updateObj, updateReqVO);
foundationInfoMapper.updateById(updateObj);
}
@@ -81,12 +90,38 @@ private void validateFoundationInfoExists(String id) {
@Override
public FoundationInfoDO getFoundationInfo(String id) {
return foundationInfoMapper.selectById(id);
FoundationInfoDO foundationInfo = foundationInfoMapper.selectById(id);
if (foundationInfo != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
foundationInfo.getImageList();
}
return foundationInfo;
}
@Override
public PageResult<FoundationInfoDO> getFoundationInfoPage(FoundationInfoPageReqVO pageReqVO) {
return foundationInfoMapper.selectPage(pageReqVO);
PageResult<FoundationInfoDO> pageResult = foundationInfoMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(foundationInfo -> {
if (foundationInfo != null) {
foundationInfo.getImageList();
}
});
}
return pageResult;
}
/**
* 处理图片集合转换
* 优先使用图片集合,如果图片集合为空则使用字符串
*/
private void handleImageConversion(FoundationInfoDO foundationInfo, FoundationInfoSaveReqVO reqVO) {
// 处理农场Logo
if (reqVO.getImageList() != null && !reqVO.getImageList().isEmpty()) {
foundationInfo.setImageList(reqVO.getImageList());
} else if (reqVO.getImage() != null) {
foundationInfo.setImage(reqVO.getImage());
}
}
}

View File

@@ -18,6 +18,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.farm.dal.mysql.personnelmanagement.PersonnelManagementMapper;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
import java.util.List;
@@ -45,6 +46,10 @@ public class PersonnelManagementServiceImpl implements PersonnelManagementServic
PersonnelManagementDO personnelManagement = BeanUtils.toBean(createReqVO, PersonnelManagementDO.class);
personnelManagement.setId(IdUtil.fastUUID());
personnelManagement.setTenantId(String.valueOf(user.getTenantId()));
// 处理图片集合转换
handleImageConversion(personnelManagement, createReqVO);
personnelManagementMapper.insert(personnelManagement);
// 返回
@@ -57,6 +62,10 @@ public class PersonnelManagementServiceImpl implements PersonnelManagementServic
validatePersonnelManagementExists(updateReqVO.getId());
// 更新
PersonnelManagementDO updateObj = BeanUtils.toBean(updateReqVO, PersonnelManagementDO.class);
// 处理图片集合转换
handleImageConversion(updateObj, updateReqVO);
personnelManagementMapper.updateById(updateObj);
}
@@ -82,12 +91,38 @@ private void validatePersonnelManagementExists(String id) {
@Override
public PersonnelManagementDO getPersonnelManagement(String id) {
return personnelManagementMapper.selectById(id);
PersonnelManagementDO personnelManagement = personnelManagementMapper.selectById(id);
if (personnelManagement != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
personnelManagement.getPictureList();
}
return personnelManagement;
}
@Override
public PageResult<PersonnelManagementDO> getPersonnelManagementPage(PersonnelManagementPageReqVO pageReqVO) {
return personnelManagementMapper.selectPage(pageReqVO);
PageResult<PersonnelManagementDO> pageResult = personnelManagementMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(personnelManagement -> {
if (personnelManagement != null) {
personnelManagement.getPictureList();
}
});
}
return pageResult;
}
/**
* 处理图片集合转换
* 优先使用图片集合,如果图片集合为空则使用字符串
*/
private void handleImageConversion(PersonnelManagementDO personnelManagement, PersonnelManagementSaveReqVO reqVO) {
// 处理头像
if (reqVO.getPictureList() != null && !reqVO.getPictureList().isEmpty()) {
personnelManagement.setPictureList(reqVO.getPictureList());
} else if (reqVO.getPicture() != null) {
personnelManagement.setPicture(reqVO.getPicture());
}
}
}

View File

@@ -81,12 +81,26 @@ private void validatePestDiseaseWeedLibraryExists(String id) {
@Override
public PestDiseaseWeedLibraryDO getPestDiseaseWeedLibrary(String id) {
return pestDiseaseWeedLibraryMapper.selectById(id);
PestDiseaseWeedLibraryDO pestDiseaseWeedLibrary = pestDiseaseWeedLibraryMapper.selectById(id);
if (pestDiseaseWeedLibrary != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
pestDiseaseWeedLibrary.getImageList();
}
return pestDiseaseWeedLibrary;
}
@Override
public PageResult<PestDiseaseWeedLibraryDO> getPestDiseaseWeedLibraryPage(PestDiseaseWeedLibraryPageReqVO pageReqVO) {
return pestDiseaseWeedLibraryMapper.selectPage(pageReqVO);
PageResult<PestDiseaseWeedLibraryDO> pageResult = pestDiseaseWeedLibraryMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(pestDiseaseWeedLibrary -> {
if (pestDiseaseWeedLibrary != null) {
pestDiseaseWeedLibrary.getImageList();
}
});
}
return pageResult;
}
}

View File

@@ -79,12 +79,28 @@ private void validateProductManagementExists(String id) {
@Override
public ProductManagementDO getProductManagement(String id) {
return productManagementMapper.selectById(id);
ProductManagementDO productManagement = productManagementMapper.selectById(id);
if (productManagement != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
productManagement.getImageList();
productManagement.getBrandImageList();
}
return productManagement;
}
@Override
public PageResult<ProductManagementDO> getProductManagementPage(ProductManagementPageReqVO pageReqVO) {
return productManagementMapper.selectPage(pageReqVO);
PageResult<ProductManagementDO> pageResult = productManagementMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(productManagement -> {
if (productManagement != null) {
productManagement.getImageList();
productManagement.getBrandImageList();
}
});
}
return pageResult;
}
}

View File

@@ -74,12 +74,26 @@ private void validateSpeciesLibraryExists(String id) {
@Override
public SpeciesLibraryDO getSpeciesLibrary(String id) {
return speciesLibraryMapper.selectById(id);
SpeciesLibraryDO speciesLibrary = speciesLibraryMapper.selectById(id);
if (speciesLibrary != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
speciesLibrary.getImageList();
}
return speciesLibrary;
}
@Override
public PageResult<SpeciesLibraryDO> getSpeciesLibraryPage(SpeciesLibraryPageReqVO pageReqVO) {
return speciesLibraryMapper.selectPage(pageReqVO);
PageResult<SpeciesLibraryDO> pageResult = speciesLibraryMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(speciesLibrary -> {
if (speciesLibrary != null) {
speciesLibrary.getImageList();
}
});
}
return pageResult;
}
}

View File

@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.traceabilitycode.vo.Traceab
import cn.iocoder.yudao.module.farm.controller.admin.traceabilitycode.vo.TraceabilityCodeSaveReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.traceabilitycode.TraceabilityCodeDO;
import cn.iocoder.yudao.module.farm.dal.mysql.traceabilitycode.TraceabilityCodeMapper;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -44,6 +45,10 @@ public class TraceabilityCodeServiceImpl implements TraceabilityCodeService {
traceabilityCode.setId(IdUtil.fastUUID());
traceabilityCode.setTenantId(String.valueOf(user.getTenantId()));
traceabilityCode.setCodeOutBatch(dateStr);
// 处理图片集合转换
handleImageConversion(traceabilityCode, createReqVO);
traceabilityCodeMapper.insert(traceabilityCode);
}
// 返回
@@ -56,6 +61,10 @@ public class TraceabilityCodeServiceImpl implements TraceabilityCodeService {
validateTraceabilityCodeExists(updateReqVO.getId());
// 更新
TraceabilityCodeDO updateObj = BeanUtils.toBean(updateReqVO, TraceabilityCodeDO.class);
// 处理图片集合转换
handleImageConversion(updateObj, updateReqVO);
traceabilityCodeMapper.updateById(updateObj);
}
@@ -82,12 +91,30 @@ public class TraceabilityCodeServiceImpl implements TraceabilityCodeService {
@Override
public TraceabilityCodeDO getTraceabilityCode(String id) {
return traceabilityCodeMapper.selectById(id);
TraceabilityCodeDO traceabilityCode = traceabilityCodeMapper.selectById(id);
if (traceabilityCode != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
traceabilityCode.getProductImageList();
traceabilityCode.getPublicityImageList();
traceabilityCode.getCollectImagesList();
}
return traceabilityCode;
}
@Override
public PageResult<TraceabilityCodeDO> getTraceabilityCodePage(TraceabilityCodePageReqVO pageReqVO) {
return traceabilityCodeMapper.selectPage(pageReqVO);
PageResult<TraceabilityCodeDO> pageResult = traceabilityCodeMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(traceabilityCode -> {
if (traceabilityCode != null) {
traceabilityCode.getProductImageList();
traceabilityCode.getPublicityImageList();
traceabilityCode.getCollectImagesList();
}
});
}
return pageResult;
}
@Override
@@ -98,4 +125,30 @@ public class TraceabilityCodeServiceImpl implements TraceabilityCodeService {
return traceabilityCodeDO;
}
/**
* 处理图片集合转换
* 优先使用图片集合,如果图片集合为空则使用字符串
*/
private void handleImageConversion(TraceabilityCodeDO traceabilityCode, TraceabilityCodeSaveReqVO reqVO) {
// 处理商品图片
if (reqVO.getProductImageList() != null && !reqVO.getProductImageList().isEmpty()) {
traceabilityCode.setProductImageList(reqVO.getProductImageList());
} else if (reqVO.getProductImage() != null) {
traceabilityCode.setProductImage(reqVO.getProductImage());
}
// 处理宣传图片
if (reqVO.getPublicityImageList() != null && !reqVO.getPublicityImageList().isEmpty()) {
traceabilityCode.setPublicityImageList(reqVO.getPublicityImageList());
} else if (reqVO.getPublicityImage() != null) {
traceabilityCode.setPublicityImage(reqVO.getPublicityImage());
}
// 处理批次采收图片
if (reqVO.getCollectImagesList() != null && !reqVO.getCollectImagesList().isEmpty()) {
traceabilityCode.setCollectImagesList(reqVO.getCollectImagesList());
} else if (reqVO.getCollectImages() != null) {
traceabilityCode.setCollectImages(reqVO.getCollectImages());
}
}
}

View File

@@ -74,12 +74,26 @@ private void validateWeatherDisasterLibraryExists(String id) {
@Override
public WeatherDisasterLibraryDO getWeatherDisasterLibrary(String id) {
return weatherDisasterLibraryMapper.selectById(id);
WeatherDisasterLibraryDO weatherDisasterLibrary = weatherDisasterLibraryMapper.selectById(id);
if (weatherDisasterLibrary != null) {
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
weatherDisasterLibrary.getImageList();
}
return weatherDisasterLibrary;
}
@Override
public PageResult<WeatherDisasterLibraryDO> getWeatherDisasterLibraryPage(WeatherDisasterLibraryPageReqVO pageReqVO) {
return weatherDisasterLibraryMapper.selectPage(pageReqVO);
PageResult<WeatherDisasterLibraryDO> pageResult = weatherDisasterLibraryMapper.selectPage(pageReqVO);
if (pageResult.getList() != null) {
// 触发图片集合转换,确保分页结果中的每个DO对象都包含转换后的图片集合
pageResult.getList().forEach(weatherDisasterLibrary -> {
if (weatherDisasterLibrary != null) {
weatherDisasterLibrary.getImageList();
}
});
}
return pageResult;
}
}