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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.material.UserEmojiBagCO;
import com.red.circle.other.app.service.material.EmojiService;
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;

/**
 * 表情包服务.
 *
 * @author pengliang on 2021/10/25
 * @eo.api-type http
 * @eo.groupName 道具服务.表情包
 * @eo.path /material/emoji
 */
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/material/emoji", produces = MediaType.APPLICATION_JSON_VALUE)
public class EmojiRestController extends BaseController {

  private final EmojiService emojiService;

  /**
   * 获取表情背包.
   *
   * @eo.name 获取表情背包.
   * @eo.url
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping
  public List<UserEmojiBagCO> getExpandByUserId(AppExtCommand cmd) {
    return emojiService.listByUserEmoji(cmd);
  }

  /**
   * 获取表情背包.
   *
   * @eo.name 获取表情背包.
   * @eo.url /all
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/all")
  public List<UserEmojiBagCO> listEmojiAll(AppExtCommand cmd) {
    return emojiService.listEmojiAll(cmd);
  }

  /**
   * 购买表情包.
   *
   * @eo.name 购买表情包.
   * @eo.url /purchase
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/purchase")
  public void purchaseEmoji(@RequestBody @Validated AppIdLongCmd cmd) {
    emojiService.purchaseEmoji(cmd);
  }

}
