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

145 lines
6.2 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.resource.mapper.ZoneResourceDomainMapper">
<resultMap type="ZoneResourceDomain" id="ZoneResourceDomainResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="sort" column="sort"/>
<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="zoneId" column="zone_id"/>
<result property="introduction" column="introduction"/>
<result property="domainCategory" column="domain_category"/>
</resultMap>
<sql id="selectZoneResourceDomainVo">
select id,
name,
sort,
dept_id,
del_flag,
create_by,
create_time,
update_by,
update_time,
introduction,
zone_id,
domain_category
from zone_resource_domain
</sql>
<sql id="selectZoneResourceDomainAliasVo">
select zrd.id,
zrd.name,
zrd.sort,
zrd.dept_id,
zrd.del_flag,
zrd.create_by,
zrd.create_time,
zrd.update_by,
zrd.update_time,
zrd.introduction,
zrd.zone_id,
zrd.domain_category
from zone_resource_domain zrd
</sql>
<select id="selectZoneResourceDomainList" parameterType="ZoneResourceDomain" resultMap="ZoneResourceDomainResult">
<include refid="selectZoneResourceDomainAliasVo"/>
<where>
<if test="name != null and name != ''">and zrd.name like concat('%', #{name}, '%')</if>
<if test="domainCategory != null and domainCategory !=''">and zrd.domain_category = #{domainCategory}</if>
<if test="sort != null ">and zrd.sort = #{sort}</if>
<if test="deptId != null ">and zrd.dept_id = #{deptId}</if>
<if test="zoneId != null ">and zrd.zone_id = #{zoneId}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
ORDER BY sort ASC
</where>
</select>
<select id="selectZoneResourceDomainById" parameterType="Long" resultMap="ZoneResourceDomainResult">
<include refid="selectZoneResourceDomainVo"/>
where id = #{id}
</select>
<select id="selectZoneResourceDomainByNameAndZoneId"
resultType="com.microservices.zone.resource.domain.ZoneResourceDomain">
<include refid="selectZoneResourceDomainVo"/>
where name = #{name}
and zone_id = #{zoneId}
and domain_category = #{domainCategory}
</select>
<insert id="insertZoneResourceDomain" parameterType="ZoneResourceDomain" useGeneratedKeys="true" keyProperty="id">
insert into zone_resource_domain
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="sort != null">sort,</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="zoneId != null">zone_id,</if>
<if test="introduction != null">introduction,</if>
<if test="domainCategory != null">domain_category,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="sort != null">#{sort},</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="zoneId != null">#{zoneId},</if>
<if test="introduction != null">#{introduction},</if>
<if test="domainCategory != null">#{domainCategory},</if>
</trim>
</insert>
<update id="updateZoneResourceDomain" parameterType="ZoneResourceDomain">
update zone_resource_domain
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="sort != null">sort = #{sort},</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="zoneId != null">zone_id = #{zoneId},</if>
<if test="introduction != null">introduction = #{introduction},</if>
<if test="domainCategory != null">domain_category = #{domainCategory},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZoneResourceDomainById" parameterType="Long">
delete
from zone_resource_domain
where id = #{id}
</delete>
<delete id="deleteZoneResourceDomainByIds" parameterType="String">
delete from zone_resource_domain where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteZoneResourceDomainByZoneId">
delete
from zone_resource_domain
where zone_id = #{zoneId}
</delete>
</mapper>