<?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.corewing.app.mapper.BizResourceMapper">


    <select id="page" resultType="com.corewing.app.entity.BizResource">
        select r.*, rc.category_name
        from biz_resource r
        left join biz_resource_category rc on rc.id = r.category_id
        <where>
            and r.delete_flag = 'NOT_DELETE'
            and r.status = 'ENABLE'
            <if test="resourcePageRequest.categoryId != null and resourcePageRequest.categoryId != ''">
                and r.category_id = #{resourcePageRequest.categoryId}
            </if>

            <if test="resourcePageRequest.searchKey != null and resourcePageRequest.searchKey != ''">
                and r.title like CONCAT('%', #{resourcePageRequest.searchKey}, '%')
            </if>

        </where>
        order by r.sort_code asc
    </select>
</mapper>