All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.linkis.bml.dao.impl.ResourceMapper.xml Maven / Gradle / Ivy

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You 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="org.apache.linkis.bml.dao.ResourceDao">

    <resultMap id="Resource" type="org.apache.linkis.bml.entity.Resource">
        <result property="resourceId" column="resource_id"/>
        <result property="user" column="owner"/>
        <result property="resourceHeader" column="resource_header"/>
        <result property="isPrivate" column="is_private"/>
        <result property="downloadedFileName" column="downloaded_file_name"/>
        <result property="system" column="sys"/>
        <result property="isExpire" column="is_expire"/>
        <result property="expireType" column="expire_type"/>
        <result property="updateTime" column="update_time"/>
        <result property="updator" column="updator"/>
        <result property="enableFlag" column="enable_flag"/>
    </resultMap>





    <sql id="resource_columns">
      `resource_id`,`is_private`, `resource_header`, `downloaded_file_name`, `sys`,
      `create_time`,`owner`,`is_expire`,`expire_time`,`max_version`,`update_time`,`updator`,`enable_flag`
    </sql>


    <select id="getResource" resultMap="Resource" parameterType="java.lang.String">
        select * from linkis_ps_bml_resources where resource_id = #{resourceId} and enable_flag = 1
    </select>

    <select id="getResources" resultMap="Resource" parameterType="java.util.Map">
        select resource_id, owner, sys from linkis_ps_bml_resources
        <where>
            enable_flag = 1
            <if test="resourceId != null and resourceId != '' ">
                and resource_id = #{resourceId}
            </if>
            <if test="owner != null and owner != '' ">
                and owner = #{owner}
            </if>
            <if test="sys != null and sys != '' ">
                and sys = #{sys}
            </if>
        </where>
    </select>

    <update id="deleteResource">
        UPDATE linkis_ps_bml_resources SET
          enable_flag = 0
        WHERE resource_id = #{resourceId} and enable_flag = 1
    </update>

    <update id="batchDeleteResources">
        UPDATE linkis_ps_bml_resources SET
        enable_flag = 0
        <where>
            enable_flag = 1
            <if test="resourceIds != null">
                AND resource_id IN
                <foreach collection="resourceIds" item="resourceId" index="index" separator="," open="("
                         close=")">
                    #{resourceId}
                </foreach>
            </if>
        </where>
    </update>

    <insert id="uploadResource" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="org.apache.linkis.bml.entity.Resource">
      INSERT INTO linkis_ps_bml_resources(<include refid="resource_columns"/>)
          VALUES (#{resourceId},#{isPrivate},#{resourceHeader},#{downloadedFileName},#{system},
                    #{createTime},#{user},#{isExpire},#{expireTime},#{maxVersion},#{updateTime},
                    #{updator},#{enableFlag})
    </insert>

    <select id="checkExists" resultType="java.lang.Integer">
        select exists(select * from `linkis_ps_bml_resources` where resource_id = #{resourceId}  and enable_flag = 1 )
    </select>

    <select id="getUserByResourceId"  resultType="java.lang.String">
        select owner from `linkis_ps_bml_resources` where resource_id = #{resourceId}
    </select>

    <update id="changeOwner">
        update `linkis_ps_bml_resources` set owner = #{newOwner} where resource_id = #{resourceId} and owner=#{oldOwner}
    </update>
</mapper>





© 2015 - 2025 Weber Informatics LLC | Privacy Policy