src/main/java/com/mzl/flower/dto/request/comment/QueryFlowerCommentDTO.java
@@ -42,4 +42,7 @@ @ApiModelProperty(value = "商品id") private Long flowerId; @ApiModelProperty(value = "隐藏标识 0 显示 1隐藏") private Integer showFlag; } src/main/java/com/mzl/flower/dto/request/comment/ReplayFlowerCommentDTO.java
对比新文件 @@ -0,0 +1,25 @@ package com.mzl.flower.dto.request.comment; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; @Data public class ReplayFlowerCommentDTO { @ApiModelProperty(value = "id") private String id; /** * 回复内容 */ @ApiModelProperty(value = "回复内容") @NotEmpty(message = "回复内容不能为空") private String replayContent; } src/main/java/com/mzl/flower/dto/request/comment/ShowFlowerCommentDTO.java
对比新文件 @@ -0,0 +1,24 @@ package com.mzl.flower.dto.request.comment; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; @Data public class ShowFlowerCommentDTO { @ApiModelProperty(value = "id") private String id; /** * 显示隐藏 */ @ApiModelProperty(value = "显示0/隐藏1") @NotNull(message = "显示/隐藏不能为空") private Integer showFalg; } src/main/java/com/mzl/flower/dto/request/comment/UpdateFlowerCommentDTO.java
@@ -12,6 +12,7 @@ public class UpdateFlowerCommentDTO { @ApiModelProperty(value = "id") @NotEmpty(message = "ID不能为空") private String id; /** @@ -42,5 +43,4 @@ */ @ApiModelProperty(value = "匿名标志") private Integer anonymityFalg; } src/main/java/com/mzl/flower/entity/FlowerCommentDO.java
@@ -2,7 +2,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.mzl.flower.base.BaseEntity; import java.sql.Blob; import java.time.LocalDateTime; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -80,5 +82,28 @@ */ private Integer anonymityFalg; /** * 显示标志 0-显示 1-隐藏 */ private Integer showFlag; /** * 回复内容 */ private String replayContent; /** * 回复人 */ private String replayBy; /** * 回复时间 */ private LocalDateTime replayTime; } src/main/java/com/mzl/flower/enums/FlowerCommentShowEnum.java
对比新文件 @@ -0,0 +1,17 @@ package com.mzl.flower.enums; import lombok.Getter; public enum FlowerCommentShowEnum { SHOW(0), HIDE(1), ; @Getter private Integer flag; private FlowerCommentShowEnum(Integer flag){ this.flag=flag; } } src/main/java/com/mzl/flower/service/comment/FlowerCommentService.java
@@ -1,10 +1,7 @@ package com.mzl.flower.service.comment; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mzl.flower.dto.request.comment.CreateFlowerCommentBatchDTO; import com.mzl.flower.dto.request.comment.CreateFlowerCommentDTO; import com.mzl.flower.dto.request.comment.QueryFlowerCommentDTO; import com.mzl.flower.dto.request.comment.UpdateFlowerCommentDTO; import com.mzl.flower.dto.request.comment.*; import com.mzl.flower.dto.response.comment.FlowerCommentStatisVO; import com.mzl.flower.dto.response.comment.FlowerCommentVO; import com.mzl.flower.entity.FlowerCommentDO; @@ -53,4 +50,13 @@ boolean createFlowerCommentBatch(CreateFlowerCommentBatchDTO dto); FlowerCommentStatisVO getSupplierStatis(Long id); /** * 评论的显示隐藏 * @param dto * @return */ boolean updateShowFlowerComment(ShowFlowerCommentDTO dto); boolean updateReplayFlowerComment(ReplayFlowerCommentDTO dto); } src/main/java/com/mzl/flower/service/impl/comment/FlowerCommentServiceImpl.java
@@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mzl.flower.config.exception.ValidationException; import com.mzl.flower.config.security.SecurityUtils; import com.mzl.flower.dto.request.comment.CreateFlowerCommentBatchDTO; import com.mzl.flower.dto.request.comment.CreateFlowerCommentDTO; import com.mzl.flower.dto.request.comment.QueryFlowerCommentDTO; import com.mzl.flower.dto.request.comment.UpdateFlowerCommentDTO; import com.mzl.flower.dto.request.comment.*; import com.mzl.flower.dto.response.comment.FlowerCommentStatisVO; import com.mzl.flower.dto.response.comment.FlowerCommentVO; import com.mzl.flower.entity.FlowerCommentDO; @@ -16,6 +13,8 @@ import com.mzl.flower.entity.payment.Order; import com.mzl.flower.entity.payment.OrderItem; import com.mzl.flower.entity.supplier.Supplier; import com.mzl.flower.enums.FlowerCommentShowEnum; import com.mzl.flower.enums.TrueOrFalseEnum; import com.mzl.flower.mapper.comment.FlowerCommentMapper; import com.mzl.flower.mapper.comment.FlowerCommentMapperCustom; import com.mzl.flower.mapper.customer.CustomerMapper; @@ -32,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; /** @@ -97,6 +97,9 @@ if(null!=supplier && StringUtils.isNotBlank(supplier.getUserId())){ flowerCommentDO.setSupplierUserId(supplier.getUserId()); } // 设置显示状态为显示 flowerCommentDO.setShowFlag(FlowerCommentShowEnum.SHOW.getFlag()); return baseMapper.insert(flowerCommentDO)>0; } @@ -188,10 +191,36 @@ vo.setAvg(supplierAvgScore); //当前商家评论总数 final Integer amount = baseMapper.selectCount(new QueryWrapper<FlowerCommentDO>().lambda().eq(FlowerCommentDO::getSupplierId, supplierId)); final Integer amount = baseMapper.selectCount(new QueryWrapper<FlowerCommentDO>().lambda() .eq(FlowerCommentDO::getDeleted, TrueOrFalseEnum.FALSE) .eq(FlowerCommentDO::getShowFlag,FlowerCommentShowEnum.SHOW.getFlag()) .eq(FlowerCommentDO::getSupplierId, supplierId)); vo.setCommentAmount(amount); return vo; } @Override public boolean updateShowFlowerComment(ShowFlowerCommentDTO dto) { FlowerCommentDO flowerCommentDO = baseMapper.selectById(dto.getId()); if (null == flowerCommentDO) { throw new ValidationException("评论不存在"); } flowerCommentDO.setShowFlag(dto.getShowFalg()); flowerCommentDO.setUpdateBy(SecurityUtils.getUserId()); return baseMapper.updateById(flowerCommentDO)>0; } @Override public boolean updateReplayFlowerComment(ReplayFlowerCommentDTO dto) { FlowerCommentDO flowerCommentDO = baseMapper.selectById(dto.getId()); if (null == flowerCommentDO) { throw new ValidationException("评论不存在"); } flowerCommentDO.setReplayBy(dto.getReplayContent()); flowerCommentDO.setReplayTime(LocalDateTime.now()); flowerCommentDO.setUpdateBy(SecurityUtils.getUserId()); return baseMapper.updateById(flowerCommentDO)>0; } } src/main/java/com/mzl/flower/web/v2/comment/FlowerCommentController.java
@@ -6,10 +6,7 @@ import com.mzl.flower.base.R; import com.mzl.flower.base.ReturnDataDTO; import com.mzl.flower.config.exception.ValidationException; import com.mzl.flower.dto.request.comment.CreateFlowerCommentBatchDTO; import com.mzl.flower.dto.request.comment.CreateFlowerCommentDTO; import com.mzl.flower.dto.request.comment.QueryFlowerCommentDTO; import com.mzl.flower.dto.request.comment.UpdateFlowerCommentDTO; import com.mzl.flower.dto.request.comment.*; import com.mzl.flower.dto.response.comment.FlowerCommentVO; import com.mzl.flower.dto.response.coupon.CouponTemplatePointVO; import com.mzl.flower.dto.response.coupon.CouponTemplateVO; @@ -120,6 +117,26 @@ return returnData(R.SUCCESS.getCode(), flowerCommentService.getSupplierStatis(id)); } @PutMapping("/show/{id}") @ApiOperation(value = "显示/隐藏", notes = "显示/隐藏") public ResponseEntity<ReturnDataDTO> updateShow(@PathVariable String id,@Validated @RequestBody ShowFlowerCommentDTO dto) { // 手动设置id值 dto.setId(id); flowerCommentService.updateShowFlowerComment(dto); return returnData(R.SUCCESS.getCode(), null); } @PutMapping("/replay/{id}") @ApiOperation(value = "评论回复", notes = "评论回复") public ResponseEntity<ReturnDataDTO> updateReplay(@PathVariable String id,@Validated @RequestBody ReplayFlowerCommentDTO dto) { // 手动设置id值 dto.setId(id); flowerCommentService.updateReplayFlowerComment(dto); return returnData(R.SUCCESS.getCode(), null); } private void valid(CreateFlowerCommentDTO dto){ } src/main/resources/mapper/calendar/CalendarMapperCustom.xml
@@ -17,7 +17,7 @@ from t_calendar t where 1=1 <if test="dto.startDate != null"> and t.cal_date > #{dto.startDate} and t.cal_date >= #{dto.startDate} </if> <if test="dto.endDate != null"> and t.cal_date <= #{dto.endDate} src/main/resources/mapper/comment/FlowerCommentMapper.xml
@@ -18,6 +18,13 @@ <result column="comment" property="comment" /> <result column="comment_images" property="commentImages" /> <result column="anonymity_falg" property="anonymityFalg" /> <result column="show_flag" property="showFlag" /> <result column="replay_content" property="replayContent" /> <result column="replay_by" property="replayBy" /> <result column="replay_time" property="replayTime" /> </resultMap> </mapper> src/main/resources/mapper/comment/FlowerCommentMapperCustom.xml
@@ -2,29 +2,6 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.mzl.flower.mapper.comment.FlowerCommentMapperCustom"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.mzl.flower.entity.FlowerCommentDO"> <id column="id" property="id" /> <result column="deleted" property="deleted" /> <result column="create_by" property="createBy" /> <result column="create_time" property="createTime" /> <result column="update_by" property="updateBy" /> <result column="update_time" property="updateTime" /> <result column="order_id" property="orderId" /> <result column="order_item_id" property="orderItemId" /> <result column="customer_id" property="customerId" /> <result column="customer_user_id" property="customerUserId" /> <result column="supplier_id" property="supplierId" /> <result column="supplier_user_id" property="supplierUserId" /> <result column="flower_id" property="flowerId" /> <result column="flower_cover" property="flowerCover" /> <result column="comment_grade" property="commentGrade" /> <result column="comment" property="comment" /> <result column="comment_images" property="commentImages" /> <result column="anonymity_falg" property="anonymityFalg" /> </resultMap> <select id="getPage" resultType="com.mzl.flower.dto.response.comment.FlowerCommentVO"> <include refid="baseSql" /> </select> @@ -35,7 +12,7 @@ SELECT COALESCE(ROUND(SUM(c.comment_grade) / NULLIF(COUNT(1), 0), 1), 0) AS average_grade FROM t_flower_comment c WHERE c.deleted = false WHERE c.deleted = false and c.show_flag=0 AND c.supplier_id = #{supplierId} </select> @@ -72,6 +49,11 @@ <if test="param.flowerId != null"> and c.flower_id = #{param.flowerId} </if> <if test="param.showFlag != null"> and c.show_flag = #{param.showFlag} </if> order by c.create_time desc