1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ ~ Copyright 2019 WeBank
4+ ~ Licensed under the Apache License, Version 2.0 (the "License");
5+ ~ you may not use this file except in compliance with the License.
6+ ~ You may obtain a copy of the License at
7+ ~
8+ ~ http://www.apache.org/licenses/LICENSE-2.0
9+ ~
10+ ~ Unless required by applicable law or agreed to in writing, software
11+ ~ distributed under the License is distributed on an "AS IS" BASIS,
12+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ ~ See the License for the specific language governing permissions and
14+ ~ limitations under the License.
15+ ~
16+ -->
17+
18+ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
19+
20+
21+ <mapper namespace =" com.webank.wedatasphere.dss.orchestrator.db.dao.OrchestratorMapper" >
22+
23+
24+
25+
26+ <sql id =" orchestrator_main" >
27+ id,`name`,`type`,`desc`,`creator`,`create_time`,`project_id`,`uses`,`appconn_name`,`uuid`,`secondary_type`
28+ </sql >
29+
30+ <sql id =" orchestrator_version" >
31+ id,`orchestrator_id`,`app_id`,`source`,`version`,`comment`,`update_time`,`updater`,`project_id`,`content`,`context_id`
32+ </sql >
33+
34+ <select id =" getOrchestrator" resultType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo" >
35+ SELECT * FROM `dss_orchestrator_info` WHERE id = #{id}
36+ </select >
37+
38+ <select id =" getOrchestratorByUUID" resultType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo" >
39+ SELECT * FROM `dss_orchestrator_info` WHERE uuid = #{uuid}
40+ </select >
41+
42+ <insert id =" addOrchestrator" useGeneratedKeys =" true" keyProperty =" id"
43+ parameterType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo" >
44+ INSERT INTO dss_orchestrator_info (<include refid =" orchestrator_main" />)
45+ VALUES
46+ (#{id},#{name},#{type},#{desc},#{creator},#{createTime},#{projectId},#{uses},#{appConnName},#{uuid},#{secondaryType})
47+ </insert >
48+
49+ <update id =" updateOrchestrator" parameterType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorInfo" >
50+ UPDATE dss_orchestrator_info
51+ <trim prefix =" set" suffixOverrides =" ," >
52+ <if test =" name != null" >`name`=#{name},</if >
53+ <if test =" desc != null" >`desc`=#{desc},</if >
54+ <if test =" appConnName != null" >`appconn_name`=#{appConnName},</if >
55+ <if test =" uses != null" >`uses`=#{uses},</if >
56+ <if test =" secondaryType != null" >`secondary_type`=#{secondaryType}</if >
57+ </trim >
58+ WHERE id = #{id}
59+ </update >
60+
61+
62+ <delete id =" deleteOrchestrator" >
63+ DELETE
64+ FROM
65+ dss_orchestrator_info
66+ WHERE id = #{id}
67+ </delete >
68+
69+ <insert id =" addOrchestratorVersion" useGeneratedKeys =" true" keyProperty =" id"
70+ parameterType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion" >
71+ INSERT INTO dss_orchestrator_version_info (<include refid =" orchestrator_version" />)
72+ VALUES
73+ (#{id},#{orchestratorId},#{appId},#{source},#{version},#{comment},#{updateTime},#{updater},#{projectId},#{content},#{contextId})
74+ </insert >
75+
76+
77+ <update id =" updateOrchestratorVersion"
78+ parameterType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion" >
79+ UPDATE dss_orchestrator_version_info
80+ <trim prefix =" set" suffixOverrides =" ," >
81+ <if test =" source != null" >`source` = #{source},</if >
82+ <if test =" appId != null" >`app_id` = #{appId},</if >
83+ <if test =" content != null" >`content`= #{content},</if >
84+ <if test =" comment != null" >`comment` = #{comment},</if >
85+ <if test =" contextId != null" >`context_id` = #{contextId},</if >
86+ <if test =" updateTime != null" >`update_time` = #{updateTime},</if >
87+ <if test =" updater != null" >`updater` = #{updater}</if >
88+ </trim >
89+ WHERE id = #{id}
90+ </update >
91+
92+
93+ <select id =" getLatestOrchestratorVersionById"
94+ resultType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion" >
95+ SELECT
96+ *
97+ FROM
98+ `dss_orchestrator_version_info`
99+ WHERE
100+ orchestrator_id = #{orchestratorId}
101+ ORDER BY
102+ version DESC
103+ LIMIT 1
104+ </select >
105+
106+
107+ <select id =" getOrchestratorVersion" resultType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion" >
108+ SELECT
109+ *
110+ FROM
111+ `dss_orchestrator_version_info`
112+ WHERE
113+ id = #{versionId}
114+ </select >
115+
116+ <delete id =" deleteOrchestratorVersion" >
117+ DELETE
118+ FROM
119+ dss_orchestrator_version_info
120+ WHERE id = #{versionId}
121+ </delete >
122+
123+ <select id =" getVersionByOrchestratorId"
124+ resultType =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion" >
125+ SELECT * FROM dss_orchestrator_version_info
126+ WHERE orchestrator_id = #{orchestratorId}
127+ ORDER BY version DESC
128+ </select >
129+
130+
131+
132+ <resultMap id =" orcInfo" type =" com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorInfo" >
133+ <result column =" id" property =" orchestratorVersionId" jdbcType =" BIGINT" />
134+ <result column =" orchestrator_id" property =" orchestratorId" jdbcType =" BIGINT" />
135+ </resultMap >
136+
137+
138+ <select id =" getOrcInfoByAppId" resultMap =" orcInfo" >
139+ select `id`, `orchestrator_id` from dss_orchestrator_version_info where app_id = #{appId}
140+ </select >
141+
142+ <resultMap id =" orchestrator_version_info_result_map" type =" com.webank.wedatasphere.dss.orchestrator.common.entity.DSSOrchestratorVersion" >
143+ <result column =" id" property =" id" jdbcType =" BIGINT" />
144+ <result column =" orchestrator_id" property =" orchestratorId" jdbcType =" BIGINT" />
145+ <result column =" app_id" property =" appId" jdbcType =" BIGINT" />
146+ <result column =" source" property =" source" jdbcType =" LONGVARCHAR" />
147+ <result column =" version" property =" version" jdbcType =" LONGVARCHAR" />
148+ <result column =" comment" property =" comment" jdbcType =" LONGVARCHAR" />
149+ <result column =" update_time" property =" updateTime" jdbcType =" TIMESTAMP" />
150+ <result column =" updater" property =" updater" jdbcType =" LONGVARCHAR" />
151+ <result column =" project_id" property =" projectId" jdbcType =" BIGINT" />
152+ <result column =" content" property =" content" jdbcType =" LONGVARCHAR" />
153+ </resultMap >
154+
155+ <select id =" getOrchestratorVersions" resultMap =" orchestrator_version_info_result_map" >
156+ select * from `dss_orchestrator_version_info` where `project_id` = #{projectId} and `orchestrator_id` = #{orchestratorId}
157+ </select >
158+
159+
160+
161+ <resultMap id =" orchestrator_user_map" type =" com.webank.wedatasphere.dss.orchestrator.common.entity.OrchestratorUser" >
162+ <result column =" id" property =" id" />
163+ <result column =" workspace_id" property =" workspaceId" />
164+ <result column =" project_id" property =" projectId" />
165+ <result column =" username" property =" username" />
166+ <result column =" priv" property =" priv" />
167+ <result column =" last_update_time" property =" lastUpdateTime" />
168+ </resultMap >
169+
170+ <select id = " getOrchestratorUserByOrcId" resultMap =" orchestrator_user_map" parameterType =" java.lang.Long" >
171+ select * from dss_orchestrator_user where `orchestrator_id` = #{orchestratorId}
172+ </select >
173+
174+
175+
176+ </mapper >
0 commit comments