package com.hai.dao;

import com.hai.entity.BsMsg;
import com.hai.entity.OutRechargePrice;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsMsgUserMapperExt {

    @Select({"<script>" +
            "select bs.* from bs_msg bs left join bs_msg_user bmu on bs.id = bmu.msg_id " +
            "where status = 2 " +
            "<if test='param.companyId != null'> and company_id = #{param.companyId} </if>",
            "<if test='param.userId != null'> and user_id = #{param.userId} </if>",
            "<if test='param.userId == null'> and user_id is null </if>",
            "<if test='param.type != null'> and type = #{param.type} </if>",
            "<if test='param.msgType != null'> and msg_type = #{param.msgType} </if>",
            "<if test='param.whereCheck != null'> and where_check = #{param.whereCheck} </if>",
            "order by create_time desc " +
            " </script>"})
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
            @Result(column="jump_type", property="jumpType", jdbcType=JdbcType.INTEGER),
            @Result(column="msg_type", property="msgType", jdbcType=JdbcType.INTEGER),
            @Result(column="object_id", property="objectId", jdbcType=JdbcType.BIGINT),
            @Result(column="image", property="image", jdbcType=JdbcType.VARCHAR),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="op_name", property="opName", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="op_id", property="opId", jdbcType=JdbcType.BIGINT),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
    })
    List<BsMsg> queryMsgByList(@Param("param") Map<String, Object> param);

}
