<?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.vote.system.mapper.VoteEventNewsMapper">

    <resultMap id="BaseResultMap" type="com.vote.system.domain.VoteEventNews">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="eventId" column="event_id" jdbcType="BIGINT"/>
        <result property="type" column="type" jdbcType="OTHER"/>
        <result property="newsNumber" column="news_number" jdbcType="VARCHAR"/>
        <result property="title" column="title" jdbcType="VARCHAR"/>
        <result property="content" column="content" jdbcType="VARCHAR"/>
        <result property="coverImage" column="cover_image" jdbcType="VARCHAR"/>
        <result property="attachments" column="attachments" jdbcType="VARCHAR"/>
        <result property="likeNum" column="like_num" jdbcType="INTEGER"/>
        <result property="readNum" column="read_num" jdbcType="INTEGER"/>
        <result property="isTop" column="is_top" jdbcType="CHAR"/>
        <result property="status" column="status" jdbcType="CHAR"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,event_id,type,
        news_number,title,content,
        cover_image,attachments,is_top,
        status,created_at,updated_at
    </sql>

    <update id="updateNewsReadCount">
        UPDATE vote_event_news
        SET read_num = read_num + 1
        WHERE id = #{newsId}
    </update>

    <update id="updateNewsLikeCount">
        UPDATE vote_event_news
        SET like_num = like_num + 1
        WHERE id = #{newsId}
    </update>

</mapper>
