Commit 40a23af7 authored by wdy's avatar wdy

车企文件添加

parent c2ae76e3
......@@ -9,6 +9,7 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.domain.vo.AttachmentsVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -69,11 +70,17 @@ public class ReviewEnterpriseArchive implements Serializable {
private String storage;
/**
* 图片地址
* 附件地址
*/
@ApiModelProperty("图片地址")
@ApiModelProperty("附件地址")
private String photo;
/**
* 附件名称
*/
@ApiModelProperty("附件名称")
private String photoName;
/**
* 关联到任务id
*/
......@@ -90,6 +97,6 @@ public class ReviewEnterpriseArchive implements Serializable {
@ApiModelProperty("附件")
@TableField(exist = false)
private String[] url;
List<AttachmentsVO> url;
}
\ No newline at end of file
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class AttachmentsVO {
// 附件路径
@ApiModelProperty("附件路径")
String url;
// 附件名称
@ApiModelProperty("附件名称")
String name;
// 构造函数
public AttachmentsVO(String url, String name) {
this.url = url;
this.name = name;
}
// 默认构造函数
public AttachmentsVO() {
// 可以为空,或者初始化一些默认值
}
}
......@@ -11,9 +11,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ReviewEnterpriseArchive;
import com.ruoyi.domain.Task;
import com.ruoyi.domain.vo.EnterpriseImportFileVO;
import com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewItemVO;
import com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewVO;
import com.ruoyi.domain.vo.*;
import com.ruoyi.mapper.TaskMapper;
import com.ruoyi.service.ReviewEnterpriseArchiveService;
import com.ruoyi.mapper.ReviewEnterpriseArchiveMapper;
......@@ -34,6 +32,7 @@ import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.common.utils.DateUtils.getNowDate;
......@@ -151,9 +150,18 @@ public class ReviewEnterpriseArchiveServiceImpl extends ServiceImpl<ReviewEnterp
throw new ServiceException("新增文件名称重复,请检查", HttpStatus.ERROR);
} else {
// 将附件地址存入photo字段中
if (reviewEnterpriseArchive.getUrl() != null && reviewEnterpriseArchive.getUrl().length != 0) {
String joinUrl = StringUtils.join(reviewEnterpriseArchive.getUrl(),",");
reviewEnterpriseArchive.setPhoto(joinUrl);
if (reviewEnterpriseArchive.getUrl() != null && reviewEnterpriseArchive.getUrl().size() != 0) {
String photo = reviewEnterpriseArchive.getUrl().stream()
.map(AttachmentsVO::getUrl)
.collect(Collectors.joining(","));
String photoName = reviewEnterpriseArchive.getUrl().stream()
.map(AttachmentsVO::getName)
.collect(Collectors.joining(","));
reviewEnterpriseArchive.setPhoto(photo);
reviewEnterpriseArchive.setPhotoName(photoName);
}
reviewEnterpriseArchiveService.save(reviewEnterpriseArchive);
......@@ -185,7 +193,18 @@ public class ReviewEnterpriseArchiveServiceImpl extends ServiceImpl<ReviewEnterp
@Override
public ReviewEnterpriseArchive getInfo(ReviewEnterpriseArchiveGetInfoRequest request) {
ReviewEnterpriseArchive reviewEnterpriseArchive = reviewEnterpriseArchiveMapper.selectById(request.getId());
reviewEnterpriseArchive.setUrl(reviewEnterpriseArchive.getPhoto().split(","));
// 按逗号拆分字符串
String[] photoUrls = reviewEnterpriseArchive.getPhoto().split(",");
String[] photoNames = reviewEnterpriseArchive.getPhotoName().split(",");
// 将拆分后的字符串配对创建AttachmentsVO对象,并加入到List中
List<AttachmentsVO> attachmentsVOList = new ArrayList<>();
for (int i = 0; i < photoUrls.length; i++) {
AttachmentsVO vo = new AttachmentsVO(photoUrls[i], photoNames[i]);
attachmentsVOList.add(vo);
}
reviewEnterpriseArchive.setUrl(attachmentsVOList);
return reviewEnterpriseArchive;
}
......@@ -251,9 +270,18 @@ public class ReviewEnterpriseArchiveServiceImpl extends ServiceImpl<ReviewEnterp
@Override
public void editEnterpriseArchive(ReviewEnterpriseArchive reviewEnterpriseArchive) {
// 将附件地址存入photo字段中
if (reviewEnterpriseArchive.getUrl() != null && reviewEnterpriseArchive.getUrl().length != 0) {
String joinUrl = StringUtils.join(reviewEnterpriseArchive.getUrl(),",");
reviewEnterpriseArchive.setPhoto(joinUrl);
if (reviewEnterpriseArchive.getUrl() != null && reviewEnterpriseArchive.getUrl().size() != 0) {
String photo = reviewEnterpriseArchive.getUrl().stream()
.map(AttachmentsVO::getUrl)
.collect(Collectors.joining(","));
String photoName = reviewEnterpriseArchive.getUrl().stream()
.map(AttachmentsVO::getName)
.collect(Collectors.joining(","));
reviewEnterpriseArchive.setPhoto(photo);
reviewEnterpriseArchive.setPhotoName(photoName);
}
reviewEnterpriseArchiveService.updateById(reviewEnterpriseArchive);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment