package com.red.circle.other.app.inner.endpoint.activity;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.activity.AgentActivityCountClientService;
import com.red.circle.other.inner.endpoint.activity.api.AgentActivityCountClientApi;
import com.red.circle.other.inner.enums.activity.AgentActivityCountType;
import com.red.circle.other.inner.model.dto.activity.AgentActivityCountDTO;
import java.util.Collection;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 代理活动统计.
 *
 * @author zongpubin on 2023/8/15
 */
@Validated
@RestController
@RequestMapping(value = AgentActivityCountClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class AgentActivityCountClientEndpoint implements AgentActivityCountClientApi {

  private final AgentActivityCountClientService agentActivityCountClientService;

  @Override
  public ResultResponse<Void> reduceTarget(Collection<Long> teamIds, Long target) {
    agentActivityCountClientService.reduceTarget(teamIds, target);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> initZero(Long acceptUserId, Long teamId) {
    agentActivityCountClientService.initZero(acceptUserId, teamId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<AgentActivityCountDTO>> pageData(
      AgentActivityCountType countType, String regionId, Integer current, Integer limitSize) {
    return ResultResponse.success(
        agentActivityCountClientService.pageData(countType, regionId, current, limitSize)
    );
  }

  @Override
  public ResultResponse<Void> initZeroTeam(Long teamId) {
    agentActivityCountClientService.initZeroTeam(teamId);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<Void> initZeroMember(Set<Long> acceptUserIds) {
    agentActivityCountClientService.initZeroMember(acceptUserIds);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<Void> removeByTeamIds(Collection<Long> teamIds) {
    agentActivityCountClientService.removeByTeamIds(teamIds);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<Void> incrTarget(Long teamId, Long target, String regionId) {
    agentActivityCountClientService.incrTarget(teamId, target, regionId);
    return ResultResponse.success();
  }
}
