Update ProdCommController.java

cyj
pbvfus8to 2 months ago
parent 9f19c0617c
commit ef4d91a5d9

@ -30,39 +30,76 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date; import java.util.Date;
/** /**
*
*
* `Swagger`便使
*
* @author lanhai * @author lanhai
*/ */
@RestController @RestController
@RequestMapping("/prodComm") @RequestMapping("/prodComm")
@Tag(name = "评论接口") @Tag(name = "评论接口")
// 使用 @AllArgsConstructor 注解,由 lombok 自动生成包含所有成员变量的构造函数,用于依赖注入
@AllArgsConstructor @AllArgsConstructor
public class ProdCommController { public class ProdCommController {
// 通过构造函数注入ProdCommService用于调用业务层方法来处理商品评论相关的业务逻辑
private final ProdCommService prodCommService; private final ProdCommService prodCommService;
/**
*
* ID
*
* @param prodId ID
* @return ServerResponseEntity<ProdCommDataDto>DTO
*/
@GetMapping("/prodCommData") @GetMapping("/prodCommData")
@Operation(summary = "返回商品评论数据(好评率 好评数量 中评数 差评数)" , description = "根据商品id获取") @Operation(summary = "返回商品评论数据(好评率 好评数量 中评数 差评数)", description = "根据商品id获取")
public ServerResponseEntity<ProdCommDataDto> getProdCommData(Long prodId) { public ServerResponseEntity<ProdCommDataDto> getProdCommData(Long prodId) {
return ServerResponseEntity.success(prodCommService.getProdCommDataByProdId(prodId)); return ServerResponseEntity.success(prodCommService.getProdCommDataByProdId(prodId));
} }
/**
*
*
*
* @param page
* @return ServerResponseEntity<IPage<ProdCommDto>>DTO
*/
@GetMapping("/prodCommPageByUser") @GetMapping("/prodCommPageByUser")
@Operation(summary = "根据用户返回评论分页数据" , description = "传入页码") @Operation(summary = "根据用户返回评论分页数据", description = "传入页码")
public ServerResponseEntity<IPage<ProdCommDto>> getProdCommPage(PageParam page) { public ServerResponseEntity<IPage<ProdCommDto>> getProdCommPage(PageParam page) {
return ServerResponseEntity.success(prodCommService.getProdCommDtoPageByUserId(page, SecurityUtils.getUser().getUserId())); return ServerResponseEntity.success(prodCommService.getProdCommDtoPageByUserId(page, SecurityUtils.getUser().getUserId()));
} }
@GetMapping("/prodCommPageByProd") /**
@Operation(summary = "根据商品返回评论分页数据" , description = "传入商品id和页码") *
* ID
*
*
* @param page
* @param prodId ID
* @param evaluate -1 null 0 1 2 3
* @return ServerResponseEntity<IPage<ProdCommDto>>DTO
*/
@GetMapping("/prodCommPageByProdId")
@Operation(summary = "根据商品返回评论分页数据", description = "传入商品id和页码")
@Parameters({ @Parameters({
@Parameter(name = "prodId", description = "商品id" , required = true), @Parameter(name = "prodId", description = "商品id", required = true),
@Parameter(name = "evaluate", description = "-1或null 全部0好评 1中评 2差评 3有图" , required = true), @Parameter(name = "evaluate", description = "-1或null 全部0好评 1中评 2差评 3有图", required = true),
}) })
public ServerResponseEntity<IPage<ProdCommDto>> getProdCommPageByProdId(PageParam page, Long prodId, Integer evaluate) { public ServerResponseEntity<IPage<ProdCommDto>> getProdCommPageByProdId(PageParam page, Long prodId, Integer evaluate) {
return ServerResponseEntity.success(prodCommService.getProdCommDtoPageByProdId(page, prodId, evaluate)); return ServerResponseEntity.success(prodCommService.getProdCommDtoPageByProdId(page, prodId, evaluate));
} }
/**
*
* IDID
*
*
* @param prodCommParam IDIDID
* @return ServerResponseEntity<Void>
*/
@PostMapping @PostMapping
@Operation(summary = "添加评论") @Operation(summary = "添加评论")
public ServerResponseEntity<Void> saveProdCommPage(ProdCommParam prodCommParam) { public ServerResponseEntity<Void> saveProdCommPage(ProdCommParam prodCommParam) {
@ -81,10 +118,17 @@ public class ProdCommController {
return ServerResponseEntity.success(); return ServerResponseEntity.success();
} }
/**
*
* ID
*
* @param prodCommId ID
* @return ServerResponseEntity<Void>
*/
@DeleteMapping @DeleteMapping
@Operation(summary = "删除评论" , description = "根据id删除") @Operation(summary = "删除评论", description = "根据id删除")
public ServerResponseEntity<Void> deleteProdComm(Long prodCommId) { public ServerResponseEntity<Void> deleteProdComm(Long prodCommId) {
prodCommService.removeById(prodCommId); prodCommService.removeById(prodCommId);
return ServerResponseEntity.success(); return ServerResponseEntity.success();
} }
} }
Loading…
Cancel
Save