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

评论管理添加 sku

上级 a343cd65
......@@ -6,6 +6,7 @@ import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.vo.SkuVo;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -63,9 +64,54 @@ public class TbCfItemCommentController {
@RequiresPermissions("tbcfitemcomment:save")
@ResponseBody
public R save(@RequestBody TbCfItemCommentEntity tbCfItemComment) {
if (StringUtils.isBlank(tbCfItemComment.getUserId()) ||
tbCfItemComment.getCreateTime() == null ||
tbCfItemComment.getCommentType() == null ||
StringUtils.isBlank(tbCfItemComment.getItemId()) ||
StringUtils.isBlank(tbCfItemComment.getAttributs()) ||
StringUtils.isBlank(tbCfItemComment.getItemReview()) ||
tbCfItemComment.getItemScore() == null ||
tbCfItemComment.getLogisticsScore() == null ||
tbCfItemComment.getPriceScore() == null ||
tbCfItemComment.getServiceScore() == null) {
}
if (StringUtils.isBlank(tbCfItemComment.getUserId())) {
return R.error("请选择一个用户");
}
if (tbCfItemComment.getCreateTime() == null) {
return R.error("创建时间不能为空");
}
if (tbCfItemComment.getType() == null) {
return R.error("评论类型不能为空");
}
if (StringUtils.isBlank(tbCfItemComment.getItemId())) {
return R.error("请选择一条商品");
}
if (StringUtils.isBlank(tbCfItemComment.getAttributs())) {
return R.error("请选择商品属性");
}
if (tbCfItemComment.getItemScore() == null || !StringUtils.isNumeric(tbCfItemComment.getItemScore().toString())) {
return R.error("你输入商品评分有误");
}
if (tbCfItemComment.getServiceScore() == null || !StringUtils.isNumeric(tbCfItemComment.getServiceScore().toString())) {
return R.error("你输入服务评分有误");
}
if (tbCfItemComment.getLogisticsScore() == null || !StringUtils.isNumeric(tbCfItemComment.getLogisticsScore().toString())) {
return R.error("你输入物流评分有误");
}
if (tbCfItemComment.getPriceScore() == null || !StringUtils.isNumeric(tbCfItemComment.getPriceScore().toString())) {
return R.error("你输入价格评分有误");
}
if (StringUtils.isBlank(tbCfItemComment.getItemReview())) {
return R.error("请输入商品评价");
}
int res = tbCfItemCommentService.save(tbCfItemComment);
if (res > 0) {
return R.ok();
} else if (res == -1) {
return R.error("评分输入有误,必须是1-5之间的整数");
}
return R.error("操作失败");
}
......
......@@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
......@@ -65,6 +67,19 @@ public class TbCfItemCommentServiceImpl implements TbCfItemCommentService {
// return 0;
// }
// tbCfItemComment.setUserId(userId);
String regex = "^[1-5]{1}$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher1 = pattern.matcher(tbCfItemComment.getItemScore().toString());
Matcher matcher2 = pattern.matcher(tbCfItemComment.getItemScore().toString());
Matcher matcher3 = pattern.matcher(tbCfItemComment.getItemScore().toString());
Matcher matcher4 = pattern.matcher(tbCfItemComment.getItemScore().toString());
if (!matcher1.matches() || !matcher2.matches() || !matcher3.matches() || !matcher4.matches()) {
return -1;
}
tbCfItemComment.setId(IdUtil.createIdbyUUID());
tbCfItemComment.setCommentType(0);
tbCfItemComment.setCreateTime(new Date());
......
......@@ -122,7 +122,7 @@
AND c.comment_type=#{real}
</if>
<if test="startTime != null and startTime.trim() != '' and endTime!=null and endTime!=''">
AND c.create_time between #{startTime} and #{endTime}
AND DATE_FORMAT( c.create_time, '%Y-%m-%d' ) between #{startTime} and #{endTime}
</if>
<if test="orderNo != null and orderNo.trim() != ''">
AND o.order_no =#{orderNo}
......@@ -176,7 +176,7 @@
<if test="orderId != null">`order_id` = #{orderId},</if>
<if test="itemId != null">`item_id` = #{itemId},</if>
<if test="type != null">`type` = #{type},</if>
<if test="urls != null">`urls` = #{urls},</if>
`urls` = #{urls},
<if test="itemScore != null">`item_score` = #{itemScore},</if>
<if test="serviceScore != null">`service_score` = #{serviceScore},</if>
<if test="logisticsScore != null">`logistics_score` = #{logisticsScore},</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论