package com.gic.haoban.manage.service.service.chat.impl;

import com.gic.haoban.manage.api.dto.chat.GroupChatActivityInviteLogDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatActivityRewardDetailLogDTO;
import com.gic.haoban.manage.api.qdto.chat.GroupChatActivityRewardDetailLogQDTO;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatActivityRewardDetailLogMapper;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityInviteLog;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityRewardDetailLog;
import com.gic.haoban.manage.service.service.chat.GroupChatActivityRewardDetailLogService;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 社群活动完成奖励明细表(TabHaobanGroupChatActivityRewardDetailLog)表服务实现类
 *
 * @author makejava
 * @since 2024-09-27 16:09:57
 */
@Service("groupChatActivityRewardDetailLogService")
public class GroupChatActivityRewardDetailLogServiceImpl implements GroupChatActivityRewardDetailLogService {
    @Resource
    private GroupChatActivityRewardDetailLogMapper groupChatActivityRewardDetailLogMapper;

    private GroupChatActivityRewardDetailLogDTO convertToDTO(TabGroupChatActivityRewardDetailLog tabGroupChatActivityRewardDetailLog){
        GroupChatActivityRewardDetailLogDTO groupChatActivityRewardDetailLogDTO = new GroupChatActivityRewardDetailLogDTO();
        BeanUtils.copyProperties(tabGroupChatActivityRewardDetailLog,groupChatActivityRewardDetailLogDTO);
        return groupChatActivityRewardDetailLogDTO;
    }

    @Override
    public List<GroupChatActivityRewardDetailLogDTO> queryList(GroupChatActivityRewardDetailLogQDTO rewardDetailLogQDTO) {
        List<TabGroupChatActivityRewardDetailLog> rewardDetailLogDTOList = groupChatActivityRewardDetailLogMapper.queryList(rewardDetailLogQDTO);
        if(CollectionUtils.isEmpty(rewardDetailLogDTOList)){
            return Lists.newArrayList();
        }
        return rewardDetailLogDTOList.stream().map(this::convertToDTO).collect(Collectors.toList());
    }
}
