|
@@ -0,0 +1,117 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper
|
|
|
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+<mapper namespace="com.kgraph.graph.suport.mapper.BuildEntityRelationMapper">
|
|
|
+
|
|
|
+ <resultMap type="BuildEntityRelation" id="BuildEntityRelationResult">
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="subTaskId" column="sub_task_id" />
|
|
|
+ <result property="subEntityClassId" column="sub_entity_class_id" />
|
|
|
+ <result property="objEntityClassId" column="obj_entity_class_id" />
|
|
|
+ <result property="entityClassRelId" column="entity_class_rel_id" />
|
|
|
+ <result property="subEntity" column="sub_entity" />
|
|
|
+ <result property="objEntity" column="obj_entity" />
|
|
|
+ <result property="createBy" column="create_by" />
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
+ <result property="updateBy" column="update_by" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectBuildEntityRelationVo">
|
|
|
+ select id, sub_task_id, sub_entity_class_id, obj_entity_class_id, entity_class_rel_id, sub_entity, obj_entity, create_by, create_time, update_by, update_time from t_build_entity_relation
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectBuildEntityRelationList" parameterType="BuildEntityRelation" resultMap="BuildEntityRelationResult">
|
|
|
+ <include refid="selectBuildEntityRelationVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="subTaskId != null "> and sub_task_id = #{subTaskId}</if>
|
|
|
+ <if test="subEntityClassId != null "> and sub_entity_class_id = #{subEntityClassId}</if>
|
|
|
+ <if test="objEntityClassId != null "> and obj_entity_class_id = #{objEntityClassId}</if>
|
|
|
+ <if test="entityClassRelId != null "> and entity_class_rel_id = #{entityClassRelId}</if>
|
|
|
+ <if test="subEntity != null and subEntity != ''"> and sub_entity = #{subEntity}</if>
|
|
|
+ <if test="objEntity != null and objEntity != ''"> and obj_entity = #{objEntity}</if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectBuildEntityRelationById" parameterType="Long" resultMap="BuildEntityRelationResult">
|
|
|
+ <include refid="selectBuildEntityRelationVo"/>
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertBuildEntityRelation" parameterType="BuildEntityRelation" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into t_build_entity_relation
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="subTaskId != null">sub_task_id,</if>
|
|
|
+ <if test="subEntityClassId != null">sub_entity_class_id,</if>
|
|
|
+ <if test="objEntityClassId != null">obj_entity_class_id,</if>
|
|
|
+ <if test="entityClassRelId != null">entity_class_rel_id,</if>
|
|
|
+ <if test="subEntity != null">sub_entity,</if>
|
|
|
+ <if test="objEntity != null">obj_entity,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ <if test="updateBy != null">update_by,</if>
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="subTaskId != null">#{subTaskId},</if>
|
|
|
+ <if test="subEntityClassId != null">#{subEntityClassId},</if>
|
|
|
+ <if test="objEntityClassId != null">#{objEntityClassId},</if>
|
|
|
+ <if test="entityClassRelId != null">#{entityClassRelId},</if>
|
|
|
+ <if test="subEntity != null">#{subEntity},</if>
|
|
|
+ <if test="objEntity != null">#{objEntity},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ <if test="updateBy != null">#{updateBy},</if>
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateBuildEntityRelation" parameterType="BuildEntityRelation">
|
|
|
+ update t_build_entity_relation
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="subTaskId != null">sub_task_id = #{subTaskId},</if>
|
|
|
+ <if test="subEntityClassId != null">sub_entity_class_id = #{subEntityClassId},</if>
|
|
|
+ <if test="objEntityClassId != null">obj_entity_class_id = #{objEntityClassId},</if>
|
|
|
+ <if test="entityClassRelId != null">entity_class_rel_id = #{entityClassRelId},</if>
|
|
|
+ <if test="subEntity != null">sub_entity = #{subEntity},</if>
|
|
|
+ <if test="objEntity != null">obj_entity = #{objEntity},</if>
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteBuildEntityRelationById" parameterType="Long">
|
|
|
+ delete from t_build_entity_relation where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteBuildEntityRelationByIds" parameterType="String">
|
|
|
+ delete from t_build_entity_relation where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <select id="getClassRelationList" resultType="Map">
|
|
|
+ SELECT
|
|
|
+ tbr.id,
|
|
|
+ ecr.id relationId,
|
|
|
+ ecr.start_id startId,
|
|
|
+ ecr.end_id endId,
|
|
|
+ tbr.sub_task_id subTaskId,
|
|
|
+ ( SELECT ec.`name` FROM entity_class ec WHERE ec.id = ecr.start_id ) AS subName,
|
|
|
+ ( SELECT `name` FROM entity_class ec WHERE ec.id = ecr.end_id ) AS objName,
|
|
|
+ ecr.`name`,
|
|
|
+ tbr.sub_entity subEntity,
|
|
|
+ tbr.obj_entity objEntity
|
|
|
+ FROM
|
|
|
+ entity_class_relation ecr
|
|
|
+ LEFT JOIN t_build_entity_relation tbr ON ecr.id = tbr.entity_class_rel_id
|
|
|
+ AND ecr.start_id = tbr.sub_entity_class_id
|
|
|
+ AND ecr.end_id = tbr.obj_entity_class_id
|
|
|
+ AND tbr.sub_task_id = #{subTaskId}
|
|
|
+ </select>
|
|
|
+</mapper>
|