工业级运维app手机api
xufenglei
2018-01-15 2e2861fd0bbba403a15a212c550bed9f8331f467
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?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>