xinelu-api/xinelu-familydoctor/src/main/resources/mapper/DeviceBindResidentMapper.xml
2023-10-09 11:18:06 +08:00

72 lines
2.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.xinelu.familydoctor.mapper.DeviceBindResidentMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBindResident">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="CHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="bindTime" column="bind_time" jdbcType="TIMESTAMP"/>
<result property="unbindTime" column="unbind_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,sn,
device_type,state,remark,
bind_time,unbind_time
</sql>
<select id="boundDevice" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from device_bind_resident
where identity = #{identity} and state = '1'
</select>
<select id="repeatBind" resultType="java.lang.Integer">
select 1 from device_bind_resident where sn = #{sn} and state = '1'
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBindResident" useGeneratedKeys="true">
insert into device_bind_resident
(identity,sn
,device_type,state,remark
,bind_time,unbind_time)
values (#{identity,jdbcType=VARCHAR},#{sn,jdbcType=VARCHAR}
,#{deviceType,jdbcType=VARCHAR},#{state,jdbcType=CHAR},#{remark,jdbcType=VARCHAR}
,#{bindTime,jdbcType=TIMESTAMP},#{unbindTime,jdbcType=TIMESTAMP})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBindResident">
update device_bind_resident
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="sn != null">
sn = #{sn,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
<if test="state != null">
state = #{state,jdbcType=CHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="bindTime != null">
bind_time = #{bindTime,jdbcType=TIMESTAMP},
</if>
<if test="unbindTime != null">
unbind_time = #{unbindTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>