SuggestWordDefMapper.xml
3.54 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
82
83
84
85
<?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.yoho.search.dal.SuggestWordDefMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.SuggestWordDef">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="keyword" property="keyword" jdbcType="VARCHAR" />
<result column="weight" property="weight" jdbcType="INTEGER" />
<result column="count" property="count" jdbcType="INTEGER" />
<result column="count_for_blk" property="countForBlk" jdbcType="INTEGER" />
<result column="count_for_global" property="countForGlobal" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id, keyword, weight, count, count_for_blk, count_for_global, type, status
</sql>
<insert id="insertBatch" parameterType="java.util.List" timeout="20000">
insert ignore into suggest_word_def (keyword, weight, count, count_for_blk, count_for_global, type)
values
<foreach collection="list" item="item" index="index"
separator=",">
(#{item.keyword, jdbcType=VARCHAR},
#{item.weight, jdbcType=INTEGER},
#{item.count, jdbcType=INTEGER},
#{item.countForBlk, jdbcType=INTEGER},
#{item.countForGlobal, jdbcType=INTEGER},
#{item.type, jdbcType=INTEGER})
</foreach>
</insert>
<update id="updateBatch" parameterType="java.util.List">
update suggest_word_def
<trim prefix="set" suffixOverrides=",">
<trim prefix="count =case" suffix="end,">
<foreach collection="suggestWordDefList" item="item" index="index">
when id = #{item.id,jdbcType=INTEGER} then #{item.count,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="count_for_blk =case" suffix="end,">
<foreach collection="suggestWordDefList" item="item" index="index">
when id = #{item.id,jdbcType=INTEGER} then #{item.countForBlk,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="count_for_global =case" suffix="end,">
<foreach collection="suggestWordDefList" item="item" index="index">
when id = #{item.id,jdbcType=INTEGER} then #{item.countForGlobal,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="weight =case" suffix="end,">
<foreach collection="suggestWordDefList" item="item" index="index">
when id = #{item.id,jdbcType=INTEGER} then #{item.weight,jdbcType=DECIMAL}
</foreach>
</trim>
</trim>
where
<foreach collection="suggestWordDefList" separator="or" item="item" index="index" >
id = #{item.id,jdbcType=INTEGER}
</foreach>
</update>
<delete id="deleteBatch" parameterType="java.util.List">
DELETE FROM suggest_word_def WHERE ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<select id="selectTotalCount" resultType="java.lang.Integer" timeout="20000">
SELECT count(1) FROM suggest_word_def
</select>
<select id="selectCountByWordType" resultType="java.lang.Integer" timeout="20000">
SELECT count(1) FROM suggest_word_def where type = #{type,jdbcType=INTEGER}
</select>
<select id="selectPageList" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List" />
from suggest_word_def limit #{offset},#{pageSize}
</select>
<select id="selectByKeywordType" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List" />
from suggest_word_def where type = #{type} limit #{offset},#{pageSize}
</select>
</mapper>