提交 cee3cccb authored 作者: 吴德鹏's avatar 吴德鹏

评论新增图片、视频

上级 4f6eaa0c
...@@ -9,6 +9,7 @@ import com.example.afrishop_v3.models.*; ...@@ -9,6 +9,7 @@ import com.example.afrishop_v3.models.*;
import com.example.afrishop_v3.repository.*; import com.example.afrishop_v3.repository.*;
import com.example.afrishop_v3.security.services.AuthenticationUser; import com.example.afrishop_v3.security.services.AuthenticationUser;
import com.example.afrishop_v3.util.IdUtil; import com.example.afrishop_v3.util.IdUtil;
import com.example.afrishop_v3.util.OssUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -18,6 +19,7 @@ import org.springframework.data.domain.PageRequest; ...@@ -18,6 +19,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -556,7 +558,7 @@ public class OrderController extends Controller { ...@@ -556,7 +558,7 @@ public class OrderController extends Controller {
@PostMapping("/add/comment") @PostMapping("/add/comment")
public Result addComment(@RequestBody TbCfItemComment comment) { public Result addComment(@RequestBody TbCfItemComment comment, @RequestParam(value = "files", required = false) MultipartFile[] files) throws Exception {
TbCfUserInfo user = this.user.user(); TbCfUserInfo user = this.user.user();
...@@ -571,13 +573,24 @@ public class OrderController extends Controller { ...@@ -571,13 +573,24 @@ public class OrderController extends Controller {
return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(), "Already reviewed this product!"); return new Result(ResultCodeEnum.VALIDATE_ERROR.getCode(), "Already reviewed this product!");
} }
List<String> urls = new ArrayList<>();
if (files != null) {
for (MultipartFile file : files) {
String url = OssUtil.upload(file, "comment");
urls.add(url);
}
String strUrl = urls.stream().collect(Collectors.joining(";"));
comment.setUrls(strUrl);
}
comment.setItemId(itemId); comment.setItemId(itemId);
comment.setUser(user); comment.setUser(user);
comment.setId(IdUtil.createIdbyUUID()); comment.setId(IdUtil.createIdbyUUID());
comment.setDelFlag(0); comment.setDelFlag(1);
// comment.setLikeNum(0L); // comment.setLikeNum(0L);
comment.setCreateTime(new Date()); comment.setCreateTime(new Date());
comment.setUpdateTime(new Date()); comment.setUpdateTime(new Date());
comment.setReal(1);
// comment.setType(0); // comment.setType(0);
// if (!StringUtils.isBlank(comment.getUrls())) { // if (!StringUtils.isBlank(comment.getUrls())) {
// comment.setType(1); // comment.setType(1);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论