package tech.easyflow.system.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import tech.easyflow.system.entity.SysOption;
import tech.easyflow.system.mapper.SysOptionMapper;
import tech.easyflow.system.service.SysOptionService;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.math.BigInteger;

/**
 * 系统配置信息表。 服务层实现。
 *
 * @author michael
 * @since 2024-03-13
 */
@Service
public class SysOptionServiceImpl extends ServiceImpl<SysOptionMapper, SysOption> implements SysOptionService {

    @Override
    public SysOption getByOptionKey(String key, BigInteger tenantId) {
        QueryWrapper w = QueryWrapper.create();
        w.eq(SysOption::getKey, key);
        if (tenantId != null) {
            w.eq(SysOption::getTenantId, tenantId);
        }
        return getOne(w);
    }
}
