Commit 5daae7e8 authored by 李灿灿's avatar 李灿灿

订单添加回复记录支持多文件上传

parent 56e2dc2d
...@@ -114,7 +114,7 @@ public class OrderController { ...@@ -114,7 +114,7 @@ public class OrderController {
*/ */
@Schema(description = "添加回复") @Schema(description = "添加回复")
@PostMapping(value = "/uploadReplyEnclosure") @PostMapping(value = "/uploadReplyEnclosure")
public R uploadReplyEnclosure(@RequestBody MultipartFile file, String filePath, String replyContent,String orderNo) throws IOException { public R uploadReplyEnclosure(@RequestBody MultipartFile[] file, String filePath, String replyContent,String orderNo) throws IOException {
return tOrderService.uploadReplyEnclosure(file, filePath,replyContent,orderNo); return tOrderService.uploadReplyEnclosure(file, filePath,replyContent,orderNo);
} }
......
...@@ -80,7 +80,7 @@ public interface TOrderService extends IService<TOrder> { ...@@ -80,7 +80,7 @@ public interface TOrderService extends IService<TOrder> {
* @return {@link R} * @return {@link R}
* @throws IOException * @throws IOException
*/ */
R uploadReplyEnclosure(MultipartFile file, String filePath, String replyContent, String orderNo) throws IOException; R uploadReplyEnclosure(MultipartFile[] file, String filePath, String replyContent, String orderNo) throws IOException;
/** /**
* 订单回复列表分页查询 * 订单回复列表分页查询
......
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -183,12 +184,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -183,12 +184,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public R uploadReplyEnclosure(MultipartFile file, String filePath, String replyContent, String orderNo) throws IOException { public R uploadReplyEnclosure(MultipartFile[] file, String filePath, String replyContent, String orderNo) throws IOException {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(orderNo)){ if (Common.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY); return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
} }
if (Common.isEmpty(replyContent) && Common.isEmpty(file)){ if (Common.isEmpty(replyContent) && ArrayUtils.isEmpty(file)){
return R.failed(OrderConstants.REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY); return R.failed(OrderConstants.REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY);
} }
// 校验回复内容200字以内 // 校验回复内容200字以内
...@@ -196,16 +197,21 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -196,16 +197,21 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
return R.failed(OrderConstants.REPLY_CONTENT_MORE_THAN_200); return R.failed(OrderConstants.REPLY_CONTENT_MORE_THAN_200);
} }
if (!Common.isEmpty(file)){ if (ArrayUtils.isNotEmpty(file)){
if(!Common.checkInsuranceFile(file.getOriginalFilename())){ if (file.length > CommonConstants.TWENTY_INT){
return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR);
}
for (MultipartFile multipartFile : file) {
if(!Common.checkInsuranceFile(multipartFile.getOriginalFilename())){
return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR); return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR);
} }
if (multipartFile.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){
if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){
return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR); return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR);
} }
} }
}
TOrderReply reply = new TOrderReply(); TOrderReply reply = new TOrderReply();
reply.setOrderNo(orderNo); reply.setOrderNo(orderNo);
reply.setReplyContent(Common.isEmpty(replyContent)?null:replyContent); reply.setReplyContent(Common.isEmpty(replyContent)?null:replyContent);
...@@ -214,8 +220,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -214,8 +220,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
reply.setDeleteFlag(CommonConstants.ZERO_INT); reply.setDeleteFlag(CommonConstants.ZERO_INT);
boolean save = tOrderReplyService.save(reply); boolean save = tOrderReplyService.save(reply);
//todo 同步推送ekp //todo 同步推送ekp
if (save && !Common.isEmpty(file)){ if (save && ArrayUtils.isNotEmpty(file)){
String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename(); for (MultipartFile multipartFile : file) {
String fileName = System.currentTimeMillis() + "_" + multipartFile.getOriginalFilename();
//filePath不传默认存储空间的根目录 //filePath不传默认存储空间的根目录
//支持的附件格式 //支持的附件格式
String key = ""; String key = "";
...@@ -224,12 +231,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -224,12 +231,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
} else { } else {
key = filePath + "/" + fileName; key = filePath + "/" + fileName;
} }
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null); boolean flag = ossUtil.uploadFileByStream(multipartFile.getInputStream(), key, null);
if (flag) { if (flag) {
log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!"); log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!");
TOrderEnclosure orderEnclosure = new TOrderEnclosure(); TOrderEnclosure orderEnclosure = new TOrderEnclosure();
orderEnclosure.setOrderNo(reply.getId()); orderEnclosure.setOrderNo(reply.getId());
orderEnclosure.setEnclosureName(file.getOriginalFilename()); orderEnclosure.setEnclosureName(multipartFile.getOriginalFilename());
orderEnclosure.setEnclosureFlag(CommonConstants.ONE_INT); orderEnclosure.setEnclosureFlag(CommonConstants.ONE_INT);
orderEnclosure.setEnclosureAddress(key); orderEnclosure.setEnclosureAddress(key);
orderEnclosure.setDeleteFlag(CommonConstants.ZERO_INT); orderEnclosure.setDeleteFlag(CommonConstants.ZERO_INT);
...@@ -244,6 +251,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -244,6 +251,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
return R.failed(OrderConstants.OPERATE_FAILED); return R.failed(OrderConstants.OPERATE_FAILED);
} }
} }
}
return R.ok(OrderConstants.OPERATE_SUCCESS); return R.ok(OrderConstants.OPERATE_SUCCESS);
} }
......
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