package com.red.circle.other.adapter.app.user.relation;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardApplyCO;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardCO;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardCountMessageCO;
import com.red.circle.other.app.dto.clientobject.user.relation.friendcard.UserFriendCardStoreCO;
import com.red.circle.other.app.dto.cmd.user.relation.cp.ProcessApplyCmd;
import com.red.circle.other.app.dto.cmd.user.relation.friendcard.FriendshipCardApplyCmd;
import com.red.circle.other.app.dto.cmd.user.relation.friendcard.FriendshipCardApplyDismissCmd;
import com.red.circle.other.app.dto.cmd.user.relation.friendcard.FriendshipCardPageCmd;
import com.red.circle.other.app.service.user.relation.UserFriendCardService;
import java.util.List;
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 pengshigang
 * @eo.api-type http
 * @eo.groupName 用户服务.友谊关系卡
 * @eo.path /user/user-friendship/card
 * @since 2022-06-09
 */
@RestController
@RequestMapping(value = "/user/user-friendship/card", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserFriendshipCardRestController extends BaseController {

  private final UserFriendCardService userFriendCardService;

  /**
   * 友谊卡商店.
   *
   * @eo.name 友谊卡商店.
   * @eo.url /store
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/store")
  public List<UserFriendCardStoreCO> store(AppExtCommand cmd) {
    return userFriendCardService.cards(cmd);
  }

  /**
   * 获取五张不同友谊卡.
   *
   * @eo.name 获取五张不同友谊卡.
   * @eo.url /cards
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/cards")
  public List<UserFriendCardCO> cards(AppUserIdCmd cmd) {
    return userFriendCardService.userCards(cmd);
  }

  /**
   * 获得指定卡片类型的用户集合.
   *
   * @eo.name 获得指定卡片类型的用户集合.
   * @eo.url /page
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/page")
  public List<UserFriendCardCO> pageUserByType(@Validated FriendshipCardPageCmd cmd) {
    return userFriendCardService.pageUserByType(cmd);
  }

  /**
   * 友谊关系卡 申请.
   *
   * @eo.name 友谊关系卡 申请.
   * @eo.url /send-apply
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/send-apply")
  public void sendApply(@RequestBody @Validated FriendshipCardApplyCmd cmd) {
    userFriendCardService.sendApply(cmd);
  }

  /**
   * 处理友谊卡申请记录.
   *
   * @eo.name 处理友谊卡申请记录.
   * @eo.url /process-apply
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/process-apply")
  public void processApply(@RequestBody @Validated ProcessApplyCmd cmd) {
    userFriendCardService.processApply(cmd);
  }

  /**
   * 解除指定关系卡.
   *
   * @eo.name 解除指定关系卡.
   * @eo.url /dismiss-apply
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/dismiss-apply")
  public void dismissApply(@RequestBody @Validated FriendshipCardApplyDismissCmd cmd) {
    userFriendCardService.dismissApply(cmd);
  }

  /**
   * 获取友谊关系卡申请记录分页.
   *
   * @eo.name 获取友谊关系卡申请记录分页.
   * @eo.url /page-apply
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/page-apply")
  public List<UserFriendCardApplyCO> pageApply(@Validated FriendshipCardPageCmd cmd) {
    return userFriendCardService.pageApply(cmd);
  }

  /**
   * 统计未同意友谊关系卡申请、好友申请、我的消息列表.
   *
   * @eo.name 获取友谊关系卡申请记录分页.
   * @eo.url /count-message
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/count-message")
  public UserFriendCardCountMessageCO countMessageInfo(AppExtCommand cmd) {
    return userFriendCardService.countMessageInfo(cmd);
  }


}
