<?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.pcloud.book.adnews.dao.impl.AdNewsBanDaoImpl">
    <resultMap id="BaseResultMap" type="com.pcloud.book.adnews.entity.AdNewsBan">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
        <result column="ad_news_id" property="adNewsId" jdbcType="BIGINT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, adviser_id, ad_news_id, create_time, update_time
    </sql>

    <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from ad_news_choose
        where id = #{id,jdbcType=BIGINT}
    </select>

    <insert id="insert" parameterType="com.pcloud.book.adnews.entity.AdNewsBan" useGeneratedKeys="true" keyProperty="id">
        insert into ad_news_ban
            (adviser_id,
            ad_news_id,
            create_time)
        values(
            #{adviserId,jdbcType=BIGINT},
            #{adNewsId,jdbcType=BIGINT},
            NOW())
    </insert>

    <!--根据id删除-->
    <delete id="deleteByAdNewsId" parameterType="map">
        DELETE FROM ad_news_ban
        where ad_news_id=#{adNewsId} and adviser_id=#{partyId}
    </delete>

</mapper>
