package com.red.circle.other.app.inner.endpoint.team.bd;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.team.BdTeamInfoClientService;
import com.red.circle.other.inner.endpoint.team.bd.api.BdTeamInfoClientApi;
import com.red.circle.other.inner.model.cmd.team.BdTeamInfoCmd;
import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd;
import com.red.circle.other.inner.model.cmd.team.bd.BdTeamUpdateOpsCmd;
import com.red.circle.other.inner.model.cmd.team.bd.BdTeamWorkStatisticsQryCmd;
import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO;
import java.util.List;
import java.util.Map;
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;

/**
 * bd 团队.
 *
 * @author pengliang on 2023/5/26
 */
@Validated
@RestController
@RequestMapping(value = BdTeamInfoClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class BdTeamInfoClientEndpoint implements BdTeamInfoClientApi {

  private final BdTeamInfoClientService bdTeamInfoClientService;

  @Override
  public ResultResponse<Boolean> check(Long userId) {
    return ResultResponse.success(bdTeamInfoClientService.check(userId));
  }

  @Override
  public ResultResponse<BdTeamInfoDTO> getByUserId(Long userId) {
    return ResultResponse.success(bdTeamInfoClientService.getByUserId(userId));
  }

  @Override
  public ResultResponse<BdTeamInfoDTO> getById(Long id) {
    return ResultResponse.success(bdTeamInfoClientService.getById(id));
  }

  @Override
  public ResultResponse<Void> add(BdTeamInfoCmd cmd) {
    bdTeamInfoClientService.addBdInfo(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> incrMemberCount(Set<Long> userIds) {
    bdTeamInfoClientService.incrMemberCount(userIds);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Map<Long, Boolean>> mapCheckBd(Set<Long> userIds) {
    return ResultResponse.success(bdTeamInfoClientService.mapCheckBd(userIds));
  }

  @Override
  public ResultResponse<Void> updateSelectiveById(BdTeamInfoDTO dto) {
    bdTeamInfoClientService.updateSelectiveById(dto);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> updateOpsById(BdTeamUpdateOpsCmd cmd) {
    bdTeamInfoClientService.updateOpsById(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> decrMemberCount(Set<Long> userIds) {
    bdTeamInfoClientService.decrMemberCount(userIds);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<BdTeamInfoDTO>> pageOps(BdTeamPageQryCmd qryCmd) {
    return ResultResponse.success(bdTeamInfoClientService.pageOps(qryCmd));
  }

  @Override
  public ResultResponse<List<BdTeamInfoDTO>> pageWorkStatistics(
      BdTeamWorkStatisticsQryCmd qryCmd) {
    return ResultResponse.success(bdTeamInfoClientService.pageWorkStatistics(qryCmd));
  }

  @Override
  public ResultResponse<Void> deleteById(Long id) {
    bdTeamInfoClientService.deleteById(id);
    return ResultResponse.success();
  }

}
