package com.zhujizheng.IHome.collect.controller; import com.zhujizheng.IHome.collect.dto.PYCollectDTO; import com.zhujizheng.IHome.collect.service.PYCollectService; import com.zhujizheng.IHome.collect.vo.PYCollectVO; import com.zhujizheng.IHome.util.response.ResponseResult; import com.zhujizheng.IHome.util.response.RestResultGenerator; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * Created with IntelliJ IDEA *
* Author: yons
* Date: 2021/03/20
* Time: 01:48
* Description:
* Copyright © 2021年 com.zhujizheng. All rights reserved.
*/
@Api("收藏相关")
@RestController
@RequestMapping("/collect")
@Slf4j
public class PYCollectController {
@Autowired
private PYCollectService collectService;
@ApiOperation("添加收藏数据")
@ApiImplicitParam(name = "collectDTO", value = "添加的收藏数据", required = true, dataType = "PYCollectDTO")
@PostMapping("/push")
public ResponseResult pushCollect(@Validated @RequestBody PYCollectDTO pushDTO) {
System.out.println("pushDTO = " + pushDTO);
PYCollectVO vo = collectService.pushCollectWithDTO(pushDTO);
if (vo == null) {
return RestResultGenerator.genErrorResult("收藏失败");
} else {
return RestResultGenerator.genResult(vo, "收藏成功");
}
}
@ApiOperation("获取收藏数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "int"),
@ApiImplicitParam(name = "collectId", value = "收藏id", paramType = "path", required = true, dataType = "int"),
})
@GetMapping("/pull/{userId}/{collectId}")
public ResponseResult getCollectWithId(@PathVariable int userId, @PathVariable int collectId) {
List