parent
c1935fba2d
commit
f69d8503a2
|
@ -1,8 +1,8 @@
|
|||
package cn.iocoder.yudao.module.product.dal.dataobject.comment;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.enums.comment.ProductCommentAuditStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("product_comment")
|
||||
@TableName(value = "product_comment", autoResultMap = true)
|
||||
@KeySequence("product_comment_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -33,97 +33,139 @@ public class ProductCommentDO extends BaseDO {
|
|||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*
|
||||
* 关联 {@link ProductSpuDO#getId()}
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 交易订单编号
|
||||
*
|
||||
* 关联 TradeOrderDO 的 id 编号
|
||||
*/
|
||||
private Long orderId;
|
||||
/**
|
||||
* 交易订单项编号
|
||||
*
|
||||
* 关联 TradeOrderItemDO 的 id 编号
|
||||
*/
|
||||
private Long orderItemId;
|
||||
/**
|
||||
* 审核状态
|
||||
*
|
||||
* 枚举 {@link ProductCommentAuditStatusEnum}
|
||||
*/
|
||||
private Integer auditStatus;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*
|
||||
* 评价人 用户编号
|
||||
* <p>
|
||||
* 关联 MemberUserDO 的 id 编号
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户 IP
|
||||
* 评价人名称
|
||||
*/
|
||||
private String userIp;
|
||||
private Long userNickname;
|
||||
|
||||
/**
|
||||
* 评价人头像
|
||||
*/
|
||||
private Long userAvatar;
|
||||
|
||||
/**
|
||||
* 是否匿名
|
||||
*/
|
||||
private Boolean anonymous;
|
||||
|
||||
/**
|
||||
* 交易订单编号
|
||||
* <p>
|
||||
* 关联 TradeOrderDO 的 id 编号
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 交易订单项编号
|
||||
* <p>
|
||||
* 关联 TradeOrderItemDO 的 id 编号
|
||||
*/
|
||||
private Long orderItemId;
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
* <p>
|
||||
* 关联 {@link ProductSpuDO#getId()}
|
||||
*/
|
||||
private Long spuId;
|
||||
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
* <p>
|
||||
* 关联 {@link ProductSkuDO#getId()}
|
||||
*/
|
||||
private Long skuId;
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
* <p>
|
||||
* 1:显示 0:隐藏
|
||||
*/
|
||||
private Boolean visible;
|
||||
|
||||
/**
|
||||
* 评分星级
|
||||
* <p>
|
||||
* 1-5分
|
||||
*/
|
||||
private Integer scores;
|
||||
|
||||
/**
|
||||
* 描述星级
|
||||
* <p>
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer descriptionScores;
|
||||
|
||||
/**
|
||||
* 服务星级
|
||||
* <p>
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer benefitScores;
|
||||
|
||||
/**
|
||||
* 配送星级
|
||||
* <p>
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer deliveryScores;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 评论图片地址数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> picUrls;
|
||||
/**
|
||||
* 描述相符星级
|
||||
*
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer descriptionScore;
|
||||
/**
|
||||
* 商品评论星级
|
||||
*
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer productScore;
|
||||
/**
|
||||
* 服务评论星级
|
||||
*
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer serviceScore;
|
||||
/**
|
||||
* 物流评论星级
|
||||
*
|
||||
* 1-5 星
|
||||
*/
|
||||
private Integer expressComment;
|
||||
|
||||
/**
|
||||
* 商家是否回复
|
||||
*/
|
||||
private Boolean replied;
|
||||
|
||||
/**
|
||||
* 回复管理员编号
|
||||
* <p>
|
||||
* 关联 AdminUserDO 的 id 编号
|
||||
*/
|
||||
private Long replyUserId;
|
||||
|
||||
/**
|
||||
* 商家回复内容
|
||||
*/
|
||||
private String replyContent;
|
||||
|
||||
/**
|
||||
* 商家回复时间
|
||||
*/
|
||||
private LocalDateTime replyTime;
|
||||
|
||||
/**
|
||||
* 有用的计数
|
||||
*
|
||||
* 其他用户看到评论时,可点击「有用」按钮
|
||||
* 追加评价内容
|
||||
*/
|
||||
private Integer usefulCount;
|
||||
private String additionalContent;
|
||||
|
||||
/**
|
||||
* 追评评价图片地址数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> additionalPicUrls;
|
||||
|
||||
/**
|
||||
* 追加评价时间
|
||||
*/
|
||||
private LocalDateTime additionalCreateTime;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package cn.iocoder.yudao.module.product.dal.mysql.comment;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 商品评论 Mapper
|
||||
*
|
||||
* @author wangzhs
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.iocoder.yudao.module.product.service.comment;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 商品评论 Service 接口
|
||||
*
|
||||
* @author wangzhs
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public interface ProductCommentService {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package cn.iocoder.yudao.module.product.service.comment;
|
||||
|
||||
/**
|
||||
* 商品评论 Service 实现类
|
||||
*
|
||||
* @author wangzhs
|
||||
*/
|
||||
public class ProductCommentServiceImpl implements ProductCommentService {
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.iocoder.yudao.module.product.service.comment;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
|
||||
/**
|
||||
* {@link ProductCommentServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author wangzhs
|
||||
*/
|
||||
@Import(ProductCommentServiceImpl.class)
|
||||
public class ProductCommentServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ProductCommentMapper productCommentMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateCommentAndGet_success() {
|
||||
// mock 测试
|
||||
ProductCommentDO productComment = randomPojo(ProductCommentDO.class);
|
||||
productCommentMapper.insert(productComment);
|
||||
|
||||
// 断言
|
||||
// 校验记录的属性是否正确
|
||||
ProductCommentDO comment = productCommentMapper.selectById(productComment.getId());
|
||||
assertPojoEquals(productComment, comment);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,3 +2,4 @@ DELETE FROM "product_sku";
|
|||
DELETE FROM "product_spu";
|
||||
DELETE FROM "product_brand";
|
||||
DELETE FROM "product_category";
|
||||
DELETE FROM "product_comment";
|
||||
|
|
|
@ -82,3 +82,35 @@ CREATE TABLE IF NOT EXISTS `product_brand` (
|
|||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '商品品牌';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `product_comment` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '评价编号',
|
||||
`user_id` bigint NOT NULL COMMENT ' 评价ID 用户编号',
|
||||
`user_nickname` varchar(128) NOT NULL COMMENT '评价人名称',
|
||||
`user_avatar` varchar(255) NOT NULL COMMENT '评价人头像',
|
||||
`anonymous` bit(1) NOT NULL DEFAULT 0 COMMENT '是否匿名 0:不匿名 1:匿名',
|
||||
`order_id` bigint NOT NULL COMMENT '交易订单编号',
|
||||
`order_item_id` bigint NOT NULL COMMENT '交易订单项编号',
|
||||
`spu_id` bigint NOT NULL COMMENT '商品SPU编号',
|
||||
`sku_id` bigint NOT NULL COMMENT '商品SKU编号',
|
||||
`visible` bit(1) NOT NULL DEFAULT 1 COMMENT '是否可见 1:显示 0:隐藏',
|
||||
`scores` int NOT NULL COMMENT '评分星级 1-5分',
|
||||
`description_scores` int NOT NULL COMMENT '描述星级 1-5分',
|
||||
`benefit_scores` int NOT NULL COMMENT '服务星级 1-5分',
|
||||
`delivery_scores` int NOT NULL COMMENT '配送星级 1-5分',
|
||||
`content` varchar(2000) NOT NULL COMMENT '评论内容',
|
||||
`pic_urls` varchar(1024) DEFAULT '' COMMENT '评论图片地址数组,以逗号分隔最多上传9张',
|
||||
`replied` bit(1) NOT NULL DEFAULT 0 COMMENT '商家是否回复 1:回复 0:未回复',
|
||||
`reply_user_id` bigint COMMENT '回复管理员编号',
|
||||
`reply_content` varchar(2000) COMMENT '商家回复内容',
|
||||
`reply_time` datetime COMMENT '商家回复时间',
|
||||
`additional_content` varchar(2000) COMMENT '追加评价内容',
|
||||
`additional_pic_urls` varchar(1024) COMMENT '追评评价图片地址数组,以逗号分隔最多上传9张',
|
||||
`additional_create_time` datetime COMMENT '追加评价时间',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`creator` varchar DEFAULT NULL COMMENT '创建人',
|
||||
`updater` varchar DEFAULT NULL COMMENT '更新人',
|
||||
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`)
|
||||
) COMMENT '商品评价';
|
Loading…
Reference in New Issue