| <?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.configuration.dao.ConfigMapper"> |
| |
| <sql id="value_List"> |
| id, `application_id`,`key_id`,`user_name`,`value` |
| </sql> |
| |
| <sql id="key_List"> |
| id, `key`,`description`,`name`,`application_id`,`default_value`,`validate_type`,`validate_range`,`is_hidden`,`is_advanced`,`level`,`unit` |
| </sql> |
| |
| <select id="selectAppIDByAppName" resultType="Long"> |
| SELECT bda.id from linkis_application bda WHERE bda.name=#{name} |
| </select> |
| |
| <select id="selectAllAppKVs" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKeyValue"> |
| SELECT |
| bdck.id AS `key_id`, |
| bdck.`key`, |
| bdck.description, |
| bdck.`name`, |
| bdck.application_id AS `creator_id`, |
| bdck.default_value, |
| bdck.validate_type, |
| bdck.validate_range, |
| bdck.is_advanced, |
| bdck.is_hidden, |
| bdck. LEVEL |
| FROM |
| linkis_config_key bdck |
| LEFT JOIN linkis_config_key_tree bdckt ON bdck.id = bdckt.key_id |
| LEFT JOIN linkis_config_tree bdct ON bdct.id = bdckt.tree_id |
| WHERE |
| bdck.application_id = #{creatorID} |
| AND bdct.application_id = #{appID} |
| </select> |
| |
| <select id="selectAppconfigByAppIDAndCreatorID" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKeyValue"> |
| SELECT |
| bdck.id AS `key_id`, |
| bdck.`key`, |
| bdck.description, |
| bdck.`name`, |
| bdck.application_id AS `creator_id`, |
| bdck.default_value, |
| bdck.validate_type, |
| bdck.validate_range, |
| bdck.is_advanced, |
| bdck.is_hidden, |
| bdck.level, |
| bdcku.id AS `value_id`, |
| bdcku.application_id, |
| bdcku.user_name, |
| bdcku.`value` |
| FROM linkis_config_key bdck |
| LEFT JOIN linkis_config_key_user bdcku |
| ON bdck.id=bdcku.key_id |
| where bdcku.application_id=#{appID} AND bdcku.user_name=#{userName} and bdck.application_id=#{creatorID} |
| </select> |
| |
| <select id="selectTreesByAppNameAndParentID" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigTree"> |
| SELECT bdct.* |
| FROM linkis_config_tree bdct |
| LEFT JOIN linkis_application bda |
| ON bdct.application_id = bda.id |
| where bda.`name`=#{appName} and bdct.parent_id=#{parentID} |
| </select> |
| |
| <select id="selectTreeByTreeID" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigTree"> |
| SELECT * FROM linkis_config_tree bdct WHERE id=#{id} |
| </select> |
| |
| <select id="selectKeysByTreeID" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKey"> |
| SELECT bdck.* from linkis_config_tree bdct LEFT JOIN linkis_config_key_tree bdckt |
| on bdct.id = bdckt.tree_id |
| LEFT JOIN linkis_config_key bdck |
| on bdck.id = bdckt.key_id |
| where bdct.id = #{treeID} and bdck.application_id = #{creatorID} |
| </select> |
| |
| <select id="selectValueByKeyId" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKeyUser"> |
| SELECT * |
| FROM linkis_config_key_user bdcku |
| where bdcku.key_id = #{keyID} and bdcku.user_name=#{userName} and bdcku.application_id = #{appID} |
| </select> |
| |
| <insert id="insertValue" useGeneratedKeys="true" keyProperty="id" parameterType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKeyUser"> |
| INSERT INTO linkis_config_key_user(<include refid="value_List"/>) |
| VALUES (#{id},#{applicationID},#{keyID}, |
| #{userName},#{value}) |
| </insert> |
| |
| <update id="updateUserValue"> |
| UPDATE linkis_config_key_user SET value = #{value} WHERE id= #{id} |
| </update> |
| |
| <select id="selectKeyByKeyID" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKey"> |
| SELECT * from linkis_config_key where id = #{keyID} |
| </select> |
| |
| <select id="listKeyByCreatorAndAppName" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigKey"> |
| SELECT |
| `key`.* |
| FROM |
| linkis_config_tree tree, |
| linkis_config_key_tree kt, |
| linkis_config_key `key` |
| WHERE |
| tree.id = kt.tree_id |
| AND kt.key_id = `key`.id |
| AND `key`.application_id = #{creatorID} |
| AND tree.application_id = #{appID} |
| </select> |
| |
| <insert id="insertCreator"> |
| INSERT INTO linkis_application values(NULL,#{creator},NULL,NULL) |
| </insert> |
| |
| <select id="selectTreeIDByKeyID" resultType="Long"> |
| SELECT |
| kt.tree_id |
| FROM |
| linkis_config_key_tree kt |
| WHERE |
| kt.key_id = #{keyID} |
| </select> |
| |
| <insert id="insertKey" useGeneratedKeys="true" keyProperty="id" parameterType ="com.webank.wedatasphere.linkis.configuration.entity.ConfigKey"> |
| INSERT INTO linkis_config_key(<include refid="key_List"/>) |
| VALUES (#{id},#{key},#{description}, |
| #{name},#{applicationID},#{defaultValue},#{validateType},#{validateRange},#{isAdvanced},#{isHidden},#{level},#{unit}) |
| </insert> |
| |
| <insert id="insertKeyTree"> |
| INSERT INTO linkis_config_key_tree values(NULL,#{keyID},#{treeID}) |
| </insert> |
| |
| <select id="selectTreeByAppIDAndName" resultType="com.webank.wedatasphere.linkis.configuration.entity.ConfigTree"> |
| SELECT * FROM linkis_config_tree WHERE `name` = #{treeName} AND `application_id` = #{appID} |
| </select> |
| |
| </mapper> |