mappers.TemplateEntityMapper.xml Maven / Gradle / Ivy
The newest version!
<?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.inlong.manager.dao.mapper.TemplateEntityMapper"> <resultMap id="BaseResultMap" type="org.apache.inlong.manager.dao.entity.TemplateEntity"> <id column="id" jdbcType="INTEGER" property="id"/> <result column="name" jdbcType="VARCHAR" property="name"/> <result column="in_charges" jdbcType="VARCHAR" property="inCharges"/> <result column="visible_range" jdbcType="VARCHAR" property="visibleRange"/> <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/> <result column="creator" jdbcType="VARCHAR" property="creator"/> <result column="modifier" jdbcType="VARCHAR" property="modifier"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/> <result column="version" jdbcType="INTEGER" property="version"/> </resultMap> <sql id="Base_Column_List"> id, name, in_charges, visible_range, is_deleted, creator, modifier, create_time, modify_time, version </sql> <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="org.apache.inlong.manager.dao.entity.TemplateEntity"> insert into template (id, name, in_charges, visible_range, creator, modifier) values (#{id, jdbcType=INTEGER}, #{name, jdbcType=VARCHAR}, #{inCharges, jdbcType=VARCHAR}, #{visibleRange, jdbcType=VARCHAR}, #{creator, jdbcType=VARCHAR}, #{modifier, jdbcType=VARCHAR}) </insert> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from template where id = #{id,jdbcType=INTEGER} and is_deleted = 0 </select> <select id="selectByName" parameterType="java.lang.String" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from template where name = #{name,jdbcType=VARCHAR} and is_deleted = 0 </select> <select id="selectByCondition" parameterType="org.apache.inlong.manager.pojo.stream.TemplatePageRequest" resultType="org.apache.inlong.manager.dao.entity.TemplateEntity"> <bind name="_isInlongService" value="LoginUser.InlongService"/> select <include refid="Base_Column_List"/> from template t <where> t.is_deleted = 0 <if test="name != null"> and t.name = #{name,jdbcType=VARCHAR} </if> <if test="inCharges != null"> and t.in_charges = #{inCharges,jdbcType=VARCHAR} </if> and (t.visible_range = "ALL" or (t.visible_range = "IN_CHARGE" and find_in_set(#{currentUser, jdbcType=VARCHAR}, t.in_charges)) or (t.visible_range = "TENANT" and #{tenant, jdbcType=VARCHAR} in (select tet.tenant from tenant_template tet where tet.template_name = t.name and tet.is_deleted=0 )) ) <if test="visibleRange != null"> and t.visible_range = #{visibleRange,jdbcType=VARCHAR} </if> </where> order by t.modify_time desc </select> <update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.TemplateEntity"> update template <set> <if test="name != null"> name = #{name,jdbcType=VARCHAR}, </if> <if test="inCharges != null"> in_charges = #{inCharges,jdbcType=VARCHAR}, </if> <if test="visibleRange != null"> visible_range = #{visibleRange,jdbcType=VARCHAR}, </if> <if test="isDeleted != null"> is_deleted = #{isDeleted,jdbcType=INTEGER}, </if> <if test="modifier != null"> modifier = #{modifier,jdbcType=VARCHAR}, </if> version = #{version,jdbcType=INTEGER} + 1 </set> where id = #{id,jdbcType=INTEGER} and version = #{version,jdbcType=INTEGER} </update> </mapper>