package com.sonic.lion.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.sonic.lion.dao.GoogleRecordDao;
import com.sonic.lion.domain.entity.GoogleRecord;
import com.sonic.lion.service.GoogleRecordService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

/**
 * @author: code
 * @date: 2025/06/24
 * @Description:
 * @version: 1.0.0
 */
@Service
public class GoogleRecordServiceImpl implements GoogleRecordService {

    @Autowired
    private GoogleRecordDao googleRecordDao;

    @Override
    public void save(@NonNull GoogleRecord googleRecord) {
        googleRecordDao.insert(googleRecord);
    }

    @Override
    public GoogleRecord getByTransactionId(String transactionId) {
        if (StringUtils.isBlank(transactionId)) {
            return null;
        }
        LambdaQueryWrapper<GoogleRecord> queryWrapper = Wrappers.<GoogleRecord>lambdaQuery()
                .eq(GoogleRecord::getTransactionId, transactionId);
        return googleRecordDao.selectOne(queryWrapper);
    }
}
