<?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.moral.monitor.dao.ApiDao">
|
|
<select id="selectFromequipmentBymac" resultType="com.moral.monitor.entity.Equipment" parameterType="String">
|
select * from equipment where mac=#{mac}
|
</select>
|
|
<update id="updateFromequipmentBymac">
|
UPDATE equipment set `name`=#{0} , address=#{1} , longitude=#{2}, latitude=#{3} ,repairman=#{4}
|
WHERE mac=#{5}
|
</update>
|
|
<insert id="insertIntoequipment">
|
INSERT INTO equipment(`name`,address,longitude,latitude,installer,repairman,mac,time,state) VALUES(#{0},#{1},#{2},#{3},#{4},#{4},#{5},NOW(),0)
|
</insert>
|
|
|
<!--登陆-->
|
<select id="selectFromuserBynameAndpassword" resultType="com.moral.monitor.entity.User">
|
SELECT * from `user` WHERE `mobile`=#{0} AND `password`=#{1}
|
</select>
|
|
<!--修改密码-->
|
<select id="selectFromuserByidAndpassword" resultType="com.moral.monitor.entity.User">
|
SELECT * from `user` WHERE id=#{0} AND `password`=#{1}
|
</select>
|
<select id="updateuserByid">
|
UPDATE `user` set `password`=#{0} WHERE id=#{1}
|
</select>
|
|
<!--根据手机号查找用户-->
|
<select id="selectFromUserBymobile" parameterType="String" resultType="com.moral.monitor.entity.User">
|
select * from `user` WHERE mobile=#{mobile}
|
</select>
|
<!-- 保存验证码-->
|
<update id="updateusercode">
|
UPDATE `user` SET code=#{1} WHERE mobile=#{0}
|
</update>
|
|
<!--我安装的设备-->
|
<select id="selectFromequipmentByinstaller" resultType="com.moral.monitor.entity.Equipment">
|
select * from equipment WHERE installer=#{0} LIMIT #{1},#{2}
|
</select>
|
|
<!--我维修的设备-->
|
<select id="selectFromequipmentByrepairman" resultType="com.moral.monitor.entity.Equipment" parameterType="com.moral.monitor.entity.apientity.RepairQuery">
|
select * from equipment
|
|
<where>
|
<if test="1==1">
|
and repairman=#{uid}
|
</if>
|
|
<if test="type==2">
|
and state='0'
|
</if>
|
|
<if test="type==1">
|
and state IN(1,2,3)
|
</if>
|
|
<if test="key!='' and key!=null ">
|
and name like '%${key}%'
|
</if>
|
|
<if test="true">
|
LIMIT #{pageIndex},#{pageSize}
|
</if>
|
</where>
|
</select>
|
|
|
<!--设备详情-->
|
<select id="selectFromequipmentByid" resultType="com.moral.monitor.entity.Equipment" parameterType="String">
|
select * from equipment WHERE id=#{id}
|
</select>
|
|
<select id="selectFromuserByid" parameterType="String" resultType="com.moral.monitor.entity.User">
|
select * from user WHERE id=#{id}
|
</select>
|
|
|
<!--上传维护记录-->
|
<insert id="insertIntoreport" >
|
insert report(repairman,mac,name,state,ext,data1,data2,create_time) VALUES(#{0},#{1},#{2},#{3},#{4},#{5},#{6},NOW())
|
</insert>
|
|
<resultMap type="com.moral.monitor.entity.apientity.Report" id="reportresult">
|
<result column="ID" property="id" />
|
<result column="MAC" property="device_mac" />
|
<result column="NAME" property="device_name" />
|
<result column="STATE" property="device_status" />
|
<result column="DATA1" property="device_data1" />
|
<result column="DATA2" property="device_data2" />
|
<result column="EXT" property="device_ext" />
|
<result column="REPAIRMAN" property="uid" />
|
<result column="CREATE_TIME" property="create_time" />
|
</resultMap>
|
<select id="selectAllfromreportByrepaiman" resultMap="reportresult">
|
select * from report
|
<where>
|
<if test="true">
|
and repairman=#{0}
|
</if>
|
|
<if test="true">
|
LIMIT #{1},#{2}
|
</if>
|
</where>
|
</select>
|
</mapper>
|