aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
blob: 8978cdfb74f81cc8a1b1b1e8239c32903d7422db (plain)
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
<?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.webhook.WebhookMapper">

  <sql id="sqlColumns">
    uuid,
    name,
    url,
    project_uuid as projectUuid,
    secret,
    created_at as createdAt,
    updated_at as updatedAt
  </sql>

  <select id="selectByUuid" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto">
    select <include refid="sqlColumns" />
    from webhooks
    where uuid = #{webhookUuid,jdbcType=VARCHAR}
  </select>

  <select id="selectGlobalWebhooksOrderedByName" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto">
    select <include refid="sqlColumns" />
    from webhooks
    where project_uuid is null
    order by name asc
  </select>

  <select id="selectForProjectUuidOrderedByName" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto">
    select <include refid="sqlColumns" />
    from webhooks
    where project_uuid = #{projectUuid,jdbcType=VARCHAR}
    order by name asc
  </select>

  <insert id="insert" parameterType="org.sonar.db.webhook.WebhookDto" useGeneratedKeys="false">
    insert into webhooks (
    uuid,
    name,
    url,
    project_uuid,
    secret,
    created_at,
    updated_at
    ) values (
    #{uuid,jdbcType=VARCHAR},
    #{name,jdbcType=VARCHAR},
    #{url,jdbcType=VARCHAR},
    #{projectUuid,jdbcType=VARCHAR},
    #{secret,jdbcType=VARCHAR},
    #{createdAt,jdbcType=BIGINT},
    #{updatedAt,jdbcType=BIGINT}
    )
  </insert>

  <update id="update" parameterType="org.sonar.db.webhook.WebhookDto">
    update webhooks set
      name=#{name,jdbcType=VARCHAR},
      url=#{url,jdbcType=VARCHAR},
      secret=#{secret,jdbcType=VARCHAR},
      updated_at=#{updatedAt,jdbcType=BIGINT}
    where uuid=#{uuid,jdbcType=VARCHAR}
  </update>

  <delete id="delete" parameterType="String">
    delete from webhooks
    where
    uuid = #{uuid,jdbcType=VARCHAR}
  </delete>

  <delete id="deleteForProjectUuid" parameterType="String">
    delete from webhooks
    where
    project_uuid = #{projectUuid,jdbcType=VARCHAR}
  </delete>

</mapper>