From fa59a5268423cada28a5d6edc3df6180c7c37b61 Mon Sep 17 00:00:00 2001 From: peihao <1280253838@qq.com> Date: Fri, 4 Jun 2021 09:58:39 +0800 Subject: [PATCH] =?UTF-8?q?1.0.0=20=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8E=A5=E5=8F=A3=E4=B8=BA=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LandAttachmentController.java | 11 +- .../LandToListAttachmentController.java | 11 +- .../com/air/land/entity/LandAttachment.java | 2 +- .../air/land/entity/LandToListAttachment.java | 2 +- .../main/java/com/air/utils/ValidList.java | 139 ++++++++++++++++++ 5 files changed, 155 insertions(+), 10 deletions(-) create mode 100644 air/src/main/java/com/air/utils/ValidList.java diff --git a/air/src/main/java/com/air/land/controller/LandAttachmentController.java b/air/src/main/java/com/air/land/controller/LandAttachmentController.java index d02c308..d93e4c9 100644 --- a/air/src/main/java/com/air/land/controller/LandAttachmentController.java +++ b/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 saveAttachment(@RequestBody @Validated LandAttachment landAttachment) { - landAttachment.setFilePath(fileUtil.getInnerPath(landAttachment.getFilePath())); - return R.ok(attachmentService.saveOrUpdate(landAttachment)); + public R saveAttachment(@RequestBody @Validated ValidList attachments) { + attachments.forEach(attachment ->{ + attachment.setFilePath(fileUtil.getInnerPath(attachment.getFilePath())); + }); + return R.ok(attachmentService.saveOrUpdateBatch(attachments)); } /** diff --git a/air/src/main/java/com/air/land/controller/LandToListAttachmentController.java b/air/src/main/java/com/air/land/controller/LandToListAttachmentController.java index 9499aa9..595d096 100644 --- a/air/src/main/java/com/air/land/controller/LandToListAttachmentController.java +++ b/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 saveAttachment(@RequestBody @Validated LandToListAttachment landToListAttachment) { - landToListAttachment.setFilePath(fileUtil.getInnerPath(landToListAttachment.getFilePath())); - return R.ok(attachmentService.saveOrUpdate(landToListAttachment)); + public R saveAttachment(@RequestBody @Validated ValidList attachments) { + attachments.forEach(attachment ->{ + attachment.setFilePath(fileUtil.getInnerPath(attachment.getFilePath())); + }); + return R.ok(attachmentService.saveOrUpdateBatch(attachments)); } /** diff --git a/air/src/main/java/com/air/land/entity/LandAttachment.java b/air/src/main/java/com/air/land/entity/LandAttachment.java index 6b87001..da980fc 100644 --- a/air/src/main/java/com/air/land/entity/LandAttachment.java +++ b/air/src/main/java/com/air/land/entity/LandAttachment.java @@ -34,7 +34,7 @@ public class LandAttachment extends Model { @ApiModelProperty(value = "已挂牌地块标识", required = true) private Long landListedId; - @NotBlank(message = "不能为空") + @NotBlank(message = "文件类型不能为空") @ApiModelProperty(value = "文件类型", required = true) private String fileType; diff --git a/air/src/main/java/com/air/land/entity/LandToListAttachment.java b/air/src/main/java/com/air/land/entity/LandToListAttachment.java index 658d1dd..b0fbd2f 100644 --- a/air/src/main/java/com/air/land/entity/LandToListAttachment.java +++ b/air/src/main/java/com/air/land/entity/LandToListAttachment.java @@ -33,7 +33,7 @@ public class LandToListAttachment extends Model { @ApiModelProperty(value = "拟出让序号", required = true) private String proposedseriaId; - @NotBlank(message = "不能为空") + @NotBlank(message = "文件类型不能为空") @ApiModelProperty(value = "文件类型", required = true) private String fileType; diff --git a/air/src/main/java/com/air/utils/ValidList.java b/air/src/main/java/com/air/utils/ValidList.java new file mode 100644 index 0000000..1802fdd --- /dev/null +++ b/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 implements List { + + @Valid + private List 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 iterator() { + return list.iterator(); + } + + @Override + public Object[] toArray() { + return list.toArray(); + } + + @Override + public 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 c) { + return list.addAll(c); + } + + @Override + public boolean addAll(int index, Collection 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 listIterator() { + return list.listIterator(); + } + + @Override + public ListIterator listIterator(int index) { + return list.listIterator(index); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return list.subList(fromIndex, toIndex); + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } +}