<?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.iamberry.wechat.service.mapper.ImageTextMoreMapper">
	<resultMap type="ImageTextMore" id="ImageTextMore">
		<id column="moreImageTextNo" property="moreImageTextNo" />
		<result column="clickOutUrl" property="clickOutUrl" />
		<result column="clickUrl" property="clickUrl" />
		<result column="createTime" property="createTime" />
		<result column="digest" property="digest" />
		<result column="mainText" property="mainText" />
		<result column="imageTextNo" property="imageTextNo" />
		<result column="imageUrl" property="imageUrl" />
		<result column="sourceUrl" property="sourceUrl" />
		<result column="imageTextType" property="imageTextType" />
		<result column="title" property="title" />
	</resultMap>
	
	<!-- 添加多图文素材 -->
	<insert id="addImageTextMore" parameterType="ImageTextMore">
		INSERT INTO
			TB_WX_IMAGETEXTMORE
			(CLICKOUTURL,
			CLICKURL,
			CREATETIME,
			DIGEST,
			IMAGETEXTNO,
			IMAGETEXTTYPE,
			IMAGEURL,
			MAINTEXT,
			SOURCEURL,
			TITLE
			)
		VALUES
			(
				#{clickOutUrl},
				#{clickUrl},
				#{createTime},
				#{digest},
				#{imageTextNo},
				#{imageTextType},
				#{imageUrl},
				#{mainText},
				#{sourceUrl},
				#{title}			
			)
	</insert>
	
	<!-- 根据多图文ID 删除多图文素材 -->
	<delete id="delImageTextMore" parameterType="long">
		DELETE FROM TB_WX_IMAGETEXTMORE WHERE MOREIMAGETEXTNO=#{0}
	</delete>
	
	<!-- 根据主图文ID，删除多图文素材 -->
	<delete id="delImageTextMoreByImageNo" parameterType="long">
		DELETE FROM TB_WX_IMAGETEXTMORE WHERE IMAGETEXTNO=#{0}
	</delete>
		
	<!-- 修改多图文 -->
	<update id="updateImageTextMore">
		UPDATE
			TB_WX_IMAGETEXTMORE
		SET
			CLICKOUTURL = #{clickOutUrl},
			CLICKURL = #{clickUrl},
			CREATETIME = #{createTime},
			DIGEST = #{digest},
			IMAGETEXTNO = #{imageTextNo},
			IMAGETEXTTYPE = #{imageTextType},
			IMAGEURL = #{imageUrl},
			MAINTEXT = #{mainText},
			SOURCEURL = #{sourceUrl},
			TITLE = #{title}
		WHERE
			MOREIMAGETEXTNO = #{moreImageTextNo}
	</update>
	
	<!-- 根据ID来查询多图文 -->
	<select id="findImageTextmore" resultMap="ImageTextMore">
		SELECT
			*
		FROM
			TB_WX_IMAGETEXTMORE 
		WHERE
			IMAGETEXTNO = #{imageTextNo} 
	</select>
	<select id="getImageTextmore" resultMap="ImageTextMore">
		SELECT
			*
		FROM
			TB_WX_IMAGETEXTMORE
		WHERE
			MOREIMAGETEXTNO=#{moreImageTextNo}
	</select>
	
	<!-- 
		以下代码为补充代码，  以上代码为老代码，有些可废弃删除
	 -->
	<!-- 根据主图文ID，查询附图文的个数-->
	<select id="selectMoreImageTextCountByMainId" parameterType="int" resultType="int">
		SELECT 
			COUNT(*) 
		FROM 
			TB_WX_IMAGETEXTMORE 
		WHERE 
			IMAGETEXTNO = #{0}
	</select>
	
</mapper>