package com.red.circle.other.app.inner.endpoint.material.gift;

import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.material.gift.GiftConfigClientService;
import com.red.circle.other.inner.endpoint.material.gift.api.GiftConfigClientApi;
import com.red.circle.other.inner.model.cmd.sys.GiftQryCmd;
import com.red.circle.other.inner.model.dto.gift.UserGiftWallDTO;
import com.red.circle.other.inner.model.dto.material.GiftConfigDTO;
import java.sql.Timestamp;
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;

/**
 * 礼物 服务.
 *
 * @author pengliang on 2023/5/23
 */
@Validated
@RestController
@RequestMapping(value = GiftConfigClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class GiftConfigClientEndpoint implements GiftConfigClientApi {

  private final GiftConfigClientService giftConfigClientService;

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

  @Override
  public ResultResponse<Map<Long, GiftConfigDTO>> mapByIds(Set<Long> ids) {
    return ResultResponse.success(giftConfigClientService.mapByIds(ids));
  }

  @Override
  public ResultResponse<List<GiftConfigDTO>> listByIds(Set<Long> ids) {
    return ResultResponse.success(giftConfigClientService.listByIds(ids));
  }

  @Override
  public ResultResponse<GiftConfigDTO> getPairCpGive(SysOriginPlatformEnum sysOrigin) {
    return ResultResponse.success(giftConfigClientService.getPairCpGive(sysOrigin));
  }

  @Override
  public ResultResponse<List<GiftConfigDTO>> listBySysOrigin(String sysOrigin) {
    return ResultResponse.success(giftConfigClientService.listBySysOrigin(sysOrigin));
  }

  @Override
  public ResultResponse<PageResult<GiftConfigDTO>> pageGiftInfo(GiftQryCmd giftQryCmd) {
    return ResultResponse.success(giftConfigClientService.pageGiftInfo(giftQryCmd));
  }

  @Override
  public ResultResponse<Boolean> updateGift(GiftConfigDTO giftConfigDTO) {
    return ResultResponse.success(giftConfigClientService.updateGift(giftConfigDTO));
  }

  @Override
  public ResultResponse<Void> removeGiftCache() {
    giftConfigClientService.removeGiftCache();
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> removeRemainingInventory(Long id, Long standardId) {
    giftConfigClientService.removeRemainingInventory(id, standardId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Boolean> saveGift(GiftConfigDTO giftConfig) {
    return ResultResponse.success(giftConfigClientService.saveGift(giftConfig));
  }

  @Override
  public ResultResponse<Boolean> switchDelStatus(Long id, Boolean status) {
    return ResultResponse.success(giftConfigClientService.switchDelStatus(id, status));
  }

  @Override
  public ResultResponse<Boolean> addAllGiftRegion(String sysOrigin, String regionId) {
    return ResultResponse.success(giftConfigClientService.addAllGiftRegion(sysOrigin, regionId));
  }

  @Override
  public ResultResponse<List<GiftConfigDTO>> listByTab(String sysOrigin, String giftTab) {
    return ResultResponse.success(giftConfigClientService.listByTab(sysOrigin, giftTab));
  }

  @Override
  public ResultResponse<List<GiftConfigDTO>> listByTabV2(GiftQryCmd giftQryCmd) {
    return ResultResponse.success(giftConfigClientService.listByTabV2(giftQryCmd));
  }

  @Override
  public ResultResponse<String> getPairCpGiveGiftId(String sysOrigin) {
    return ResultResponse.success(giftConfigClientService.getPairCpGiveGiftId(sysOrigin));
  }

  @Override
  public ResultResponse<Void> pushPairCpGiveGiftId(String sysOrigin, Long giftId) {
    giftConfigClientService.pushPairCpGiveGiftId(sysOrigin, giftId);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<List<UserGiftWallDTO>> listGiftWallByUser(Long userId) {
    return ResultResponse.success(giftConfigClientService.listGiftWallByUser(userId));
  }

  @Override
  public ResultResponse<List<GiftConfigDTO>> listByExpiredTime(Timestamp now) {
    return ResultResponse.success(giftConfigClientService.listByExpiredTime(now));
  }

}
