-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathAppDao.xml
More file actions
126 lines (113 loc) · 4.65 KB
/
AppDao.xml
File metadata and controls
126 lines (113 loc) · 4.65 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?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.sohu.cache.dao.AppDao">
<sql id="app_desc_fields">
app_id,name,user_id,status,intro,create_time,passed_time,type,officer,
ver_id,is_test,has_back_store,need_persistence,need_hot_back_up,forecase_qps,
forecast_obj_num,mem_alert_value,client_machine_room,app_key,client_conn_alert_value
</sql>
<!--通过appId查询app的信息-->
<select id="getAppDescById" resultType="AppDesc" parameterType="long">
SELECT
<include refid="app_desc_fields"/>
FROM app_desc
WHERE app_id = #{appId};
</select>
<!-- 根据应用名查询app信息 -->
<select id="getByAppName" resultType="AppDesc" parameterType="string">
SELECT
<include refid="app_desc_fields"/>
FROM app_desc
WHERE name = #{appName};
</select>
<insert id="save" parameterType="AppDesc" keyProperty="appId" useGeneratedKeys="true" >
insert into app_desc
(<include refid="app_desc_fields"/>)
values
(#{appId},#{name},#{userId},#{status},#{intro},#{createTime},#{passedTime},
#{type},#{officer},#{verId},#{isTest},#{hasBackStore},#{needPersistence},
#{needHotBackUp},#{forecaseQps},#{forecastObjNum},#{memAlertValue},#{clientMachineRoom},#{appKey},#{clientConnAlertValue})
</insert>
<update id="update" parameterType="AppDesc">
update app_desc
set name=#{name}, user_id=#{userId}, status=#{status}, intro=#{intro}, create_time=#{createTime},
passed_time=#{passedTime},type=#{type},
officer=#{officer},ver_id=#{verId},mem_alert_value=#{memAlertValue},client_conn_alert_value=#{clientConnAlertValue}
where app_id=#{appId}
</update>
<sql id="app_desc_select_column">
app_desc.app_id,name,app_desc.user_id,status,intro,create_time,passed_time,type,officer,ver_id,app_key
</sql>
<select id="getAppDescList" resultType="AppDesc" parameterType="long">
select
<include refid="app_desc_select_column"/>
from app_desc,app_to_user where app_to_user.user_id=#{userId} and app_to_user.app_id=app_desc.app_id
</select>
<select id="getUserAppCount" resultType="int" parameterType="long">
select count(app_desc.app_id) from app_desc,app_to_user where app_to_user.user_id=#{userId} and app_to_user.app_id=app_desc.app_id
</select>
<select id="getAllAppCount" resultType="int" parameterType="AppSearch">
select count(app_id) from app_desc where 1=1
<choose>
<when test="appName != null and appName != ''">
and name like CONCAT(SUBSTR(#{appName}, 1, LENGTH(#{appName})),'%')
</when>
</choose>
<choose>
<when test="appType != null and appType > 0">
and type = ${appType}
</when>
</choose>
<choose>
<when test="appStatus != null and appStatus >= 0">
and status = ${appStatus}
</when>
</choose>
<choose>
<when test="appId != null and appId > 0">
and app_id = ${appId}
</when>
</choose>
</select>
<select id="getAllAppDescList" resultType="AppDesc" parameterType="AppSearch">
select
<include refid="app_desc_fields"/>
from app_desc where 1=1
<choose>
<when test="appName != null and appName != ''">
and name like CONCAT(SUBSTR(#{appName}, 1, LENGTH(#{appName})),'%')
</when>
</choose>
<choose>
<when test="appType != null and appType > 0">
and type = ${appType}
</when>
</choose>
<choose>
<when test="appStatus != null and appStatus >= 0">
and status = ${appStatus}
</when>
</choose>
<choose>
<when test="appId != null and appId > 0">
and app_id = ${appId}
</when>
</choose>
<choose>
<when test="page != null">
<choose>
<when test="page.totalCount > page.pageSize">
limit #{page.start},#{page.pageSize};
</when>
<otherwise>
limit #{page.totalCount}
</otherwise>
</choose>
</when>
</choose>
</select>
<update id="updateAppKey">
update app_desc set app_key=#{appKey} where app_id=#{appId}
</update>
</mapper>