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.DailyTaskStorageCO;
import com.red.circle.other.app.dto.cmd.task.DailyTasksEventCmd;
import com.red.circle.other.app.service.task.DailyTasksService;
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/10/20
 * @eo.api-type http
 * @eo.groupName 系统服务.每日任务
 * @eo.path /task/daily/task
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/task/daily/task", produces = MediaType.APPLICATION_JSON_VALUE)
public class DailyTaskRestController extends BaseController {

  private final DailyTasksService dailyTasksService;

  /**
   * 标记已完成奖励.
   *
   * @eo.name 标记已完成奖励.
   * @eo.url /completed-setting
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/completed-setting")
  public void completedTaskSetting(@RequestBody @Validated DailyTasksEventCmd cmd) {
    dailyTasksService.completedTaskSetting(cmd);
  }


  /**
   * 已完成或者待领取任务列表.
   *
   * @eo.name 已完成或者待领取任务列表.
   * @eo.url /list-completed
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/list-completed")
  public List<DailyTaskStorageCO> listCompletedTask(AppExtCommand cmd) {
    return dailyTasksService.listCompletedTask(cmd);
  }

  /**
   * 领取任务奖励.
   *
   * @eo.name 领取任务奖励.
   * @eo.url /receive
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/receive")
  public void receiveTaskRewards(@RequestBody @Validated DailyTasksEventCmd cmd) {
    dailyTasksService.receiveTaskRewards(cmd);
  }


}
