package com.yaoai.domain.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yaoai.domain.entity.TenantSetting;
import org.apache.ibatis.annotations.Mapper;

import java.util.Optional;

@Mapper
public interface TenantSettingMapper extends BaseMapper<TenantSetting> {

    default Optional<TenantSetting> findByKey(Long tenantId, String key) {
        return Optional.ofNullable(selectOne(Wrappers.<TenantSetting>lambdaQuery()
                .eq(TenantSetting::getTenantId, tenantId)
                .eq(TenantSetting::getSettingKey, key)));
    }
}
