This is an automated email from the ASF dual-hosted git repository.

aiceflower pushed a commit to branch release-0.9.4
in repository https://gitbox.apache.org/repos/asf/linkis.git

commit b4d34564b2f849c0575b21bd6be0c0e460e765c1
Author: dennyzhou-zdx <[email protected]>
AuthorDate: Wed Feb 26 21:49:39 2020 +0800

    #Fixes #299
---
 .../datasourcemanager/core/dao/DataSourceDao.java  |  75 +++++++++
 .../core/dao/DataSourceEnvDao.java                 |  67 ++++++++
 .../core/dao/DataSourceParamKeyDao.java            |  42 +++++
 .../core/dao/DataSourceTypeDao.java                |  36 +++++
 .../core/dao/DataSourceTypeEnvDao.java             |  38 +++++
 .../core/dao/mapper/DataSouceMapper.xml            | 177 +++++++++++++++++++++
 .../core/dao/mapper/DataSourceEnvMapper.xml        |  96 +++++++++++
 .../core/dao/mapper/DataSourceParamKeyMapper.xml   |  45 ++++++
 .../core/dao/mapper/DataSourceTypeEnvMapper.xml    |  28 ++++
 .../core/dao/mapper/DataSourceTypeMapper.xml       |  31 ++++
 10 files changed, 635 insertions(+)

diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceDao.java
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceDao.java
new file mode 100644
index 0000000000..b14fa32b64
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceDao.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2019 WeBank
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.core.dao;
+
+
+import 
com.webank.wedatasphere.linkis.datasourcemanager.common.domain.DataSource;
+import com.webank.wedatasphere.linkis.datasourcemanager.core.vo.DataSourceVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Data source dao
+ * @author dennyzhou-zdx
+ * 2020/02/14
+ */
+public interface DataSourceDao {
+
+    /**
+     * Insert
+     * @param dataSource data source
+     */
+    void  insertOne(DataSource dataSource);
+
+    /**
+     * View detail
+     * @param dataSourceId data source id
+     * @param createSystem system name
+     * @return data source entity
+     */
+    DataSource selectOneDetail(@Param("dataSourceId") Long dataSourceId,
+                               @Param("createSystem") String createSystem);
+
+    /**
+     * View normal
+     * @param dataSourceId data source id
+     * @param createSystem system name
+     * @return data source entity
+     */
+    DataSource selectOne(@Param("dataSourceId") Long dataSourceId,
+                         @Param("createSystem") String createSystem);
+    /**
+     * Delete One
+     * @param dataSourceId data source id
+     * @param createSystem create system
+     * @return affect row
+     */
+    int removeOne(@Param("dataSourceId")Long dataSourceId,
+                  @Param("createSystem")String createSystem);
+
+
+    /**
+     * Update one
+     * @param updatedOne updated one
+     */
+    void updateOne(DataSource updatedOne);
+
+    /**
+     * Page of query
+     * @param dataSourceVo data source view entity
+     * @return query list
+     */
+    List<DataSource> selectByPageVo(DataSourceVo dataSourceVo);
+}
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceEnvDao.java
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceEnvDao.java
new file mode 100644
index 0000000000..247c419e71
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceEnvDao.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2019 WeBank
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.core.dao;
+
+import 
com.webank.wedatasphere.linkis.datasourcemanager.common.domain.DataSourceEnv;
+import 
com.webank.wedatasphere.linkis.datasourcemanager.core.vo.DataSourceEnvVo;
+
+import java.util.List;
+
+/**
+ * Data source dao
+ * @author dennyzhou-zdx
+ * 2020/02/14
+ */
+public interface DataSourceEnvDao {
+
+    /**
+     * View details of data source environment information
+     * @param dataSourceEnvId env id
+     * @return
+     */
+    DataSourceEnv selectOneDetail(Long dataSourceEnvId);
+
+    /**
+     * Insert one
+     * @param dataSourceEnv environment
+     */
+    void insertOne(DataSourceEnv dataSourceEnv);
+
+    /**
+     * List all by type id
+     * @param dataSourceTypeId type id
+     * @return
+     */
+    List<DataSourceEnv> listByTypeId(Long dataSourceTypeId);
+
+    /**
+     * Remove one
+     * @param envId env id
+     * @return
+     */
+    int removeOne(Long envId);
+
+    /**
+     * Update one
+     * @param updatedOne
+     */
+    void updateOne(DataSourceEnv updatedOne);
+
+    /**
+     * Page query
+     * @param dataSourceEnvVo  environment view entity
+     * @return
+     */
+    List<DataSourceEnv> selectByPageVo(DataSourceEnvVo dataSourceEnvVo);
+}
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java
new file mode 100644
index 0000000000..e6693fbb71
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019 WeBank
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.core.dao;
+
+import 
com.webank.wedatasphere.linkis.datasourcemanager.common.domain.DataSourceParamKeyDefinition;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+/**
+ *
+ * @author dennyzhou-zdx
+ * 2020/02/14
+ */
+public interface DataSourceParamKeyDao {
+
+    /**
+     * List by data source type id
+     * @param dataSourceTypeId type id
+     * @return
+     */
+    List<DataSourceParamKeyDefinition> listByDataSourceType(Long 
dataSourceTypeId);
+
+    /**
+     * List by data source type id and scope
+     * @param dataSourceTypeId type id
+     * @param scope scope
+     * @return
+     */
+    List<DataSourceParamKeyDefinition> 
listByDataSourceTypeAndScope(@Param("dataSourceTypeId")Long dataSourceTypeId,
+                                                                    
@Param("scope")DataSourceParamKeyDefinition.Scope scope);
+}
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceTypeDao.java
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceTypeDao.java
new file mode 100644
index 0000000000..94a7b6a56d
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceTypeDao.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019 WeBank
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.core.dao;
+
+import 
com.webank.wedatasphere.linkis.datasourcemanager.common.domain.DataSourceType;
+
+import java.util.List;
+/**
+ * @author dennyzhou-zdx
+ * 2020/02/14
+ */
+public interface DataSourceTypeDao {
+    /**
+     * Get all types
+     * @return type entity list
+     */
+    List<DataSourceType> getAllTypes();
+
+    /**
+     * View
+     * @param typeId
+     * @return
+     */
+    DataSourceType selectOne(Long typeId);
+}
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceTypeEnvDao.java
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceTypeEnvDao.java
new file mode 100644
index 0000000000..83e6ae469f
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/DataSourceTypeEnvDao.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2019 WeBank
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.core.dao;
+
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author dennyzhu-zdx
+ * 2020/02/14
+ */
+public interface DataSourceTypeEnvDao {
+
+    /**
+     * Insert relation between type and environment
+     * @param dataSourceTypeId data source type
+     * @param dataSourceEnvId data source env
+     */
+    void insertRelation(@Param("dataSourceTypeId") Long dataSourceTypeId,
+                        @Param("dataSourceEnvId") Long dataSourceEnvId);
+
+    /**
+     * Remove relations by environment id
+     * @param envId
+     * @return
+     */
+    int removeRelationsByEnvId(Long envId);
+}
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSouceMapper.xml
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSouceMapper.xml
new file mode 100644
index 0000000000..541634b5bb
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSouceMapper.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2019 WeBank
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="com.webank.wedatasphere.linkis.datasourcemanager.core.dao.DataSourceDao">
+    <resultMap id="dataSourceDetailMap" type="DataSource">
+        <result property="id" column="id"/>
+        <result property="dataSourceName" column="datasource_name"/>
+        <result property="dataSourceDesc" column="datasource_desc"/>
+        <result property="dataSourceTypeId" column="datasource_type_id"/>
+        <result property="createIdentify" column="create_identity"/>
+        <result property="createSystem" column="create_system"/>
+        <result property="parameter" column="parameter"/>
+        <result property="dataSourceEnvId" column="datasource_env_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="modifyTime" column="modify_time"/>
+        <result property="modifyUser" column="modify_user"/>
+        <result property="createUser" column="create_user"/>
+        <association property="dataSourceType" javaType="DataSourceType">
+            <result property="icon" column="icon"/>
+            <result property="name" column="name"/>
+        </association>
+        <association property="dataSourceEnv" javaType="DataSourceEnv" 
column="datasource_env_id" select="selectEnvById">
+            <result property="envName" column="env_name"/>
+            <result property="parameter" column="env_parameter"/>
+        </association>
+    </resultMap>
+
+    <resultMap id="dataSourceMap" type="DataSource">
+        <result property="id" column="id"/>
+        <result property="dataSourceName" column="datasource_name"/>
+        <result property="dataSourceDesc" column="datasource_desc"/>
+        <result property="dataSourceTypeId" column="datasource_type_id"/>
+        <result property="createIdentify" column="create_identity"/>
+        <result property="createSystem" column="create_system"/>
+        <result property="parameter" column="parameter"/>
+        <result property="dataSourceEnvId" column="datasource_env_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="modifyTime" column="modify_time"/>
+        <result property="modifyUser" column="modify_user"/>
+        <result property="createUser" column="create_user"/>
+    </resultMap>
+
+    <sql id="data_source_insert_columns">
+        `datasource_name`, `datasource_type_id`, `datasource_desc`,
+        `create_identify`, `create_system`, `create_user`, `parameter`, 
`create_time`,
+        `modify_user`, `modify_time`, `datasource_env_id`
+    </sql>
+
+    <sql id="data_source_query_columns">
+        `id`, `datasource_name`, `datasource_type_id`, `datasource_desc`,
+        `create_identify`, `create_system`, `create_user`, `parameter`, 
`create_time`,
+        `modify_user`, `modify_time`, `datasource_env_id`
+    </sql>
+
+    <sql id="data_source_query_page">
+        `id`, `datasource_name`, `datasource_type_id`, `datasource_desc`,
+        `create_identify`, `create_system`, `create_user`, `create_time`,
+        `modify_user`, `modify_time`, `datasource_env_id`
+    </sql>
+    <sql id="data_source_join_type">
+        t.`name`, t.`icon`,
+        d.`id`, d.`datasource_name`, d.`datasource_type_id`, 
d.`datasource_desc`,
+        d.`create_identify`, d.`create_system`, d.`create_user`, 
d.`parameter`, d.`create_time`,
+        d.`modify_user`, d.`modify_time`, d.`datasource_env_id`
+    </sql>
+
+    <insert id="insertOne" useGeneratedKeys="true" keyProperty="id" 
parameterType="DataSource">
+        <![CDATA[INSERT INTO `linkis_datasource`(]]>
+        <include refid="data_source_insert_columns"/>
+        <![CDATA[) VALUES(#{dataSourceName}, #{dataSourceTypeId},
+        #{dataSourceDesc,jdbcType=VARCHAR}, #{createIdentify}, 
#{createSystem}, #{createUser},
+        #{parameter}, #{createTime}, #{modifyUser,jdbcType=VARCHAR}, 
#{modifyTime,jdbcType=DATE},
+         #{dataSourceEnvId,jdbcType=INTEGER})]]>
+    </insert>
+
+    <select id="selectOneDetail" resultMap="dataSourceDetailMap">
+        <![CDATA[SELECT ]]>
+        <include refid="data_source_join_type"/>
+        <![CDATA[ FROM `linkis_datasource_type` t
+        INNER JOIN `linkis_datasource` d ON t.`id` = d.`datasource_type_id`]]>
+        <where>
+            d.`id` = #{dataSourceId}
+            <if test="createSystem != null and createSystem != ''">
+                AND d.`create_system` = #{createSystem}
+            </if>
+        </where>
+    </select>
+
+    <select id="selectOne" resultMap="dataSourceMap">
+        <![CDATA[SELECT ]]>
+        <include refid="data_source_query_columns"/>
+        <![CDATA[ FROM `linkis_datasource` ]]>
+        <where>
+            `id` = #{dataSourceId}
+            <if test="createSystem != null and createSystem != ''">
+                AND `create_system` = #{createSystem}
+            </if>
+        </where>
+    </select>
+
+    <select id="selectEnvById" resultType="DataSourceEnv">
+        <![CDATA[SELECT `env_name`, `parameter` AS `env_parameter`
+        FROM `linkis_datasource_env` WHERE `id` = #{id};]]>
+    </select>
+
+    <delete id="removeOne">
+        <![CDATA[DELETE FROM `linkis_datasource`]]>
+        <where>
+            `id` = #{dataSourceId}
+            <if test="createSystem != null and createSystem != ''">
+                AND `create_system` = #{createSystem}
+            </if>
+        </where>
+    </delete>
+
+    <update id="updateOne">
+        <![CDATA[UPDATE `linkis_datasource`]]>
+        <set>
+            <![CDATA[`datasource_name` = #{dataSourceName},]]>
+            <![CDATA[`datasource_desc` = #{dataSourceDesc,jdbcType=VARCHAR},]]>
+            <if test="dataSourceTypeId != null and dataSourceTypeId > 0">
+                <![CDATA[`datasource_type_id` = #{dataSourceTypeId},]]>
+            </if>
+            <![CDATA[`create_identify` = #{createIdentify,jdbcType=VARCHAR},]]>
+            <![CDATA[`create_system` = #{createSystem,jdbcType=VARCHAR},]]>
+            <![CDATA[`parameter` = #{parameter,jdbcType=VARCHAR},]]>
+            <![CDATA[`datasource_env_id` = 
#{dataSourceEnvId,jdbcType=INTEGER},]]>
+            <![CDATA[`modify_time` = #{modifyTime,jdbcType=DATE},]]>
+            <![CDATA[`modify_user` = #{modifyUser,jdbcType=VARCHAR}]]>
+        </set>
+        <where>
+            `id` = #{id}
+        </where>
+    </update>
+
+    <select id="selectByPageVo" resultMap="dataSourceMap">
+        <![CDATA[SELECT ]]>
+        <include refid="data_source_query_page"/>
+        <![CDATA[ FROM `linkis_datasource` ]]>
+        <where>
+            <![CDATA[`create_system` = #{createSystem}]]>
+            <if test="dataSourceName != null and dataSourceName != ''">
+                <![CDATA[AND `datasource_name` like concat('%', 
#{dataSourceName}, '%')]]>
+            </if>
+            <if test="dataSourceTypeId != null and dataSourceTypeId > 0">
+                <![CDATA[AND `datasource_type_id` = #{dataSourceTypeId}]]>
+            </if>
+            <if test="createIdentifyList.size() > 0">
+                <choose>
+                    <when test="createIdentifyList.size() == 1">
+                        <foreach collection="createIdentifyList" separator="" 
item="item" open="AND " close="">
+                            <![CDATA[`create_identity` = #{item}]]>
+                        </foreach>
+                    </when>
+                    <otherwise>
+                        <foreach collection="createIdentifyList" separator="," 
item="item"
+                                 open="AND `create_identity` IN(" close=")">
+                            <![CDATA[#{item}]]>
+                        </foreach>
+                    </otherwise>
+                </choose>
+            </if>
+        </where>
+    </select>
+</mapper>
\ No newline at end of file
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceEnvMapper.xml
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceEnvMapper.xml
new file mode 100644
index 0000000000..a2f6eac0d8
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceEnvMapper.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2019 WeBank
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="com.webank.wedatasphere.linkis.datasourcemanager.core.dao.DataSourceEnvDao">
+    <resultMap id="dataSourceEnvMap" type="DataSourceEnv">
+        <result property="id" column="id"/>
+        <result property="envName" column="env_name"/>
+        <result property="envDesc" column="env_desc"/>
+        <result property="parameter" column="parameter"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createUser" column="create_user"/>
+        <result property="modifyTime" column="modify_time"/>
+        <result property="modifyUser" column="modify_user"/>
+        <result property="dataSourceTypeId" column="data_source_type_id"/>
+        <association property="dataSourceType" javaType="DataSourceType">
+            <result property="icon" column="icon"/>
+            <result property="name" column="name"/>
+        </association>
+    </resultMap>
+
+    <sql id="data_source_env_insert_columns">
+        `env_name`, `env_desc`, `parameter`, `create_time`,
+        `create_user`, `modify_time`, `modify_user`
+    </sql>
+
+    <sql id="data_source_env_detail">
+        `id`, `env_name`, `env_desc`, `parameter`, `create_time`,
+        `create_user`, `modify_time`, `modify_user`
+    </sql>
+
+    <select id="selectOneDetail" resultMap="dataSourceEnvMap">
+        <![CDATA[SELECT e.`id`, e.`env_name`, e.`env_desc`, e.`parameter`, 
e.`create_time`,
+        e.`create_user`, e.`modify_time`, e.`modify_user`
+            FROM `linkis_datasource_env` e WHERE id = #{dataSourceEnvId};]]>
+    </select>
+
+    <insert id="insertOne" useGeneratedKeys="true" keyProperty="id" 
parameterType="DataSourceEnv">
+        <![CDATA[INSERT INTO `linkis_datasource_env`(]]>
+        <include refid="data_source_env_insert_columns"/>
+        <![CDATA[) VALUES(#{envName}, #{envDesc,jdbcType=VARCHAR},
+         #{parameter}, #{createTime}, #{createUser},
+          #{modifyTime,jdbcType=DATE}, #{modifyUser,jdbcType=VARCHAR});]]>
+    </insert>
+
+    <select id="listByTypeId" resultMap="dataSourceEnvMap">
+        <![CDATA[SELECT `id`, `env_name` FROM `linkis_datasource_env`
+        WHERE `id` IN (SELECT `env_id` FROM `linkis_datasource_type_env`
+        WHERE `data_source_type_id` = #{id})]]>
+    </select>
+
+    <select id="selectByPageVo" resultMap="dataSourceEnvMap">
+        <![CDATA[SELECT e.`id`, e.`env_name`, e.`env_desc`, e.`parameter`, 
e.`create_time`,
+        e.`create_user`, e.`modify_time`, e.`modify_user`, 
te.`data_source_type_id`
+            FROM `linkis_datasource_env` e INNER JOIN 
`linkis_datasource_type_env` te
+             ON e.`id` = te.`env_id`]]>
+        <where>
+            <if test="envName != null and envName != ''">
+                <![CDATA[e.`env_name` like concat('%', #{envName}, '%')]]>
+            </if>
+            <if test="dataSourceTypeId != null and dataSourceTypeId > 0">
+                <![CDATA[AND te.`data_source_type_id` = #{dataSourceTypeId}]]>
+            </if>
+        </where>
+    </select>
+
+    <delete id="removeOne">
+        <![CDATA[DELETE FROM `linkis_datasource_env` WHERE `id` = #{id};]]>
+    </delete>
+
+    <update id="updateOne">
+        <![CDATA[UPDATE `linkis_datasource_env` ]]>
+        <set>
+            <![CDATA[`env_name` = #{envName},]]>
+            <![CDATA[`env_desc` = #{envDesc,jdbcType=VARCHAR},]]>
+            <![CDATA[`parameter` = #{parameter},]]>
+            <![CDATA[`parameter` = #{parameter},]]>
+            <![CDATA[`modify_time` = #{modifyTime,jdbcType=DATE},]]>
+            <![CDATA[`modify_user` = #{modifyUser,jdbcType=VARCHAR}]]>
+        </set>
+        <where>
+            `id` = #{id}
+        </where>
+    </update>
+</mapper>
\ No newline at end of file
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml
new file mode 100644
index 0000000000..1fcb42da4a
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2019 WeBank
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="com.webank.wedatasphere.linkis.datasourcemanager.core.dao.DataSourceParamKeyDao">
+    <resultMap id="paramKeyMap" type="DataSourceParamKeyDefinition">
+        <result property="id" column="id"/>
+        <result property="key" column="key"/>
+        <result property="description" column="description"/>
+        <result property="name" column="name"/>
+        <result property="defaultValue" column="default_value"/>
+        <result property="valueType" column="value_type"/>
+        <result property="scope" column="scope"/>
+        <result property="require" column="require"/>
+        <result property="valueRegex" column="value_regex"/>
+        <result property="refId" column="ref_id"/>
+        <result property="refValue" column="ref_value"/>
+    </resultMap>
+    <sql id="param_key_query">
+        `id`, `key`, `description`, `name`, `require`, `scope`,
+        `default_value`, `value_type`, `value_regex`, `ref_id`, `ref_value`
+    </sql>
+    <select id="listByDataSourceType" resultMap="paramKeyMap" 
parameterType="Long">
+        <![CDATA[SELECT ]]>
+        <include refid="param_key_query"/>
+        <![CDATA[ FROM `linkis_datasource_type_key` WHERE 
`data_source_type_id` = #{dataSourceTypeId};]]>
+    </select>
+    <select id="listByDataSourceTypeAndScope" resultMap="paramKeyMap">
+        <![CDATA[SELECT ]]>
+        <include refid="param_key_query"/>
+        <![CDATA[ FROM `linkis_datasource_type_key`
+        WHERE `data_source_type_id` = #{dataSourceTypeId} AND `scope` = 
#{scope};]]>
+    </select>
+</mapper>
\ No newline at end of file
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceTypeEnvMapper.xml
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceTypeEnvMapper.xml
new file mode 100644
index 0000000000..3a124012ab
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceTypeEnvMapper.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2019 WeBank
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="com.webank.wedatasphere.linkis.datasourcemanager.core.dao.DataSourceTypeEnvDao">
+
+    <insert id="insertRelation" useGeneratedKeys="true" keyProperty="id">
+        <![CDATA[INSERT INTO `linkis_datasource_type_env`
+        (`data_source_type_id`, `env_id`) VALUES
+        (#{dataSourceTypeId}, #{dataSourceEnvId});]]>
+    </insert>
+
+    <delete id="removeRelationsByEnvId">
+        <![CDATA[DELETE FROM `linkis_datasource_type_env` WHERE
+        `env_id` = #{envId};]]>
+    </delete>
+</mapper>
\ No newline at end of file
diff --git 
a/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceTypeMapper.xml
 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceTypeMapper.xml
new file mode 100644
index 0000000000..f451e21791
--- /dev/null
+++ 
b/datasource/datasourcemanager/server/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/core/dao/mapper/DataSourceTypeMapper.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2019 WeBank
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="com.webank.wedatasphere.linkis.datasourcemanager.core.dao.DataSourceTypeDao">
+    <resultMap id="dataSourceTypeMap" type="dataSourceType">
+        <result property="id" column="id"/>
+        <result property="icon" column="icon"/>
+        <result property="description" column="description"/>
+        <result property="name" column="name"/>
+    </resultMap>
+
+    <select id="getAllTypes" resultMap="dataSourceTypeMap">
+        <![CDATA[SELECT * FROM `linkis_datasource_type`;]]>
+    </select>
+
+    <select id="selectOne" resultMap="dataSourceTypeMap">
+        <![CDATA[SELECT * FROM `linkis_datasource_type` WHERE id = #{id};]]>
+    </select>
+</mapper>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to