package com.zhujizheng.IHome.remark.controller; import com.zhujizheng.IHome.remark.dto.PYRemarkUpdateDTO; import com.zhujizheng.IHome.remark.service.PYRemarkService; import com.zhujizheng.IHome.remark.vo.PYRemarkVO; 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/21 * Time: 02:45 * Description: * Copyright © 2021年 com.zhujizheng. All rights reserved. */ @Api("备注相关") @RestController @RequestMapping("/remark") @Slf4j public class PYRemarkController { @Autowired private PYRemarkService remarkService; @ApiOperation("获取所有备注") @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "int") @GetMapping("/pull/{userId}") public ResponseResult getCollectWithId(@PathVariable int userId) { List voList = remarkService.getAllRemark(userId); if (voList == null) { return RestResultGenerator.genErrorResult("获取备注数据失败"); } return RestResultGenerator.genResult(voList, "获取备注数据成功"); } @ApiOperation("获取备注数据,指定friendId") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", paramType = "path", required = true, dataType = "int"), @ApiImplicitParam(name = "friendId", value = "好友id", paramType = "path", required = true, dataType = "int") }) @GetMapping("/pull/{userId}/{friendId}") public ResponseResult getCollectWithId(@PathVariable int userId, @PathVariable int friendId) { PYRemarkVO vo = remarkService.getRemark(userId, friendId); if (vo == null) { return RestResultGenerator.genErrorResult("获取备注数据失败"); } return RestResultGenerator.genResult(vo, "获取备注数据成功"); } @ApiOperation("更新备注") @ApiImplicitParam(name = "updateDTO", value = "修改备注的数据", required = true, dataType = "PYRemarkUpdateDTO") @PostMapping("/update") public ResponseResult updateDayMatter(@Validated @RequestBody PYRemarkUpdateDTO updateDTO) { log.info("修改备注,updateDTO: " + updateDTO); int result = remarkService.changeRemark(updateDTO); if (result == 0) { return RestResultGenerator.genErrorResult("修改备注失败"); } else { return RestResultGenerator.genResult(null, "修改备注成功"); } } }