[新增][商品评价]管理后台/APP端
parent
cbf5ef5953
commit
6fe5f4bc0d
@ -0,0 +1,63 @@
|
|||||||
|
package cn.iocoder.yudao.module.product.controller.app.comment;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentAdditionalReqVO;
|
||||||
|
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO;
|
||||||
|
import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
|
||||||
|
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
|
||||||
|
import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
|
@Tag(name = "用户 APP - 商品评价")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/product/comment")
|
||||||
|
@Validated
|
||||||
|
public class AppCommentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductCommentService productCommentService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得商品评价分页")
|
||||||
|
public CommonResult<PageResult<AppCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) {
|
||||||
|
PageResult<ProductCommentDO> pageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE);
|
||||||
|
return success(ProductCommentConvert.INSTANCE.convertPage02(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/create")
|
||||||
|
@Operation(summary = "创建商品评价")
|
||||||
|
public CommonResult<Boolean> createComment(@RequestBody AppCommentCreateReqVO createReqVO) {
|
||||||
|
// 查询会员 todo@艿艿 获取用户头像
|
||||||
|
// TODO: 2023/3/20 要不要判断订单、商品是否存在
|
||||||
|
MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
|
||||||
|
productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(user, createReqVO), Boolean.FALSE);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/additional")
|
||||||
|
@Operation(summary = "追加评论")
|
||||||
|
public CommonResult<Boolean> additionalComment(@RequestBody AppCommentAdditionalReqVO createReqVO) {
|
||||||
|
// 查询会员
|
||||||
|
MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
|
||||||
|
productCommentService.additionalComment(user, createReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.product.controller.app.comment.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "用户APP - 商品评价创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AppCommentCreateReqVO extends AppCommentBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "是否匿名 true:是 false:否", required = true, example = "true")
|
||||||
|
@NotNull(message = "是否匿名不能为空")
|
||||||
|
private Boolean anonymous;
|
||||||
|
|
||||||
|
@Schema(description = "交易订单编号", required = true, example = "12312")
|
||||||
|
@NotNull(message = "交易订单编号不能为空")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
@Schema(description = "交易订单项编号", required = true, example = "2312312")
|
||||||
|
@NotNull(message = "交易订单项编号不能为空")
|
||||||
|
private Long orderItemId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.product.controller.app.comment.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "用户APP - 商品评价分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class AppCommentPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "商品SPU编号", example = "29502")
|
||||||
|
@NotNull(message = "商品SPU编号不能为空")
|
||||||
|
private Long spuId;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue