package com.glxp.mipsdl.service.system;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.glxp.mipsdl.util.IntUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.mipsdl.dao.system.SysParamConfigMapper;
import com.glxp.mipsdl.entity.system.SysParamConfigEntity;

import javax.annotation.Resource;

@Service
public class SysParamConfigService extends ServiceImpl<SysParamConfigMapper, SysParamConfigEntity> {
    @Resource
    SysParamConfigMapper sysParamConfigMapper;

    public Boolean selectByKey(String key) {
        SysParamConfigEntity sysParamConfigEntity = sysParamConfigMapper.selectOne(new QueryWrapper<SysParamConfigEntity>().eq("paramKey", key).last("limit 1"));
        if (sysParamConfigEntity != null) {
            String value = sysParamConfigEntity.getParamValue();
            if (IntUtil.value(value) > 0) {
                return true;
            }
        }
        return false;
    }

}
