package com.red.circle.other.app.inner.service.material.props.impl;

import com.red.circle.other.app.inner.convertor.material.BadgeInnerConvertor;
import com.red.circle.other.app.inner.service.material.props.BadgeSourceClientService;
import com.red.circle.other.infra.database.rds.service.badge.BadgeConfigService;
import com.red.circle.other.infra.database.rds.service.badge.BadgePictureConfigService;
import com.red.circle.other.inner.model.cmd.material.BadgePictureMapQry;
import com.red.circle.other.inner.model.dto.material.BadgeConfigDTO;
import com.red.circle.other.inner.model.dto.material.BadgePictureConfigDTO;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 徽章资源服务.
 *
 * @author pengliang on 2023/6/6
 */
@Service
@RequiredArgsConstructor
public class BadgeSourceClientServiceImpl implements BadgeSourceClientService {

  private final BadgeConfigService badgeConfigService;
  private final BadgeInnerConvertor badgeInnerConvertor;
  private final BadgePictureConfigService badgePictureConfigService;

  @Override
  public BadgePictureConfigDTO getByBadgeId(String sysOrigin, Long badgeId) {
    return badgeInnerConvertor.toBadgePictureConfigDTO(
        badgePictureConfigService.getByBadgeId(sysOrigin, badgeId));
  }

  @Override
  public Map<Long, BadgeConfigDTO> mapConfigByIds(Set<Long> ids) {
    return badgeInnerConvertor.tpMapBadgeConfigDTO(badgeConfigService.mapByIds(ids));
  }

  @Override
  public Map<Long, BadgePictureConfigDTO> mapPictureByIds(BadgePictureMapQry qry) {
    return badgeInnerConvertor.toMapBadgePictureConfigDTO(
        badgePictureConfigService.mapBadge(qry.getSysOrigin(), qry.getBadgeIds()));
  }

  @Override
  public Long getFreightBadgeId() {
    return badgeConfigService.getFreightBadgeId();
  }

}
