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

评论

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