package org.springblade.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.system.entity.VisualSubscribeNotifyConf;
import org.springblade.modules.system.enums.NotifyType;
import org.springblade.modules.system.mapper.VisualSubscribeNotifyConfMapper;
import org.springblade.modules.system.service.VisualSubscribeNotifyConfService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VisualSubscribeNotifyConfServiceImpl extends ServiceImpl<VisualSubscribeNotifyConfMapper, VisualSubscribeNotifyConf> implements VisualSubscribeNotifyConfService {

    @Override
    @Cacheable(cacheNames = "subNotifyConf", key = "#notifyType.name", unless = "#result != null")
    public List<VisualSubscribeNotifyConf> notifyConfList(NotifyType notifyType){
        LambdaQueryWrapper<VisualSubscribeNotifyConf> queryWrapper = Wrappers.<VisualSubscribeNotifyConf>lambdaQuery()
                .eq(VisualSubscribeNotifyConf::getNotifyType, notifyType);
        return list(queryWrapper);
    }

    @Override
    @CacheEvict(cacheNames = "subNotifyConf", key = "#notifyType.name")
    public boolean evict(NotifyType notifyType) {
        return true;
    }

    @Override
    public List<VisualSubscribeNotifyConf> getList(int classify) {
        return baseMapper.getList(classify);
    }
}
