<!--
  ~
  ~  Copyright 2020 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.exchangis.job.server.mapper.JobTransformProcessorDao" >

    <resultMap id="processorMap" type="com.webank.wedatasphere.exchangis.job.server.render.transform.processor.TransformProcessor">
        <result column="id" property="id"/>
        <result column="job_id" property="jobId"/>
        <result column="code_content" property="codeContent"/>
        <result column="code_language" property="codeLanguage"/>
        <result column="code_bml_resourceId" property="codeBmlResourceId"/>
        <result column="code_bml_version" property="codeBmlVersion"/>
    </resultMap>
    <sql id="TableName">
        exchangis_job_transform_processor
    </sql>

    <insert id="saveOne" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
        INSERT INTO <include refid="TableName"/>
        (`job_id`, `code_content`, `code_language`, `code_bml_resourceId`, `code_bml_version`, `creator`)
        VALUES(#{jobId}, #{codeContent}, #{codeLanguage}, #{codeBmlResourceId,jdbcType=VARCHAR}, #{codeBmlVersion,jdbcType=VARCHAR}, #{creator});
    </insert>

    <select id="getProcDetail" resultMap="processorMap">
        SELECT `id`, `job_id`, `code_content`, `code_language`, `code_bml_resourceId`, `code_bml_version`, `creator`
        FROM <include refid="TableName"/>
        WHERE `id` = #{id};
    </select>

    <select id="getProcInfo" resultMap="processorMap">
        SELECT `id`, `job_id`, `code_language`, `code_bml_resourceId`, `code_bml_version`, `creator`
        FROM <include refid="TableName"/>
        WHERE `id` = #{id};
    </select>

    <update id="updateOne">
        UPDATE <include refid="TableName"/>
        SET
        `code_content` = #{codeContent},
        `code_language` = #{codeLanguage},
        `code_bml_resourceId` = #{codeBmlResourceId},
        `code_bml_version` = #{codeBmlVersion}
        WHERE `id` = #{id};
    </update>
</mapper>