package com.ningdatech.carapi.sys.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.carapi.sys.entity.CompanyJoin;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 企业
 * </p>
 *
 * @author PoffyZhang
 */
@Repository
public interface CompanyJoinMapper extends BaseMapper<CompanyJoin> {
    String QUERY_SQL = "SELECT c.*, o.name as operator_name FROM nd_company_info AS c " +
            "LEFT JOIN nd_operator_info AS o ON c.operator_id = o.id ";
    String WRAPPER_SQL = "SELECT * from ( " + QUERY_SQL + " ) AS q ${ew.customSqlSegment}";

    @Select(WRAPPER_SQL)
    Page<CompanyJoin> pageJoin(Page page, @Param("ew") LambdaQueryWrapper<CompanyJoin> wrapper);

    @Select(WRAPPER_SQL)
    List<CompanyJoin> listJoin(@Param("ew") LambdaQueryWrapper<CompanyJoin> wrapper);

    @Select(WRAPPER_SQL)
    CompanyJoin oneJoin(@Param("ew") LambdaQueryWrapper<CompanyJoin> wrapper);
}
