package com.yingpaipay.setting.service.impl;

import com.yingpaipay.setting.domain.AiSetting;
import com.yingpaipay.setting.mapper.AiSettingMapper;
import com.yingpaipay.setting.service.IAiSettingService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.constant.CacheNames;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Slf4j
@RequiredArgsConstructor
@Service
public class AiSettingServiceImpl implements IAiSettingService {

    private final AiSettingMapper baseMapper;

    @Cacheable(cacheNames = CacheNames.SETTING, key = "'ai'")
    @Override
    public AiSetting query() {
        return baseMapper.selectById(1L);
    }

    @CachePut(cacheNames = CacheNames.SETTING, key = "'ai'")
    @Override
    public boolean edit(AiSetting request) {
        return baseMapper.updateById(request) > 0;
    }

}
