cqyt/shapelight-admin/src/main/resources/mapper/ten/TenRoomDao.xml

428 lines
16 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="net.shapelight.modules.ten.dao.TenRoomDao">
<resultMap id="BaseResultMap" type="net.shapelight.modules.ten.entity.TenRoomEntity">
<id column="room_id" jdbcType="BIGINT" property="roomId" />
<result column="build_id" jdbcType="BIGINT" property="buildId" />
<result column="cell_id" jdbcType="BIGINT" property="cellId" />
<result column="room_number" jdbcType="INTEGER" property="roomNumber" />
<result column="room_name" jdbcType="VARCHAR" property="roomName" />
<result column="layer" jdbcType="INTEGER" property="layer" />
<result column="area" jdbcType="VARCHAR" property="area" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="person_count" jdbcType="INTEGER" property="personCount" />
<result column="room_password" jdbcType="VARCHAR" property="roomPassword" />
<result column="room_count" jdbcType="TINYINT" property="roomCount" />
<result column="living_count" jdbcType="TINYINT" property="livingCount" />
<result column="kitchen_count" jdbcType="TINYINT" property="kitchenCount" />
<result column="bath_count" jdbcType="TINYINT" property="bathCount" />
<result column="balcony_count" jdbcType="TINYINT" property="balconyCount" />
<result column="picture" jdbcType="VARCHAR" property="picture" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="last_update_by" jdbcType="VARCHAR" property="lastUpdateBy" />
<result column="last_update_time" jdbcType="TIMESTAMP" property="lastUpdateTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="delete_flag" jdbcType="TINYINT" property="deleteFlag" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="xa_sync" jdbcType="TINYINT" property="xaSync" />
<result column="p_id" jdbcType="VARCHAR" property="pId" />
<result column="dzbm" jdbcType="VARCHAR" property="dzbm" />
<association property="buildName" javaType="String"
select="net.shapelight.modules.ten.dao.TenBuildDao.getBuildName"
column="buildId=build_id,cellId=cell_id">
</association>
<association property="buildUnit" javaType="String"
select="net.shapelight.modules.ten.dao.TenBuildDao.getBuildUnit"
column="buildId=build_id,cellId=cell_id">
</association>
<association property="cellName" javaType="String"
select="net.shapelight.modules.ten.dao.TenCellDao.getCellName"
column="cellId=cell_id">
</association>
</resultMap>
<insert id="insert" parameterType="net.shapelight.modules.ten.entity.TenRoomEntity">
insert into ten_room
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roomId != null">
room_id,
</if>
<if test="buildId != null">
build_id,
</if>
<if test="cellId != null">
cell_id,
</if>
<if test="roomNumber != null">
room_number,
</if>
<if test="roomName != null">
room_name,
</if>
<if test="layer != null">
layer,
</if>
<if test="area != null">
area,
</if>
<if test="type != null">
type,
</if>
<if test="personCount != null">
person_count,
</if>
<if test="roomPassword != null">
room_password,
</if>
<if test="roomCount != null">
room_count,
</if>
<if test="livingCount != null">
living_count,
</if>
<if test="kitchenCount != null">
kitchen_count,
</if>
<if test="bathCount != null">
bath_count,
</if>
<if test="balconyCount != null">
balcony_count,
</if>
<if test="picture != null">
picture,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="lastUpdateBy != null">
last_update_by,
</if>
<if test="lastUpdateTime != null">
last_update_time,
</if>
<if test="remark != null">
remark,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="tenantId != null">
tenant_id,
</if>
<if test="xaSync != null">
xa_sync,
</if>
<if test="pId != null">
p_id,
</if>
<if test="dzbm != null">
dzbm,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="roomId != null">
#{roomId,jdbcType=BIGINT},
</if>
<if test="buildId != null">
#{buildId,jdbcType=BIGINT},
</if>
<if test="cellId != null">
#{cellId,jdbcType=BIGINT},
</if>
<if test="roomNumber != null">
#{roomNumber,jdbcType=INTEGER},
</if>
<if test="roomName != null">
#{roomName,jdbcType=VARCHAR},
</if>
<if test="layer != null">
#{layer,jdbcType=INTEGER},
</if>
<if test="area != null">
#{area,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=TINYINT},
</if>
<if test="personCount != null">
#{personCount,jdbcType=INTEGER},
</if>
<if test="roomPassword != null">
#{roomPassword,jdbcType=VARCHAR},
</if>
<if test="roomCount != null">
#{roomCount,jdbcType=TINYINT},
</if>
<if test="livingCount != null">
#{livingCount,jdbcType=TINYINT},
</if>
<if test="kitchenCount != null">
#{kitchenCount,jdbcType=TINYINT},
</if>
<if test="bathCount != null">
#{bathCount,jdbcType=TINYINT},
</if>
<if test="balconyCount != null">
#{balconyCount,jdbcType=TINYINT},
</if>
<if test="picture != null">
#{picture,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="lastUpdateBy != null">
#{lastUpdateBy,jdbcType=VARCHAR},
</if>
<if test="lastUpdateTime != null">
#{lastUpdateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=TINYINT},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=BIGINT},
</if>
<if test="xaSync != null">
#{xaSync,jdbcType=TINYINT},
</if>
<if test="pId != null">
#{pId,jdbcType=VARCHAR},
</if>
<if test="dzbm != null">
#{dzbm,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateById" parameterType="net.shapelight.modules.ten.entity.TenRoomEntity">
update ten_room
<set>
<if test="roomId != null">
room_id = #{roomId,jdbcType=BIGINT},
</if>
<if test="buildId != null">
build_id = #{buildId,jdbcType=BIGINT},
</if>
<if test="cellId != null">
cell_id = #{cellId,jdbcType=BIGINT},
</if>
<if test="roomNumber != null">
room_number = #{roomNumber,jdbcType=INTEGER},
</if>
<if test="roomName != null">
room_name = #{roomName,jdbcType=VARCHAR},
</if>
<if test="layer != null">
layer = #{layer,jdbcType=INTEGER},
</if>
<if test="area != null">
area = #{area,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=TINYINT},
</if>
<if test="personCount != null">
person_count = #{personCount,jdbcType=INTEGER},
</if>
<if test="roomPassword != null">
room_password = #{roomPassword,jdbcType=VARCHAR},
</if>
<if test="roomCount != null">
room_count = #{roomCount,jdbcType=TINYINT},
</if>
<if test="livingCount != null">
living_count = #{livingCount,jdbcType=TINYINT},
</if>
<if test="kitchenCount != null">
kitchen_count = #{kitchenCount,jdbcType=TINYINT},
</if>
<if test="bathCount != null">
bath_count = #{bathCount,jdbcType=TINYINT},
</if>
<if test="balconyCount != null">
balcony_count = #{balconyCount,jdbcType=TINYINT},
</if>
<if test="picture != null">
picture = #{picture,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="lastUpdateBy != null">
last_update_by = #{lastUpdateBy,jdbcType=VARCHAR},
</if>
<if test="lastUpdateTime != null">
last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=TINYINT},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=BIGINT},
</if>
<if test="xaSync != null">
xa_sync = #{xaSync,jdbcType=TINYINT},
</if>
<if test="pId != null">
p_id = #{pId,jdbcType=VARCHAR},
</if>
<if test="dzbm != null">
dabm = #{dzbm,jdbcType=VARCHAR},
</if>
</set>
where room_id = #{roomId,jdbcType=BIGINT}
</update>
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select * from ten_room
where room_id = #{roomId,jdbcType=BIGINT}
</select>
<delete id="deleteById">
delete from ten_room
where room_id = #{roomId,jdbcType=BIGINT}
</delete>
<delete id="logicDeleteById">
update ten_room set delete_flag = 1
where room_id = #{roomId,jdbcType=BIGINT}
</delete>
<delete id="logicDeleteByBuildId">
update ten_room set delete_flag = 1
where build_id = #{buildId,jdbcType=BIGINT}
</delete>
<delete id="logicDeleteByCellId">
update ten_room set delete_flag = 1
where cell_id = #{cellId,jdbcType=BIGINT}
</delete>
<!--<select id="findPageAll" resultMap="BaseResultMap">-->
<!--select * from ten_room_${cellId} where delete_flag = 0-->
<!--</select>-->
<select id="findPageAll" resultMap="BaseResultMap" >
<!--SELECT alias.* from (-->
<!--<foreach collection="cellIds" item="item" index="index" separator="union all">-->
<!--select * from ten_room_${item}-->
<!--</foreach>-->
<!--) alias where delete_flag = 0-->
<!--<if test="params.buildId != null and params.buildId!=''">-->
<!--and alias.build_id = #{params.buildId}-->
<!--</if>-->
<!--<if test="params.layer != null and params.layer!=''">-->
<!--and alias.layer = #{params.layer}-->
<!--</if>-->
<!--<if test="params.roomName != null and params.roomName!=''">-->
<!--and room_name like CONCAT('%', '${params.roomName}', '%')-->
<!--</if>-->
<!--<if test="params.roomNumber != null and params.roomNumber!=''">-->
<!--and room_number = #{params.roomNumber}-->
<!--</if>-->
select * from ten_room where delete_flag = 0
<if test="params.buildId != null and params.buildId!=''">
and build_id = #{params.buildId}
</if>
<if test="params.layer != null and params.layer!=''">
and layer = #{params.layer}
</if>
<if test="params.roomName != null and params.roomName!=''">
and room_name like CONCAT('%', '${params.roomName}', '%')
</if>
<if test="params.roomNumber != null and params.roomNumber!=''">
and room_number = #{params.roomNumber}
</if>
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
</select>
<select id="getAllCount" resultType="int" >
<!--SELECT count(*) from (-->
<!--<foreach collection="cellIds" item="item" index="index" separator="union all">-->
<!--select room_id from ten_room_${item} where delete_flag = 0-->
<!--<if test="params.type != null and params.type!=''">-->
<!--and type = #{params.type}-->
<!--</if>-->
<!--</foreach>-->
<!--) alias-->
select count(*) from ten_room where 1 = 1
<if test="params.type != null and params.type!=''">
and type = #{params.type}
</if>
<if test="cellIds != null">
and cell_id in
<foreach item="cellId" collection="cellIds" open="(" separator="," close=")">
#{cellId}
</foreach>
</if>
</select>
<select id="queryByNumberAndLayer" resultMap="BaseResultMap">
select * from ten_room where delete_flag = 0
and room_number = #{roomNumber} and layer = #{layer}
and build_id = #{buildId}
</select>
<select id="findByRoomName" resultMap="BaseResultMap">
select * from ten_room where delete_flag = 0
and room_name = #{roomName}
and build_id = #{buildId}
</select>
<select id="getLayerRooms" resultType="net.shapelight.modules.ten.entity.TenRoomEntity">
select * from ten_room where delete_flag = 0
and build_id = #{buildId} and layer = #{layer}
</select>
<select id="getRoomName" resultType="string">
select room_name from ten_room
where room_id = #{roomId,jdbcType=BIGINT}
</select>
<select id="getNotSync" resultType="net.shapelight.modules.ten.entity.TenRoomEntity">
select * from ten_room where delete_flag = 0
and xa_sync = 0
and cell_id = #{cellId}
and p_id is not null
</select>
</mapper>