Bonus-Cloud/bonus-modules/bonus-system/src/main/resources/mapper/system/AllocAreaMapper.xml

91 lines
4.5 KiB
XML
Raw Normal View History

2025-02-18 19:34:50 +08:00
<?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.bonus.system.mapper.AllocAreaMapper">
<resultMap type="com.bonus.system.domain.AllocArea" id="AllocAreaResult">
2025-02-18 19:34:50 +08:00
<result property="areaId" column="area_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="areaName" column="area_name" />
<result property="orderNum" column="order_num" />
<result property="status" column="status" />
<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" />
</resultMap>
<sql id="selectAllocAreaVo">
select area_id, parent_id, ancestors, area_name, order_num, status, del_flag, create_by, create_time, update_by, update_time from alloc_area
2025-02-18 19:34:50 +08:00
</sql>
<select id="selectAllocAreaList" parameterType="com.bonus.system.domain.AllocArea" resultMap="AllocAreaResult">
<include refid="selectAllocAreaVo"/>
2025-02-18 19:34:50 +08:00
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
2025-02-18 19:44:28 +08:00
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="areaName != null and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
2025-02-18 19:34:50 +08:00
<if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectAllocAreaByAreaId" parameterType="Long" resultMap="AllocAreaResult">
<include refid="selectAllocAreaVo"/>
2025-02-18 19:34:50 +08:00
where area_id = #{areaId}
</select>
2025-02-19 17:05:15 +08:00
<insert id="insertAllocArea" parameterType="com.bonus.system.domain.AllocArea" useGeneratedKeys="true" keyProperty="id">
insert into alloc_area
2025-02-18 19:34:50 +08:00
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaId != null">area_id,</if>
<if test="parentId != null">parent_id,</if>
2025-02-18 19:44:28 +08:00
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="areaName != null and areaName != ''">area_name,</if>
2025-02-18 19:34:50 +08:00
<if test="orderNum != null">order_num,</if>
2025-02-18 19:44:28 +08:00
<if test="status != null and status != ''">status,</if>
2025-02-18 19:34:50 +08:00
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaId != null">#{areaId},</if>
<if test="parentId != null">#{parentId},</if>
2025-02-18 19:44:28 +08:00
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="areaName != null and areaName != ''">#{areaName},</if>
2025-02-18 19:34:50 +08:00
<if test="orderNum != null">#{orderNum},</if>
2025-02-18 19:44:28 +08:00
<if test="status != null and status != ''">#{status},</if>
2025-02-18 19:34:50 +08:00
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
2025-02-18 19:44:28 +08:00
sysdate()
2025-02-18 19:34:50 +08:00
</trim>
</insert>
<update id="updateAllocArea" parameterType="com.bonus.system.domain.AllocArea">
update alloc_area
2025-02-18 19:34:50 +08:00
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
2025-02-18 19:44:28 +08:00
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
2025-02-18 19:34:50 +08:00
<if test="orderNum != null">order_num = #{orderNum},</if>
2025-02-18 19:44:28 +08:00
<if test="status != null and status != ''">status = #{status},</if>
2025-02-18 19:34:50 +08:00
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
2025-02-18 19:44:28 +08:00
sysdate()
2025-02-18 19:34:50 +08:00
</trim>
where area_id = #{areaId}
</update>
<delete id="deleteAllocAreaByAreaId" parameterType="Long">
delete from alloc_area where area_id = #{areaId}
2025-02-18 19:34:50 +08:00
</delete>
<delete id="deleteAllocAreaByAreaIds" parameterType="String">
delete from alloc_area where area_id in
2025-02-18 19:34:50 +08:00
<foreach item="areaId" collection="array" open="(" separator="," close=")">
#{areaId}
</foreach>
</delete>
</mapper>