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

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.sys.ActivityIndexCO;
import com.red.circle.other.app.dto.clientobject.sys.SysActivityCountRankCO;
import com.red.circle.other.app.dto.clientobject.sys.SysActivityUserCountCO;
import com.red.circle.other.app.dto.cmd.sys.SysActivityRankQryCmd;
import com.red.circle.other.app.service.sys.SysActivityService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统活动.
 *
 * @author pengliang on 2022/8/16
 * @eo.api-type http
 * @eo.groupName 系统服务.系统活动
 * @eo.path /sys/activity
 */
@Slf4j
@RestController
@RequestMapping(value = "/sys/activity", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class ActivityRestController extends BaseController {

  private final SysActivityService sysActivityService;

  /**
   * 系统活动配置.
   *
   * @eo.name 系统活动配置.
   * @eo.url
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping
  public ActivityIndexCO getActivityConfig(AppIdLongCmd cmd) {
    return sysActivityService.getActivityConfig(cmd);
  }

  /**
   * 排行榜.
   *
   * @eo.name 排行榜.
   * @eo.url /rank
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/rank")
  public List<SysActivityCountRankCO> listRank(SysActivityRankQryCmd cmd) {
    return sysActivityService.listRank(cmd);
  }

  /**
   * 我的贡献.
   *
   * @eo.name 我的贡献.
   * @eo.url /user-count
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/user-count")
  public SysActivityUserCountCO getUserCount(AppIdLongCmd cmd) {
    return sysActivityService.getUserCount(cmd);
  }

}
