<?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.sckw.message.dao.KwmMessageMapper">

  <select id="findPage" resultType="com.sckw.message.model.KwmMessage" >
    select
      m.id, m.category, m.type, m.title, m.content, m.url, m.params, m.client_type clientType, m.remark,
      mu.status, m.create_by createBy, m.create_time createTime, m.update_by updateBy, m.update_time updateTime
    from kwm_message m
    left join kwm_message_user mu
    on m.id = mu.msg_id
    <where>
        m.del_flag = 0 and mu.del_flag = 0 and mu.user_id = #{item.userId}
        <if test="item.category != null and item.category != ''">
          and m.category = #{item.category}
        </if>
        <if test="item.type != null and item.type != ''">
          and m.type = #{item.type}
        </if>
    </where>
    ORDER BY m.status, m.create_time desc
  </select>
</mapper>