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.BdTeamMemberClientService;
import com.red.circle.other.inner.endpoint.team.bd.api.BdTeamMemberClientApi;
import com.red.circle.other.inner.model.cmd.team.bd.BdTeamMemberOpsPageQryCmd;
import com.red.circle.other.inner.model.dto.agency.bd.BdTeamMemberDTO;
import java.util.List;
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/11/21
 */
@Validated
@RestController
@RequestMapping(value = BdTeamMemberClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class BdTeamMemberClientEndpoint implements BdTeamMemberClientApi {

  private final BdTeamMemberClientService bdTeamMemberClientService;

  @Override
  public ResultResponse<PageResult<BdTeamMemberDTO>> pageOps(BdTeamMemberOpsPageQryCmd qryCmd) {
    return ResultResponse.success(bdTeamMemberClientService.pageOps(qryCmd));
  }

  @Override
  public ResultResponse<Boolean> exist(Long agentUserId) {
    return ResultResponse.success(bdTeamMemberClientService.exist(agentUserId));
  }

  @Override
  public ResultResponse<Void> add(String sysOrigin, Long agentUserId, Long bdUserId, Long teamId,
      Long updateUserId) {
    bdTeamMemberClientService.add(sysOrigin, agentUserId, bdUserId, teamId, updateUserId);
    return ResultResponse.success();
  }

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

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

  @Override
  public ResultResponse<List<BdTeamMemberDTO>> listByUserId(Long userId) {
    return ResultResponse.success(
        bdTeamMemberClientService.listByUserId(userId)
    );
  }

  @Override
  public ResultResponse<Void> deleteAllByUserId(Long userId) {
    bdTeamMemberClientService.deleteAllByUserId(userId);
    return ResultResponse.success();
  }

}
