<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.quinn.mapper.SourceMapper">

    <select id="listPageStar" resultType="com.quinn.pojo.SourceWithStar">
        select id,sid,source_name,detail,source_type,category_id,category_name,en_name,file_type,down_record,gmt_create,gmt_update,
        (select count(1) from qn_star c where c.topic_id = sid and c.topic_category = 'SOURCE') as star
        from qn_source
        <where>
            <if test="querySource.name!=null and querySource.name != ''">
                and source_name like CONCAT('%',#{querySource.name},'%')
            </if>
            <if test="querySource.category > 0">
                and category_id = #{querySource.category}
            </if>
        </where>
        order by gmt_create desc
        limit #{myPageParam.pageNum},#{myPageParam.size}
    </select>

</mapper>
