package com.qmth.themis.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.themis.business.constant.SystemConstant;
import com.qmth.themis.business.dao.TEConfigMapper;
import com.qmth.themis.business.entity.TEConfig;
import com.qmth.themis.business.service.TEConfigService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * @Description: 全局配置 服务实现类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/9
 */
@Service
public class TEConfigServiceImpl extends ServiceImpl<TEConfigMapper, TEConfig> implements TEConfigService {

    /**
     * 获取全局考试配置
     *
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.configCache, key = "methodName", unless = "#result == null")
    public TEConfig getGlobalConfig() {
        List<TEConfig> teConfigList = this.list();
        return Objects.isNull(teConfigList) || teConfigList.size() == 0 ? null : teConfigList.get(0);
    }
}
