package com.yida.data.school.news.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.school.EduSchoolMatterGroup;
import com.yida.data.common.core.entity.school.EduSchoolMatterMatterGroup;
import com.yida.data.school.news.mapper.EduSchoolMatterGroupMapper;
import com.yida.data.school.news.mapper.EduSchoolMatterMatterGroupMapper;
import com.yida.data.school.news.service.EduSchoolMatterGroupService;
import com.yida.data.school.vo.index.MatterGroupInfoVO;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import lombok.RequiredArgsConstructor;

/**
 * Service实现
 *
 * @author zhanghaijun
 * @date 2021-07-19 17:21:58
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class EduSchoolMatterGroupServiceImpl extends ServiceImpl
        <EduSchoolMatterGroupMapper, EduSchoolMatterGroup> implements EduSchoolMatterGroupService {

    private final EduSchoolMatterGroupMapper eduSchoolMatterGroupMapper;
    private final EduSchoolMatterMatterGroupMapper eduSchoolMatterMatterGroupMapper;

    @Override
    public List<MatterGroupInfoVO> listMatterGroup(Long schoolId, Integer type) {
        return baseMapper.listMatterGroup(schoolId, type);
    }

    @Override
    public void delGroupBatch(List<Long> ids) {
        removeByIds(ids);
        eduSchoolMatterMatterGroupMapper.delete(Wrappers.lambdaQuery(new EduSchoolMatterMatterGroup())
                .in(EduSchoolMatterMatterGroup::getMatterGroupId, ids));
    }
}
