package com.red.circle.other.infra.common.props;

import com.red.circle.other.infra.convertor.game.GiftInfraConvertor;
import com.red.circle.other.infra.convertor.material.BadgeInfraConvertor;
import com.red.circle.other.infra.convertor.material.PropsResourcesInfraConvertor;
import com.red.circle.other.infra.database.rds.service.badge.BadgePictureConfigService;
import com.red.circle.other.infra.database.rds.service.emoji.EmojiGroupService;
import com.red.circle.other.infra.database.rds.service.gift.GiftConfigService;
import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService;
import com.red.circle.other.inner.model.cmd.material.PropsResourcesMergeCmd;
import com.red.circle.other.inner.model.dto.material.PropsResourcesMergeDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author pengliang on 2023/12/15
 */
@Component
@RequiredArgsConstructor
public class PropsResourcesCommon {

  private final GiftConfigService giftConfigService;
  private final EmojiGroupService emojiGroupService;
  private final GiftInfraConvertor giftInfraConvertor;
  private final BadgeInfraConvertor badgeInfraConvertor;
  private final PropsSourceRecordService propsSourceRecordService;
  private final BadgePictureConfigService badgePictureConfigService;
  private final PropsResourcesInfraConvertor propsResourcesInfraConvertor;

  public PropsResourcesMergeDTO mapMergeByIds(PropsResourcesMergeCmd cmd) {
    return new PropsResourcesMergeDTO()
        .setProps(propsResourcesInfraConvertor.toMapPropsResourcesDTO(
            propsSourceRecordService.mapByIds(cmd.getPropsIds())))
        .setGift(
            giftInfraConvertor.toMapGiftConfigDTO(giftConfigService.mapByIds(cmd.getGiftIds())))
        .setBadge(badgeInfraConvertor.toMapBadgePictureConfigDTO(badgePictureConfigService
            .mapBadge(cmd.getSysOrigin(), cmd.getBadgeIds())))
        .setEmoji(propsResourcesInfraConvertor.toMapEmojiGroupDTO(
            emojiGroupService.mapByIds(cmd.getEmojiIds())));
  }
}
