/
AlmAppInstallMapper.xml
96 lines (85 loc) · 2.8 KB
/
AlmAppInstallMapper.xml
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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
<mapper namespace="org.sonar.db.alm.AlmAppInstallMapper">
<sql id="sqlColumns">
aai.uuid,
aai.alm_id as almId,
aai.owner_id as ownerId,
aai.is_owner_user as isOwnerUser,
aai.install_id as installId,
aai.user_external_id as userExternalId,
aai.created_at as createdAt,
aai.updated_at as updatedAt
</sql>
<select id="selectByOwnerId" parameterType="Map" resultType="org.sonar.db.alm.AlmAppInstallDto">
select <include refid="sqlColumns" />
from
alm_app_installs aai
where
alm_id = #{almId, jdbcType=VARCHAR}
and owner_id = #{ownerId, jdbcType=VARCHAR}
</select>
<select id="selectByInstallationId" parameterType="Map" resultType="org.sonar.db.alm.AlmAppInstallDto">
select <include refid="sqlColumns"/>
from
alm_app_installs aai
where
alm_id = #{almId, jdbcType=VARCHAR}
and install_id = #{installId, jdbcType=VARCHAR}
</select>
<select id="selectByUuid" parameterType="Map" resultType="org.sonar.db.alm.AlmAppInstallDto">
select <include refid="sqlColumns"/>
from
alm_app_installs aai
where
uuid = #{uuid, jdbcType=VARCHAR}
</select>
<select id="selectUnboundByUserExternalId" parameterType="Map" resultType="org.sonar.db.alm.AlmAppInstallDto">
select <include refid="sqlColumns" />
from
alm_app_installs aai
left outer join organization_alm_bindings bind on bind.alm_app_install_uuid = aai.uuid
where
aai.user_external_id = #{userExternalId, jdbcType=VARCHAR}
and bind.uuid is null
</select>
<insert id="insert" parameterType="Map" useGeneratedKeys="false">
INSERT INTO alm_app_installs
(
uuid,
alm_id,
owner_id,
is_owner_user,
install_id,
user_external_id,
created_at,
updated_at
)
VALUES (
#{uuid, jdbcType=VARCHAR},
#{almId, jdbcType=VARCHAR},
#{ownerId, jdbcType=VARCHAR},
#{isOwnerUser, jdbcType=BOOLEAN},
#{installId, jdbcType=VARCHAR},
#{userExternalId, jdbcType=VARCHAR},
#{now, jdbcType=BIGINT},
#{now, jdbcType=BIGINT}
)
</insert>
<update id="update" parameterType="map">
update alm_app_installs set
install_id = #{installId, jdbcType=VARCHAR},
is_owner_user = #{isOwnerUser, jdbcType=BOOLEAN},
user_external_id = #{userExternalId, jdbcType=VARCHAR},
updated_at = #{now, jdbcType=BIGINT}
where
alm_id = #{almId, jdbcType=VARCHAR}
and owner_id = #{ownerId, jdbcType=VARCHAR}
</update>
<delete id="delete" parameterType="Map">
delete from alm_app_installs
where
alm_id = #{almId, jdbcType=VARCHAR}
and owner_id = #{ownerId, jdbcType=VARCHAR}
</delete>
</mapper>