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

评论

上级 e4a175f4
...@@ -560,7 +560,9 @@ public class OrderController extends Controller { ...@@ -560,7 +560,9 @@ public class OrderController extends Controller {
@PostMapping("/add/comment") @PostMapping("/add/comment")
public Result addComment(TbCfItemComment comment, @RequestParam(value = "files", required = false) MultipartFile[] files) throws Exception { public Result addComment(TbCfItemComment comment) throws Exception {
logger.info("上传files:", comment.getFiles());
TbCfUserInfo user = this.user.user(); TbCfUserInfo user = this.user.user();
...@@ -568,16 +570,16 @@ public class OrderController extends Controller { ...@@ -568,16 +570,16 @@ public class OrderController extends Controller {
String itemId = comment.getItemId(); String itemId = comment.getItemId();
boolean exists = commentRepository.existsByUserUserIdAndItemId(userId, itemId); // boolean exists = commentRepository.existsByUserUserIdAndItemId(userId, itemId);
//
if (exists) { // if (exists) {
//Product reviewed condition // //Product reviewed condition
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<>(); List<String> urls = new ArrayList<>();
if (files != null) { if (comment.getFiles() != null) {
for (MultipartFile file : files) { for (MultipartFile file : comment.getFiles()) {
byte[] bytes = PicUtils.compressPicForScale(file.getBytes(), 30); byte[] bytes = PicUtils.compressPicForScale(file.getBytes(), 30);
// ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); // ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
String urlName = UUID.randomUUID() + ".jpg"; String urlName = UUID.randomUUID() + ".jpg";
...@@ -595,7 +597,7 @@ public class OrderController extends Controller { ...@@ -595,7 +597,7 @@ public class OrderController extends Controller {
// 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.setCommentType(1);
// comment.setType(0); // comment.setType(0);
// if (!StringUtils.isBlank(comment.getUrls())) { // if (!StringUtils.isBlank(comment.getUrls())) {
// comment.setType(1); // comment.setType(1);
......
...@@ -7,6 +7,7 @@ import org.hibernate.annotations.Formula; ...@@ -7,6 +7,7 @@ import org.hibernate.annotations.Formula;
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.persistence.*; import javax.persistence.*;
...@@ -90,8 +91,8 @@ public class TbCfItemComment { ...@@ -90,8 +91,8 @@ public class TbCfItemComment {
private Date createTime; private Date createTime;
@JsonIgnore @JsonIgnore
@Transient // @Transient
private Integer real; private Integer commentType;
/** /**
* 更新时间 * 更新时间
*/ */
...@@ -109,6 +110,10 @@ public class TbCfItemComment { ...@@ -109,6 +110,10 @@ public class TbCfItemComment {
@Transient @Transient
private boolean isLike; private boolean isLike;
@JsonIgnore
@Transient
private MultipartFile[] files;
// @Formula(value = "(SELECT IFNULL(COUNT(*),0) FROM tb_cf_item_like lk where lk.comment_id = id)") // @Formula(value = "(SELECT IFNULL(COUNT(*),0) FROM tb_cf_item_like lk where lk.comment_id = id)")
@Transient @Transient
private int likeCount; private int likeCount;
...@@ -118,7 +123,6 @@ public class TbCfItemComment { ...@@ -118,7 +123,6 @@ public class TbCfItemComment {
private double totalScore; private double totalScore;
private String attributs; private String attributs;
public String getAttributs() { public String getAttributs() {
...@@ -404,12 +408,12 @@ public class TbCfItemComment { ...@@ -404,12 +408,12 @@ public class TbCfItemComment {
return user; return user;
} }
public Integer getReal() { public Integer getCommentType() {
return real; return commentType;
} }
public void setReal(Integer real) { public void setCommentType(Integer commentType) {
this.real = real; this.commentType = commentType;
} }
public String getAvatar() { public String getAvatar() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论