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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.endpoint.user.user.api.UserCustomGiftClientApi;
import com.red.circle.other.inner.model.cmd.user.UserCustomGiftQryCmd;
import com.red.circle.other.inner.model.dto.user.UserCustomGiftRecordDTO;
import com.red.circle.other.app.inner.service.user.user.UserCustomGiftClientService;
import java.util.Map;
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 2024/1/31
 */
@Validated
@RestController
@RequestMapping(value = UserCustomGiftClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserCustomGiftClientEndpoint implements UserCustomGiftClientApi {

  private final UserCustomGiftClientService userCustomGiftClientService;

  @Override
  public ResultResponse<PageResult<UserCustomGiftRecordDTO>> getCustomGift(
      UserCustomGiftQryCmd query) {
    return ResultResponse.success(userCustomGiftClientService.getCustomGift(query));
  }

  @Override
  public ResultResponse<Void> switchStatus(Long id, Boolean status) {
    userCustomGiftClientService.switchStatus(id, status);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<UserCustomGiftRecordDTO> userCustomGift(Long id) {
    return ResultResponse.success(userCustomGiftClientService.userCustomGift(id));
  }

  @Override
  public ResultResponse<Void> updateSelectiveById(UserCustomGiftRecordDTO cmd) {
    userCustomGiftClientService.updateSelectiveById(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> saveCustomGift(UserCustomGiftRecordDTO dto) {
    userCustomGiftClientService.saveCustomGift(dto);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Map<Integer, UserCustomGiftRecordDTO>> mapByAmount(Long userId) {
    return ResultResponse.success(userCustomGiftClientService.mapByAmount(userId));
  }
}
