package com.ylx.point.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ylx.point.domain.PointSignReward;
import com.ylx.point.mapper.PointSignRewardMapper;
import com.ylx.point.service.IPointSignRewardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 签到动态奖励配置Service业务层处理
 *
 * @author wzj
 * @date 2026-03-25
 */
@Service
public class PointSignRewardServiceImpl extends ServiceImpl<PointSignRewardMapper, PointSignReward> implements IPointSignRewardService {
    @Autowired
    private PointSignRewardMapper pointSignRewardMapper;

    /**
     * 查询签到动态奖励配置列表
     *
     * @param pointSignReward 签到动态奖励配置
     * @return 签到动态奖励配置
     */
    @Override
    public List<PointSignReward> selectPointSignRewardList(PointSignReward pointSignReward) {
        return pointSignRewardMapper.selectPointSignRewardList(pointSignReward);
    }

    /**
     * 批量删除签到动态奖励配置
     *
     * @param ids 需要删除的签到动态奖励配置主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deletePointSignRewardByIds(String[] ids) {
        return pointSignRewardMapper.deletePointSignRewardByIds(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void batchInsertPointSignReward(List<PointSignReward> rewards) {
        if (CollectionUtil.isEmpty(rewards)) {
            return;
        }

        // 批量插入
        pointSignRewardMapper.batchInsertPointSignReward(rewards);
    }
}
