package com.trade.service.enterprise.customer.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trade.service.enterprise.customer.mapper.EnterpriseChangeRecordMapper;
import com.trade.service.enterprise.customer.domain.EnterpriseChangeRecord;
import com.trade.service.enterprise.customer.service.EnterpriseChangeRecordBaseService;
import org.springframework.stereotype.Service;

/**
 * 企业信息变更记录基础服务实现类
 *
 * @author hlb
 * @since 2024-05-29 15:07:42
 */
@Service("enterpriseChangeRecordBaseService")
public class EnterpriseChangeRecordBaseServiceImpl extends ServiceImpl<EnterpriseChangeRecordMapper, EnterpriseChangeRecord> implements EnterpriseChangeRecordBaseService {

    @Override
    public EnterpriseChangeRecord getLatestRecord(Long customerId, String certificationStatus) {
        return this.lambdaQuery()
                .eq(EnterpriseChangeRecord::getCustomerId, customerId)
                .eq(StrUtil.isNotEmpty(certificationStatus), EnterpriseChangeRecord::getCertificationStatus, certificationStatus)
                .orderByDesc(EnterpriseChangeRecord::getGmtModified).last("limit 1").one();
    }
}

