Files
zxjp-web/coolstore-partner-dao/src/main/resources/mapper/RegionAreaConfigMapper.xml
2024-03-29 14:18:54 +08:00

215 lines
6.9 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.cool.store.mapper.RegionAreaConfigMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.RegionAreaConfigDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="region_id" jdbcType="BIGINT" property="regionId" />
<result column="region_path" jdbcType="VARCHAR" property="regionPath" />
<result column="want_shop_area_id" jdbcType="BIGINT" property="wantShopAreaId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
<result column="deleted" jdbcType="BIT" property="deleted" />
</resultMap>
<sql id="Base_Column_List">
id, region_id, region_path, want_shop_area_id, create_time, update_time, create_user_id, update_user_id,
deleted
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xfsg_region_area_config
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from xfsg_region_area_config
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insertSelective" parameterType="com.cool.store.entity.RegionAreaConfigDO">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into xfsg_region_area_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="regionId != null">
region_id,
</if>
<if test="regionPath != null">
region_path,
</if>
<if test="wantShopAreaId != null">
want_shop_area_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createUserId != null">
create_user_id,
</if>
<if test="updateUserId != null">
update_user_id,
</if>
<if test="deleted != null">
deleted,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="regionId != null">
#{regionId,jdbcType=BIGINT},
</if>
<if test="regionPath != null">
#{regionPath,jdbcType=VARCHAR},
</if>
<if test="wantShopAreaId != null">
#{wantShopAreaId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=VARCHAR},
</if>
<if test="updateUserId != null">
#{updateUserId,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.cool.store.entity.RegionAreaConfigDO">
update xfsg_region_area_config
<set>
<if test="regionId != null">
region_id = #{regionId,jdbcType=BIGINT},
</if>
<if test="regionPath != null">
region_path = #{regionPath,jdbcType=VARCHAR},
</if>
<if test="wantShopAreaId != null">
want_shop_area_id = #{wantShopAreaId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null">
create_user_id = #{createUserId,jdbcType=VARCHAR},
</if>
<if test="updateUserId != null">
update_user_id = #{updateUserId,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="dynamicQuery">
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="null != id">
and t.id = #{id,jdbcType=BIGINT}
</if>
<if test="null != regionId">
and t.region_id = #{regionId,jdbcType=BIGINT}
</if>
<if test="null != regionPath">
and t.region_path = #{regionPath,jdbcType=VARCHAR}
</if>
<if test="null != wantShopAreaId">
and t.want_shop_area_id = #{wantShopAreaId,jdbcType=BIGINT}
</if>
<if test="null != createTime">
and t.create_time = #{createTime,jdbcType=TIMESTAMP}
</if>
<if test="null != updateTime">
and t.update_time = #{updateTime,jdbcType=TIMESTAMP}
</if>
<if test="null != createUserId">
and t.create_user_id = #{createUserId,jdbcType=VARCHAR}
</if>
<if test="null != updateUserId">
and t.update_user_id = #{updateUserId,jdbcType=VARCHAR}
</if>
<if test="null != deleted">
and t.deleted = #{deleted,jdbcType=BIT}
</if>
</trim>
</sql>
<delete id="deleteRegionAreaConfigByRegionId">
delete from xfsg_region_area_config
where region_id = #{regionId}
</delete>
<delete id="deleteByWantShopAreaIds">
delete from xfsg_region_area_config
where want_shop_area_id in
<foreach collection="wantShopAreaIds" item="wantShopAreaId" open="(" separator="," close=")">
#{wantShopAreaId}
</foreach>
</delete>
<insert id="batchInsertOrUpdateRegionAreaConfig">
insert into xfsg_region_area_config
(
region_id,
region_path,
want_shop_area_id,
create_time,
create_user_id,
update_time,
update_user_id
)
values
<foreach collection="regionAreaConfigList" item="entity" separator=",">
(
#{entity.regionId},
#{entity.regionPath},
#{entity.wantShopAreaId},
now(),
#{entity.createUserId},
now(),
#{entity.updateUserId}
)
</foreach>
ON DUPLICATE KEY UPDATE
update_time = now()
</insert>
<select id="listAreaByRegionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xfsg_region_area_config
where region_id = #{regionId}
</select>
<select id="getByWantShopAreaId" resultType="java.lang.Long">
select region_id
from xfsg_region_area_config
where want_shop_area_id = #{wantShopAreaId}
</select>
<select id="listAreaByRegionIdList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xfsg_region_area_config
where 1 = 1
<if test="regionIdList != null and regionIdList.size >0 ">
<foreach collection="regionIdList" item="regionId" separator=" or " open="and (" close=" )">
region_path like concat('%/', #{regionId}, '/%')
</foreach>
</if>
</select>
</mapper>