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

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.UserCheckSubscriptionCmd;
import com.red.circle.other.inner.model.dto.user.UserSubscriptionDTO;
import com.red.circle.other.inner.model.dto.user.WeekFriendshipCardCountDTO;
import com.red.circle.other.app.inner.service.user.user.UserSubscriptionClientService;
import com.red.circle.other.inner.endpoint.user.user.api.UserSubscriptionClientApi;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.tuple.ImmutableTriple;
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/5
 */
@Validated
@RestController
@RequestMapping(value = UserSubscriptionClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserSubscriptionClientEndpoint implements UserSubscriptionClientApi {

  private final UserSubscriptionClientService userSubscriptionClientService;

  @Override
  public ResultResponse<Boolean> checkSubscription(Long userId, Long createUserId) {
    return ResultResponse.success(
        userSubscriptionClientService.checkSubscription(userId, createUserId));

  }

  @Override
  public ResultResponse<Map<Long, Boolean>> mapIsSubscription(UserCheckSubscriptionCmd cmd) {
    return ResultResponse.success(userSubscriptionClientService.mapIsSubscription(cmd.getUserId(),
        cmd.getSubscriptionUserIds()));
  }

  @Override
  public ResultResponse<UserSubscriptionDTO> getBySubscription(Long userId,
      Long subscriptionUserId) {
    return ResultResponse.success(
        userSubscriptionClientService.getBySubscription(userId, subscriptionUserId));
  }

  @Override
  public ResultResponse<Boolean> notExistsAdd(Long userId, Long subscriptionUserId) {
    return ResultResponse.success(
        userSubscriptionClientService.notExistsAdd(userId, subscriptionUserId));
  }


  @Override
  public ResultResponse<List<WeekFriendshipCardCountDTO>> listThisWeekTop(String sysOrigin,
      Integer size) {
    return ResultResponse.success(userSubscriptionClientService.listThisWeekTop(sysOrigin, size));
  }

  @Override
  public ResultResponse<ImmutableTriple<Long, Long, String>> parseUserIdPair(String id) {
    return ResultResponse.success(userSubscriptionClientService.parseUserIdPair(id));
  }
}
