package com.ruoyi.ss.feeRule.service.impl;

import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.ss.feeRule.domain.FeeRuleVO;
import com.ruoyi.ss.feeRule.service.IFeeRuleAssembler;
import com.ruoyi.ss.room.service.IRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author qzz
 * 2025/1/20
 */
@Service
public class FeeRuleAssemblerImpl implements IFeeRuleAssembler {


    @Autowired
    private IRoomService roomService;

    /**
     * 拼接房间信息
     * @param list 店铺列表
     */
    @Override
    public void assembleRoomInfo(List<FeeRuleVO> list) {
        if (CollectionUtils.isEmptyElement(list)) {
            return;
        }
        list.forEach(vo -> {
            List<String> roomNames = roomService.selectIsExistRule(vo.getRuleId());
            if (roomNames != null && !roomNames.isEmpty()) {
                // 使用String.join将列表用逗号连接
                vo.setRoomNames(String.join(",", roomNames));
            }
        });

    }
}
