197 lines
7.6 KiB
XML
197 lines
7.6 KiB
XML
<?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.landaiqing.subject.infra.basic.mapper.SubjectMappingDao">
|
|
|
|
<resultMap type="com.landaiqing.subject.infra.basic.entity.SubjectMapping" id="SubjectMappingMap">
|
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
|
<result property="subjectId" column="subject_id" jdbcType="INTEGER"/>
|
|
<result property="categoryId" column="category_id" jdbcType="INTEGER"/>
|
|
<result property="labelId" column="label_id" jdbcType="INTEGER"/>
|
|
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
|
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
|
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
|
|
</resultMap>
|
|
|
|
<!--查询单个-->
|
|
<select id="queryById" resultMap="SubjectMappingMap">
|
|
select id,subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted
|
|
from subject_mapping
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<!--查询指定行数据-->
|
|
<select id="queryAllByLimit" resultMap="SubjectMappingMap">
|
|
select
|
|
id,subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted
|
|
from subject_mapping
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="subjectId != null">
|
|
and subject_id = #{subjectId}
|
|
</if>
|
|
<if test="categoryId != null">
|
|
and category_id = #{categoryId}
|
|
</if>
|
|
<if test="labelId != null">
|
|
and label_id = #{labelId}
|
|
</if>
|
|
<if test="createdBy != null and createdBy != ''">
|
|
and created_by = #{createdBy}
|
|
</if>
|
|
<if test="createdTime != null">
|
|
and created_time = #{createdTime}
|
|
</if>
|
|
<if test="updateBy != null and updateBy != ''">
|
|
and update_by = #{updateBy}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
and update_time = #{updateTime}
|
|
</if>
|
|
<if test="isDeleted != null">
|
|
and is_deleted = #{isDeleted}
|
|
</if>
|
|
</where>
|
|
limit #{pageable.offset}, #{pageable.pageSize}
|
|
</select>
|
|
|
|
<!--统计总行数-->
|
|
<select id="count" resultType="java.lang.Long">
|
|
select count(1)
|
|
from subject_mapping
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="subjectId != null">
|
|
and subject_id = #{subjectId}
|
|
</if>
|
|
<if test="categoryId != null">
|
|
and category_id = #{categoryId}
|
|
</if>
|
|
<if test="labelId != null">
|
|
and label_id = #{labelId}
|
|
</if>
|
|
<if test="createdBy != null and createdBy != ''">
|
|
and created_by = #{createdBy}
|
|
</if>
|
|
<if test="createdTime != null">
|
|
and created_time = #{createdTime}
|
|
</if>
|
|
<if test="updateBy != null and updateBy != ''">
|
|
and update_by = #{updateBy}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
and update_time = #{updateTime}
|
|
</if>
|
|
<if test="isDeleted != null">
|
|
and is_deleted = #{isDeleted}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="queryDistinctLabelId" resultMap="SubjectMappingMap">
|
|
select
|
|
distinct label_id
|
|
from subject_mapping
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="subjectId != null">
|
|
and subject_id = #{subjectId}
|
|
</if>
|
|
<if test="categoryId != null">
|
|
and category_id = #{categoryId}
|
|
</if>
|
|
<if test="labelId != null">
|
|
and label_id = #{labelId}
|
|
</if>
|
|
<if test="createdBy != null and createdBy != ''">
|
|
and created_by = #{createdBy}
|
|
</if>
|
|
<if test="createdTime != null">
|
|
and created_time = #{createdTime}
|
|
</if>
|
|
<if test="updateBy != null and updateBy != ''">
|
|
and update_by = #{updateBy}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
and update_time = #{updateTime}
|
|
</if>
|
|
<if test="isDeleted != null">
|
|
and is_deleted = #{isDeleted}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!--新增所有列-->
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
insert into subject_mapping(subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted)
|
|
values (#{subjectId},#{categoryId},#{labelId},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
|
|
</insert>
|
|
|
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into subject_mapping(subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.subjectId},#{entity.categoryId},#{entity.labelId},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into subject_mapping(subject_id,category_id,label_id,created_by,created_time,update_by,update_time,is_deleted)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.subjectId},#{entity.categoryId},#{entity.labelId},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
|
|
</foreach>
|
|
on duplicate key update
|
|
subject_id = values(subject_id)category_id = values(category_id)label_id = values(label_id)created_by =
|
|
values(created_by)created_time = values(created_time)update_by = values(update_by)update_time =
|
|
values(update_time)is_deleted = values(is_deleted)
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
update subject_mapping
|
|
<set>
|
|
<if test="subjectId != null">
|
|
subject_id = #{subjectId},
|
|
</if>
|
|
<if test="categoryId != null">
|
|
category_id = #{categoryId},
|
|
</if>
|
|
<if test="labelId != null">
|
|
label_id = #{labelId},
|
|
</if>
|
|
<if test="createdBy != null and createdBy != ''">
|
|
created_by = #{createdBy},
|
|
</if>
|
|
<if test="createdTime != null">
|
|
created_time = #{createdTime},
|
|
</if>
|
|
<if test="updateBy != null and updateBy != ''">
|
|
update_by = #{updateBy},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time = #{updateTime},
|
|
</if>
|
|
<if test="isDeleted != null">
|
|
is_deleted = #{isDeleted},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
delete
|
|
from subject_mapping
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
</mapper>
|
|
|