<?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.upyuns.platform.rs.website.mapper.NewsInfoMapper">

    <select id="selectList" resultType="com.upyuns.platform.rs.website.entity.NewsInfo">
        select ni.*, nt.name_cn as typeName from news_info ni
        left join news_type nt on nt.id = ni.type_id
        <where>
            <if test="typeId != null">
                and ni.type_id = #{typeId}
            </if>
            <if test="status != null">
                and ni.status = #{status}
            </if>
            and ni.is_del = 0
        </where>
        <if test="sortType == 1">
            order by ni.rank
        </if>
        <if test="sortType == 2">
            order by ni.rank DESC
        </if>
        <if test="sortType == 3">
            order by ni.upd_time DESC
        </if>
    </select>

</mapper>