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

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trade.service.enterprise.dto.EnterpriseBaseInfoDto;
import com.trade.service.enterprise.dto.EnterpriseSearchDto;
import com.trade.service.enterprise.mapper.EnterpriseMapper;
import com.trade.service.enterprise.domain.Enterprise;
import com.trade.service.enterprise.service.EnterpriseBaseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * 企业信息基础服务实现类
 *
 * @author hlb
 * @since 2024-05-29 15:07:42
 */
@Service("enterpriseBaseService")
public class EnterpriseBaseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterprise> implements EnterpriseBaseService {

    @Resource
    private EnterpriseMapper enterpriseMapper;

    @Override
    public Enterprise getEnterpriseByCustomerId(Long customerId) {
        return this.lambdaQuery().eq(Enterprise::getCustomerId, customerId).orderByDesc(Enterprise::getGmtCreate)
                .last("LIMIT 1").one();
    }

    @Override
    public List<EnterpriseBaseInfoDto> findBySearch(EnterpriseSearchDto search) {
        return enterpriseMapper.findBySearch(search);
    }

    @Override
    public List<EnterpriseBaseInfoDto> findByCustomerInfo(String customerInfo) {
        return enterpriseMapper.findByCustomerInfo(customerInfo);
    }
}
