com.webank.wedatasphere.dss.server.dao.impl.projectTaxonomyMapper.xml Maven / Gradle / Ivy
<?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.dss.server.dao.ProjectTaxonomyMapper"> <sql id="project_taxonomy"> id, `name`,`description`,`creator_id`,`create_time`,`update_time` </sql> <select id="selectProjectTaxonomyByID" resultType="com.webank.wedatasphere.dss.server.entity.DWSProjectTaxonomy"> SELECT * FROM `dss_project_taxonomy` WHERE id = #{id} </select> <select id="selectProjectTaxonomyRelationByTaxonomyIdOrProjectId" resultType="com.webank.wedatasphere.dss.server.entity.DWSProjectTaxonomyRelation"> SELECT taxonomy_id as taxonomyId , project_id as projectId , creator_id as creatorId FROM `dss_project_taxonomy_relation` WHERE project_id = #{taxonomyIdOrProjectId} </select> <select id="listProjectTaxonomyByUser" resultType="com.webank.wedatasphere.dss.server.entity.DWSProjectTaxonomy"> SELECT pt.* FROM `dss_project_taxonomy` pt LEFT JOIN dss_user bdu ON pt.creator_id = bdu.id WHERE pt.creator_id = - 1 OR bdu.`name` = #{userName} </select> <select id="listProjectIDByTaxonomyID" resultType="Long"> SELECT ptr.project_id FROM `dss_project_taxonomy_relation` ptr LEFT JOIN dss_user bdu ON ptr.creator_id = bdu.id WHERE ptr.taxonomy_id = #{taxonomyID} AND bdu.`name` = #{userName} </select> <insert id="insertProjectTaxonomy" useGeneratedKeys="true" keyProperty="id" parameterType="com.webank.wedatasphere.dss.server.entity.DWSProjectTaxonomy"> INSERT INTO dss_project_taxonomy (<include refid = "project_taxonomy" />) VALUES (#{id},#{name},#{description},#{creatorID},#{createTime},#{updateTime}) </insert> <update id="updateProjectTaxonomy" parameterType="com.webank.wedatasphere.dss.server.entity.DWSProjectTaxonomy"> UPDATE dss_project_taxonomy <trim prefix="set" suffixOverrides=","> <if test="name != null">name=#{name},</if> <if test="description != null">description=#{description},</if> <if test="updateTime != null">update_time=#{updateTime},</if> </trim> WHERE id =#{id} </update> <select id="hasProjects" resultType="Long"> select count(*) from dss_project_taxonomy_relation ptr WHERE ptr.taxonomy_id = #{projectTaxonomyID} </select> <delete id="deleteProjectTaxonomy"> DELETE FROM dss_project_taxonomy WHERE id = #{projectTaxonomyID} </delete> <insert id="addProjectTaxonomyRelation"> INSERT INTO dss_project_taxonomy_relation VALUES (#{taxonomyID},#{projectID},#{creatorID}) </insert> <update id="updateProjectTaxonomyRelation"> UPDATE dss_project_taxonomy_relation set taxonomy_id = #{taxonomyID} WHERE project_id = #{projectID} </update> <delete id="deleteProjectTaxonomyRelationByProjectID"> DELETE FROM dss_project_taxonomy_relation WHERE project_id = #{projectID} </delete> </mapper>