package com.fjhx.service.logistics.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.entity.logistics.LogisticsCompany;
import com.fjhx.mapper.logistics.LogisticsCompanyMapper;
import com.fjhx.params.logistics.LogisticsCompanyVo;
import com.fjhx.service.logistics.LogisticsCompanyService;
import org.springblade.core.tenant.annotation.TenantIgnore;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 物流公司 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-12-07
 */
@Service
public class LogisticsCompanyServiceImpl extends ServiceImpl<LogisticsCompanyMapper, LogisticsCompany> implements LogisticsCompanyService {

    @TenantIgnore
    @Override
    public List<LogisticsCompany> select(LogisticsCompanyVo logisticsCompanyVo) {
        return lambdaQuery()
                .and(Func.isNotEmpty(logisticsCompanyVo.getKeyword()), o -> o.apply("instr(`code`, '" + logisticsCompanyVo.getKeyword() + "') > 0").or().apply("instr(`name`, '" + logisticsCompanyVo.getKeyword() + "') > 0"))
                .orderByAsc(LogisticsCompany::getSort)
                .list();
    }

}
