StockMapper.xml
3.13 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
78
79
80
81
<?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.huaheng.pc.config.stock.mapper.StockMapper">
<resultMap type="com.huaheng.pc.config.stock.domain.Stock" id="stockResult">
<result property="stockId" column="stockId" />
<result property="name" column="name" />
<result property="number" column="number" />
<result property="isOpenLocation" column="isOpenLocation" />
<result property="useOrgId" column="useOrgId" />
<result property="deleted" column="deleted" />
</resultMap>
<sql id="selectStockVo">
select stockId, name, number, isOpenLocation,useOrgId,deleted from stock
</sql>
<select id="selectByNumber" resultType="com.huaheng.pc.config.stock.domain.Stock">
<include refid="selectStockVo"></include>
<where>
`number`=#{code}
</where>
</select>
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO stock
(stockId,name,number,isOpenLocation,useOrgId) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.stockId},#{item.name},#{item.number},#{item.isOpenLocation},#{item.useOrgId}
)
</foreach>
</insert>
<update id="modifyBatch" parameterType="java.util.List">
update stock
<trim prefix="set" suffixOverrides=",">
<trim prefix="name =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.name!=null">
when stockId=#{item.stockId}
then #{item.name}
</if>
</foreach>
</trim>
<trim prefix="number =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.number!=null">
when stockId=#{item.stockId}
then #{item.number}
</if>
</foreach>
</trim>
<trim prefix="isOpenLocation =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.isOpenLocation!=null">
when stockId=#{item.stockId}
then #{item.isOpenLocation}
</if>
</foreach>
</trim>
<trim prefix="useOrgId =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.useOrgId!=null">
when stockId=#{item.stockId}
then #{item.useOrgId}
</if>
</foreach>
</trim>
</trim>
where stockId in
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.stockId}
</foreach>
</update>
<update id="truncateTable">
truncate table stock
</update>
</mapper>