AttrValueMapper.xml 2.7 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.sibu.orderHelper.integral.web.dao.IMAttrValueDao">

	<resultMap id="attrValueResponse" type="com.sibu.orderHelper.integral.model.AttrValueBean">
		<result property="valueId" column="value_id" javaType="java.lang.Long" jdbcType="BIGINT"/>
		<result property="attrValue" column="attr_value" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="attrId" column="attr_id" javaType="java.lang.Long" jdbcType="BIGINT"/>
	</resultMap>
	
	<insert id="save" parameterType="com.sibu.orderHelper.integral.model.AttrValueBean">
		INSERT INTO attr_value (
			value_id,attr_value,attr_id
		) VALUES (
			#{valueId},#{attrValue},#{attrId}
		)
		<!-- <selectKey resultType="java.lang.String" keyProperty="valueId">
			<![CDATA[SELECT last_insert_id() AS id ]]>
		</selectKey> -->
	</insert>
		<!-- 批量保存图片 -->
	<insert id="batchInsert" parameterType="java.util.List" >
		INSERT INTO attr_value (
			attr_value,attr_id
		) VALUES
		<foreach collection="list" item="value" separator=",">
		 (#{value.attrValue},#{value.attrId})
		</foreach>
	</insert>
	<!-- 更新对象 ,只能更新属性值,其他不能更改-->
	<update id="update" parameterType="java.util.Map">
		UPDATE attr_value 
		<trim prefix="SET" suffixOverrides=",">
			<if test="null != attrValue">
				attr_value=#{attrValue},
			</if>
		</trim>
		WHERE value_id = #{valueId}
	</update>
	<!-- 批量更新value值-->
	<update id="batchUpdate" parameterType="java.util.List">
		<foreach collection="list" item="value" open="" close="" separator=";">
			UPDATE attr_value 
			<trim prefix="SET" suffixOverrides=",">
				<if test="null != value.attrValue">
					attr_value=#{value.attrValue},
				</if>
			</trim>
			WHERE value_id = #{value.valueId}
		</foreach>
	</update>
	
	<!-- 删除对象 -->
	<delete id="delete" parameterType="java.lang.Long">
		DELETE FROM attr_value WHERE value = #{valueId}
	</delete>
	<!-- 批量删除对象 -->
	<delete id="batchDelete" parameterType="java.util.List">
		DELETE FROM attr_value WHERE value_id in
		<foreach collection="list" item="item"  open="(" separator="," close=")">  
			#{item} 
		</foreach>
	</delete>
	
	<!-- 删除 -->
	<delete id="deleteByAttrId" parameterType="java.lang.Long">
		DELETE FROM attr_value WHERE attr_id = #{attrId}
	</delete>
	
	<!-- 查看属性的值是否已经被引用 -->
	<select id="selectAttrRefCount" resultType="java.lang.Integer" parameterType="java.util.List">
		SELECT COUNT(1) FROM `attr_ref`  WHERE attr_value_id IN
		<foreach collection="list" item="item"  open="(" separator="," close=")">  
			#{item} 
		</foreach>
	</select>
</mapper>