Browse Source

1.0.0 修改文件保存接口为批量保存

release/v1.0.0
peihao 4 years ago
parent
commit
fa59a52684
  1. 11
      air/src/main/java/com/air/land/controller/LandAttachmentController.java
  2. 11
      air/src/main/java/com/air/land/controller/LandToListAttachmentController.java
  3. 2
      air/src/main/java/com/air/land/entity/LandAttachment.java
  4. 2
      air/src/main/java/com/air/land/entity/LandToListAttachment.java
  5. 139
      air/src/main/java/com/air/utils/ValidList.java

11
air/src/main/java/com/air/land/controller/LandAttachmentController.java

@ -3,6 +3,7 @@ package com.air.land.controller;
import com.air.land.entity.LandAttachment;
import com.air.land.service.LandAttachmentService;
import com.air.utils.FileUtil;
import com.air.utils.ValidList;
import com.cinderella.framework.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -45,14 +46,16 @@ public class LandAttachmentController {
/**
* 保存已挂牌地块文件
*
* @param landAttachment 文件参数
* @param attachments 文件参数
* @return R
*/
@ApiOperation(value = "保存已挂牌地块文件", notes = "保存已挂牌地块文件")
@PostMapping
public R<Boolean> saveAttachment(@RequestBody @Validated LandAttachment landAttachment) {
landAttachment.setFilePath(fileUtil.getInnerPath(landAttachment.getFilePath()));
return R.ok(attachmentService.saveOrUpdate(landAttachment));
public R<Boolean> saveAttachment(@RequestBody @Validated ValidList<LandAttachment> attachments) {
attachments.forEach(attachment ->{
attachment.setFilePath(fileUtil.getInnerPath(attachment.getFilePath()));
});
return R.ok(attachmentService.saveOrUpdateBatch(attachments));
}
/**

11
air/src/main/java/com/air/land/controller/LandToListAttachmentController.java

@ -3,6 +3,7 @@ package com.air.land.controller;
import com.air.land.entity.LandToListAttachment;
import com.air.land.service.LandToListAttachmentService;
import com.air.utils.FileUtil;
import com.air.utils.ValidList;
import com.cinderella.framework.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -45,14 +46,16 @@ public class LandToListAttachmentController {
/**
* 保存地块文件
*
* @param landToListAttachment 文件参数
* @param attachments 文件参数
* @return R
*/
@ApiOperation(value = "保存地块文件", notes = "保存地块文件")
@PostMapping
public R<Boolean> saveAttachment(@RequestBody @Validated LandToListAttachment landToListAttachment) {
landToListAttachment.setFilePath(fileUtil.getInnerPath(landToListAttachment.getFilePath()));
return R.ok(attachmentService.saveOrUpdate(landToListAttachment));
public R<Boolean> saveAttachment(@RequestBody @Validated ValidList<LandToListAttachment> attachments) {
attachments.forEach(attachment ->{
attachment.setFilePath(fileUtil.getInnerPath(attachment.getFilePath()));
});
return R.ok(attachmentService.saveOrUpdateBatch(attachments));
}
/**

2
air/src/main/java/com/air/land/entity/LandAttachment.java

@ -34,7 +34,7 @@ public class LandAttachment extends Model<LandAttachment> {
@ApiModelProperty(value = "已挂牌地块标识", required = true)
private Long landListedId;
@NotBlank(message = "不能为空")
@NotBlank(message = "文件类型不能为空")
@ApiModelProperty(value = "文件类型", required = true)
private String fileType;

2
air/src/main/java/com/air/land/entity/LandToListAttachment.java

@ -33,7 +33,7 @@ public class LandToListAttachment extends Model<LandToListAttachment> {
@ApiModelProperty(value = "拟出让序号", required = true)
private String proposedseriaId;
@NotBlank(message = "不能为空")
@NotBlank(message = "文件类型不能为空")
@ApiModelProperty(value = "文件类型", required = true)
private String fileType;

139
air/src/main/java/com/air/utils/ValidList.java

@ -0,0 +1,139 @@
package com.air.utils;
import javax.validation.Valid;
import java.util.*;
/**
* 验证list
*
* @author peihao
* @date 2021-06-04
**/
public class ValidList<E> implements List<E> {
@Valid
private List<E> list = new LinkedList<>();
@Override
public int size() {
return list.size();
}
@Override
public boolean isEmpty() {
return list.isEmpty();
}
@Override
public boolean contains(Object o) {
return list.contains(o);
}
@Override
public Iterator<E> iterator() {
return list.iterator();
}
@Override
public Object[] toArray() {
return list.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return list.toArray(a);
}
@Override
public boolean add(E e) {
return list.add(e);
}
@Override
public boolean remove(Object o) {
return list.remove(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return list.containsAll(c);
}
@Override
public boolean addAll(Collection<? extends E> c) {
return list.addAll(c);
}
@Override
public boolean addAll(int index, Collection<? extends E> c) {
return list.addAll(index, c);
}
@Override
public boolean removeAll(Collection<?> c) {
return list.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return list.retainAll(c);
}
@Override
public void clear() {
list.clear();
}
@Override
public E get(int index) {
return list.get(index);
}
@Override
public E set(int index, E element) {
return list.set(index, element);
}
@Override
public void add(int index, E element) {
list.add(index, element);
}
@Override
public E remove(int index) {
return list.remove(index);
}
@Override
public int indexOf(Object o) {
return list.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return list.lastIndexOf(o);
}
@Override
public ListIterator<E> listIterator() {
return list.listIterator();
}
@Override
public ListIterator<E> listIterator(int index) {
return list.listIterator(index);
}
@Override
public List<E> subList(int fromIndex, int toIndex) {
return list.subList(fromIndex, toIndex);
}
public List<E> getList() {
return list;
}
public void setList(List<E> list) {
this.list = list;
}
}
Loading…
Cancel
Save