microservices/microservices-modules/microservices-modules-zone/src/main/resources/mapper/zone/ZoneObjectDictMapper.xml

193 lines
8.5 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.microservices.zone.extension.mapper.ZoneObjectDictMapper">
<resultMap type="com.microservices.zone.extension.domain.ZoneObjectDict" id="ZoneObjectDictResult">
<result property="id" column="id"/>
<result property="objectType" column="object_type"/>
<result property="objectId" column="object_id"/>
<result property="dictType" column="dict_type"/>
<result property="dictValue" column="dict_value"/>
<result property="sort" column="sort"/>
<result property="zoneId" column="zone_id"/>
<result property="deptId" column="dept_id"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectZoneObjectDictVo">
select id, object_type, object_id, dict_type, dict_value,
sort, zone_id, dept_id, del_flag,
create_by, create_time, update_by, update_time, remark
from zone_object_dict
</sql>
<select id="selectZoneObjectDictList"
parameterType="com.microservices.zone.extension.domain.ZoneObjectDict"
resultMap="ZoneObjectDictResult">
<include refid="selectZoneObjectDictVo"/>
<where>
<if test="objectType != null and objectType != ''">and object_type = #{objectType}</if>
<if test="objectId != null">and object_id = #{objectId}</if>
<if test="dictType != null and dictType != ''">and dict_type = #{dictType}</if>
<if test="dictValue != null and dictValue != ''">and dict_value = #{dictValue}</if>
<if test="zoneId != null">and zone_id = #{zoneId}</if>
<if test="deptId != null">and dept_id = #{deptId}</if>
</where>
order by id desc
</select>
<select id="selectZoneObjectDictById" parameterType="Long" resultMap="ZoneObjectDictResult">
<include refid="selectZoneObjectDictVo"/>
where id = #{id}
</select>
<select id="selectByObject" resultMap="ZoneObjectDictResult">
<include refid="selectZoneObjectDictVo"/>
where object_type = #{objectType} and object_id = #{objectId}
order by dict_type asc, id asc
</select>
<select id="selectByObjectIds" resultMap="ZoneObjectDictResult">
<include refid="selectZoneObjectDictVo"/>
where object_type = #{objectType} and object_id in
<foreach collection="objectIds" item="objectId" open="(" separator="," close=")">
#{objectId}
</foreach>
order by object_id asc, dict_type asc, id asc
</select>
<select id="selectObjectIdsByDict" resultType="long">
select object_id
from zone_object_dict
where object_type = #{objectType}
and dict_type = #{dictType}
and dict_value = #{dictValue}
order by object_id asc
</select>
<insert id="insertZoneObjectDict"
parameterType="com.microservices.zone.extension.domain.ZoneObjectDict"
useGeneratedKeys="true"
keyProperty="id">
insert into zone_object_dict
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="objectType != null and objectType != ''">object_type,</if>
<if test="objectId != null">object_id,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="dictValue != null and dictValue != ''">dict_value,</if>
<if test="sort != null">sort,</if>
<if test="zoneId != null">zone_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="delFlag != null">del_flag,</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>
<if test="remark != null and remark != ''">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objectType != null and objectType != ''">#{objectType},</if>
<if test="objectId != null">#{objectId},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
<if test="sort != null">#{sort},</if>
<if test="zoneId != null">#{zoneId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="delFlag != null">#{delFlag},</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>
<if test="remark != null and remark != ''">#{remark},</if>
</trim>
</insert>
<insert id="batchInsertZoneObjectDict" parameterType="java.util.List">
insert into zone_object_dict
(object_type, object_id, dict_type, dict_value, sort, zone_id, dept_id, del_flag, create_by, create_time,
update_by, update_time, remark)
values
<foreach collection="list" item="item" separator=",">
(#{item.objectType}, #{item.objectId}, #{item.dictType}, #{item.dictValue}, #{item.sort}, #{item.zoneId},
#{item.deptId}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy},
#{item.updateTime}, #{item.remark})
</foreach>
</insert>
<update id="updateZoneObjectDict"
parameterType="com.microservices.zone.extension.domain.ZoneObjectDict">
update zone_object_dict
<trim prefix="SET" suffixOverrides=",">
<if test="objectType != null and objectType != ''">object_type = #{objectType},</if>
<if test="objectId != null">object_id = #{objectId},</if>
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="zoneId != null">zone_id = #{zoneId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="delFlag != null">del_flag = #{delFlag},</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>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZoneObjectDictById" parameterType="Long">
delete
from zone_object_dict
where id = #{id}
</delete>
<delete id="deleteZoneObjectDictByIds" parameterType="String">
delete from zone_object_dict where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteByObject">
delete
from zone_object_dict
where object_type = #{objectType}
and object_id = #{objectId}
</delete>
<select id="selectObjectIdsByDictFilters" resultType="long">
SELECT DISTINCT object_id
FROM zone_object_dict
WHERE object_type = #{objectType}
AND del_flag = '0'
<foreach collection="dictFilters" item="filter" separator="">
AND EXISTS (
SELECT 1 FROM zone_object_dict zod2
WHERE zod2.object_type = #{objectType}
AND zod2.object_id = zone_object_dict.object_id
AND zod2.dict_type = #{filter.dictType}
AND zod2.dict_value = #{filter.dictValue}
AND zod2.del_flag = '0'
)
</foreach>
ORDER BY object_id ASC
</select>
<select id="selectDictTypeNamesByTypes" resultType="java.util.Map">
select dict_type, dict_name
from sys_dict_type
where dict_type in
<foreach collection="dictTypes" item="dt" open="(" separator="," close=")">
#{dt}
</foreach>
</select>
</mapper>