package com.red.circle.other.adapter.app.dynamic;

import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.dynamic.UserThumbsUpCO;
import com.red.circle.other.app.dto.cmd.dynamic.UserRelationThumbsUpCmd;
import com.red.circle.other.app.service.dynamic.UserRelationThumbsUpService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户点赞列表 前端控制器.
 * </p>
 *
 * @author zongpubin on 2023-04-06 11:41
 * @eo.api-type http
 * @eo.groupName 动态服务.用户点赞
 * @eo.path /dynamic/thumbs-up
 */
@RestController
@RequestMapping(value = "/dynamic/thumbs-up", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class ThumbsUpRestController extends BaseController {

  private final UserRelationThumbsUpService userRelationThumbsUpService;

  /**
   * 点赞
   *
   * @eo.name 点赞
   * @eo.url /like
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/like")
  public Boolean like(@RequestBody @Validated UserRelationThumbsUpCmd cmd) {
    return userRelationThumbsUpService.thumbsUp(cmd);
  }

  /**
   * 点赞数量，是否已经点赞
   *
   * @eo.name 点赞数量，是否已经点赞
   * @eo.url /info
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/info")
  public UserThumbsUpCO thumbsUpInfo(UserRelationThumbsUpCmd cmd) {
    return userRelationThumbsUpService.thumbsUpInfo(cmd);
  }

}
