package com.jd.lightapplication.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jd.lightapplication.model.QrcodeShowConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface QrcodeShowConfigMapper extends BaseMapper<QrcodeShowConfig>  {

    @Select("<script>" +
            "SELECT *,ur.source_name as sourceName,ur.file_path as filePath FROM qrcode_show_config qsc" +
            " INNER JOIN upload_record ur" +
            " ON qsc.upload_record_id = ur.id" +
            " WHERE 1=1" +
            "<if test=\"@org.apache.commons.lang3.StringUtils@isNotBlank(title)\">" +
            " and qsc.title LIKE CONCAT('%',#{title},'%')" +
            "</if>" +
            " ORDER BY qsc.create_time DESC" +
            "</script>")
    IPage<QrcodeShowConfig> page(@Param("page") Page page, @Param("title") String title);

    @Select("SELECT *,ur.source_name as sourceName,ur.file_path as filePath FROM qrcode_show_config qsc" +
            " INNER JOIN upload_record ur" +
            " ON qsc.upload_record_id = ur.id" +
            " WHERE qsc.status = 10" +
            " ORDER BY qsc.create_time DESC")
    List<QrcodeShowConfig> queryAll();
}
