CommentMapper.xml 3.64 KB
<?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.yohobuy.platform.dal.show.IShowCommentDao">
	<resultMap id="BaseResultMap" type="com.yohobuy.platform.dal.show.model.Comment">
		<id column="id" property="id" jdbcType="INTEGER" />
		<result column="element_id" property="elementId" jdbcType="INTEGER" />
		<result column="uid" property="uid" jdbcType="INTEGER" />
		<result column="content" property="content" jdbcType="VARCHAR" />
		<result column="comment_type" property="commentType" jdbcType="TINYINT" />
		<result column="status" property="status" jdbcType="TINYINT" />
		<result column="create_time" property="createTime" jdbcType="INTEGER" />
		<result column="order_code" property="orderCode" jdbcType="BIGINT" />
		<result column="size_name" property="sizeName" jdbcType="VARCHAR" />
		<result column="color_name" property="colorName" jdbcType="VARCHAR" />
		<result column="check_status" property="checkStatus" jdbcType="INTEGER" />
	</resultMap>
	<sql id="Base_Column_List">
		id, element_id, uid, content, comment_type, status, create_time, order_code, size_name,
		color_name,check_status
	</sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List" />
		from comments
		where id = #{id,jdbcType=INTEGER}
	</select>

	<insert id="insert" parameterType="com.yohobuy.platform.dal.show.model.Comment">
		<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
			SELECT LAST_INSERT_ID() AS id
		</selectKey>
		insert into comments (id, element_id, uid,
		content, comment_type,
		create_time, order_code, size_name,
		color_name)
		values (#{id,jdbcType=INTEGER}, #{elementId,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER},
		#{content,jdbcType=VARCHAR}, #{commentType,jdbcType=TINYINT},
		#{createTime,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sizeName,jdbcType=VARCHAR},
		#{colorName,jdbcType=VARCHAR})
	</insert>

	<update id="updateByPrimaryKeySelective" parameterType="com.yohobuy.platform.dal.show.model.Comment">
		update comments
		<set>
			<if test="elementId != null">
				element_id = #{elementId,jdbcType=INTEGER},
			</if>
			<if test="uid != null">
				uid = #{uid,jdbcType=INTEGER},
			</if>
			<if test="content != null">
				content = #{content,jdbcType=VARCHAR},
			</if>
			<if test="commentType != null">
				comment_type = #{commentType,jdbcType=TINYINT},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=TINYINT},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=INTEGER},
			</if>
			<if test="orderCode != null">
				order_code = #{orderCode,jdbcType=BIGINT},
			</if>
			<if test="sizeName != null">
				size_name = #{sizeName,jdbcType=VARCHAR},
			</if>
			<if test="colorName != null">
				color_name = #{colorName,jdbcType=VARCHAR},
			</if>
			<if test="checkStatus != null">
				check_status = #{checkStatus,jdbcType=INTEGER},
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>
	
	<select id="selectSnsCheckImage" resultType="com.yohobuy.platform.dal.show.model.SnsProductImage" parameterType="java.util.List">
		select s.product_id as productId,c.id as commentId, s.id as shareOrderId, si.id as imageId,si.url
		    from comments c 
		    inner join shareorder s on s.comment_id=c.id  
		    inner join shareorder_image si on si.share_order_id = s.id
			where c.status = 1 and s.product_id in 
        <foreach item="item" collection="productIdList" open="(" separator="," close=")">
          #{item,jdbcType=INTEGER}
        </foreach>
        order by product_id
	</select>
	
</mapper>