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.model.cmd.user.UserActivityRewardReceiveRecordCmd;
import com.red.circle.other.inner.model.cmd.user.UserActivityRewardReceiveRecordQryCmd;
import com.red.circle.other.inner.model.dto.user.UserActivityRewardReceiveRecordDTO;
import com.red.circle.other.app.inner.service.user.user.UserActivityClientService;
import com.red.circle.other.inner.endpoint.user.user.api.UserActivityClientApi;
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 pengliang on 2023/6/6
 */
@Validated
@RestController
@RequestMapping(value = UserActivityClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserActivityClientEndpoint implements UserActivityClientApi {

  private final UserActivityClientService userActivityClientService;

  @Override
  public ResultResponse<Boolean> existsThisMonth(Long userId, Long activityId) {
    return ResultResponse.success(userActivityClientService.existsThisMonth(userId, activityId));
  }

  @Override
  public ResultResponse<Map<Long, UserActivityRewardReceiveRecordDTO>> mapByThisMonth(Long userId) {
    return ResultResponse.success(userActivityClientService.mapByThisMonth(userId));
  }

  @Override
  public ResultResponse<Void> saveThisMonth(UserActivityRewardReceiveRecordCmd cmd) {
    userActivityClientService.saveThisMonth(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<UserActivityRewardReceiveRecordDTO>> pageUserActivityRewardReceiveRecord(
      UserActivityRewardReceiveRecordQryCmd query) {
    return ResultResponse.success(
        userActivityClientService.pageUserActivityRewardReceiveRecord(query));
  }
}
