AttrValueMapper.xml
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?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>