Select Git revision
2021-05-31-cav21.md
RelationshipMapper.xml 6.06 KiB
<?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.ic.er.dao.RelationshipMapper">
<resultMap id="BaseResultMap" type="com.ic.er.bean.entity.RelationshipDO">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="view_id" property="viewId"/>
<result column="first_entity_id" property="firstEntityId"/>
<result column="second_entity_id" property="secondEntityId"/>
<result column="first_attribute_id" property="firstAttributeId"/>
<result column="second_attribute_id" property="secondAttributeId"/>
<result column="cardinality" property="cardinality"/>
<result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
</resultMap>
<sql id="Base_Column_List">
id, name, view_id, first_entity_id, second_entity_id, first_attribute_id, second_attribute_id, cardinality
</sql>
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
id,name,view_id,first_entity_id,second_entity_id,first_attribute_id,second_attribute_id,cardinality,is_delete,gmt_create,gmt_modified
from relationship
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</select>
<select id="selectByRelationship" parameterType="com.ic.er.bean.entity.RelationshipDO" resultMap="BaseResultMap">
select
id,name,view_id,first_entity_id,second_entity_id,first_attribute_id,second_attribute_id,cardinality,is_delete,gmt_create,gmt_modified
from relationship
<where>
<if test="id != null">
and id = #{id,jdbcType=BIGINT}
</if>
<if test="name != null">
and name = #{name,jdbcType=VARCHAR}
</if>
<if test="viewId != null">
and view_id = #{viewId,jdbcType=BIGINT}
</if>
<if test="firstEntityId != null">
and first_entity_id = #{firstEntityId,jdbcType=BIGINT}
</if>
<if test="secondEntityId != null">
and second_entity_id = #{secondEntityId,jdbcType=BIGINT}
</if>
<if test="firstAttributeId != null">
and first_attribute_id = #{firstAttributeId,jdbcType=BIGINT}
</if>
<if test="secondAttributeId != null">
and second_attribute_id = #{secondAttributeId,jdbcType=BIGINT}
</if>
<if test="cardinality != null">
and cardinality = #{cardinality,jdbcType=SMALLINT}
</if>
<if test="gmtCreate != null">
and gmt_create = #{gmtCreate,jdbcType=DATETIME}
</if>
<if test="gmtModified != null">
and gmt_modified = #{gmtModified,jdbcType=DATETIME}
</if>
and is_delete = 0
</where>
</select>
<insert id="insert" parameterType="com.ic.er.bean.entity.RelationshipDO" useGeneratedKeys="true" keyProperty="id">
insert into relationship
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="viewId != null">
view_id,
</if>
<if test="firstEntityId != null">
first_entity_id,
</if>
<if test="secondEntityId != null">
second_entity_id,
</if>
<if test="firstAttributeId != null">
first_attribute_id,
</if>
<if test="secondAttributeId != null">
second_attribute_id,
</if>
<if test="cardinality != null">
cardinality,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="viewId != null">
#{viewId,jdbcType=BIGINT},
</if>
<if test="firstEntityId != null">
#{firstEntityId,jdbcType=BIGINT},
</if>
<if test="secondEntityId != null">
#{secondEntityId,jdbcType=BIGINT},
</if>
<if test="firstAttributeId != null">
#{firstAttributeId,jdbcType=BIGINT},
</if>
<if test="secondAttributeId != null">
#{secondAttributeId,jdbcType=BIGINT},
</if>
<if test="cardinality != null">
#{cardinality.value,jdbcType=SMALLINT},
</if>
</trim>
</insert>
<update id="deleteById" parameterType="java.lang.Long">
update relationship set
is_delete = 1
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</update>
<update id="updateById" parameterType="com.ic.er.bean.entity.RelationshipDO">
update relationship
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="viewId != null">
view_id = #{viewId,jdbcType=BIGINT},
</if>
<if test="firstEntityId != null">
first_entity_id = #{firstEntityId,jdbcType=BIGINT},
</if>
<if test="secondEntityId != null">
second_entity_id = #{secondEntityId,jdbcType=BIGINT},
</if>
<if test="firstAttributeId != null">
first_attribute_id = #{firstAttributeId,jdbcType=BIGINT},
</if>
<if test="secondAttributeId != null">
second_attribute_id = #{secondAttributeId,jdbcType=BIGINT},
</if>
<if test="cardinality != null">
cardinality = #{cardinality.value,jdbcType=SMALLINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT} and is_delete = 0
</update>
</mapper>