[新增][商品评价]

1. 实体类
2. h2.sql
pull/2/head
wangzhs 2023-03-19 15:47:49 +08:00
parent c1935fba2d
commit f69d8503a2
7 changed files with 211 additions and 58 deletions

View File

@ -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;
}

View File

@ -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> {
}

View File

@ -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 {
}

View File

@ -0,0 +1,9 @@
package cn.iocoder.yudao.module.product.service.comment;
/**
* Service
*
* @author wangzhs
*/
public class ProductCommentServiceImpl implements ProductCommentService {
}

View File

@ -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);
}
}

View File

@ -2,3 +2,4 @@ DELETE FROM "product_sku";
DELETE FROM "product_spu";
DELETE FROM "product_brand";
DELETE FROM "product_category";
DELETE FROM "product_comment";

View File

@ -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 '';