package com.red.circle.other.adapter.app.sys.task;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.task.CheckInRewardListCO;
import com.red.circle.other.app.dto.cmd.task.CheckInRewardCmd;
import com.red.circle.other.app.service.task.CheckInService;
import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardPropsDTO;
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 2020/5/29
 * @eo.api-type http
 * @eo.groupName 系统服务.签到打卡
 * @eo.path /task/check/in
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/task/check/in", produces = MediaType.APPLICATION_JSON_VALUE)
public class CheckInRestController extends BaseController {

  private final CheckInService checkInService;

  /**
   * ASWAT新打卡-奖励池.
   *
   * @eo.name ASWAT新打卡-奖励池.
   * @eo.url /list/award/pool
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/list/award/pool")
  public List<ActivityRewardPropsDTO> listRewardPool(AppExtCommand cmd) {
    return checkInService.listRewardPool(cmd);
  }

  /**
   * ASWAT新打卡-今天是否已签到.
   *
   * @eo.name ASWAT新打卡-今天是否已签到.
   * @eo.url /today
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/today")
  public Boolean checkToday(AppExtCommand cmd) {
    return checkInService.checkToday(cmd);
  }

  /**
   * ASWAT新打卡-抽奖.
   *
   * @eo.name ASWAT新打卡-抽奖.
   * @eo.url /lottery
   * @eo.method post
   * @eo.request-type formdata
   */
  @PostMapping("/lottery")
  public ActivityRewardPropsDTO lottery(AppExtCommand cmd) {
    return checkInService.lottery(cmd);
  }

  /**
   * 2FUN每日签到奖励列表.
   *
   * @eo.name ASWAT新打卡-今天是否已签到.
   * @eo.url /2fun/list/award
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/2fun/list/award")
  public CheckInRewardListCO listReward(AppExtCommand cmd) {
    return checkInService.listReward(cmd);
  }

  /**
   * 2FUN打卡-领取奖励.
   *
   * @eo.name ASWAT新打卡-今天是否已签到.
   * @eo.url /2fun
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/2fun")
  public Integer checkIn2Fun(@RequestBody @Validated CheckInRewardCmd cmd) {
    return checkInService.checkIn2Fun(cmd);
  }

  /**
   * 每日签到奖励列表.
   *
   * @eo.name YOLO新打卡-今天是否已签到.
   * @eo.url /2fun/list/award
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/list/award")
  public CheckInRewardListCO listRewardYolo(AppExtCommand cmd) {
    return checkInService.listReward(cmd);
  }

  /**
   * 打卡-领取奖励.
   *
   * @eo.name YOLO新打卡-今天是否已签到.
   * @eo.url /2fun
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/receive")
  public Integer checkInYolo(@RequestBody @Validated CheckInRewardCmd cmd) {
    return checkInService.checkIn2Fun(cmd);
  }


}
