package com.red.circle.console.app.service.app.user;

import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.other.inner.endpoint.material.props.BadgeBackpackClient;
import com.red.circle.other.inner.model.dto.material.BadgePictureConfigDTO;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户徽章背包 服务.
 *
 * @author pengshigang on 2023/5/12
 */
@Service
@RequiredArgsConstructor
public class UserBadgeBackpackBackServiceImpl implements UserBadgeBackpackBackService {

  private final UserProfileClient userProfileClient;
  private final BadgeBackpackClient badgeBackpackClient;

  @Override
  public List<BadgePictureConfigDTO> pageUserNotAchieveBadge(Long userId) {

    UserProfileDTO userProfile = ResponseAssert.requiredSuccess(
        userProfileClient.getByUserId(userId));
    ResponseAssert.notNull(CommonErrorCode.DATA_ERROR, userProfile);

    return ResponseAssert.requiredSuccess(
        badgeBackpackClient.listBadge(userId, userProfile.getOriginSys()));
  }
}
