工业级运维app手机api
xufenglei
2017-11-16 43c0f7bd6b605b2c71f58e43055144004e7d42e7
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?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.UserDao">
 
    <!--所有用户列表-->
    <select id="allUsers"  parameterType="com.moral.monitor.entity.QueryHelper" resultType="com.moral.monitor.entity.User">
        select * from user
        <where>
            <if test="search!=''">
                and name LIKE '%${search}%'
            </if>
        </where>
        limit #{offset},#{limit}
    </select>
 
    <select id="userscount"  parameterType="com.moral.monitor.entity.QueryHelper" resultType="int">
        select COUNT(id)  from user
        <where>
            <if test="search!=''">
                and name LIKE '%${search}%'
            </if>
        </where>
    </select>
 
 
 
    <!-- 删除用户-->
    <select id="deleteUser"  parameterType="String"  >
        DELETE FROM `user` WHERE id=#{id}
    </select>
 
 
    <!--列出所有用户组-->
    <select id="group" resultType="com.moral.monitor.entity.Group">
        select * from `group`
    </select>
 
    <!--添加用户-->
    <select id="adduser" parameterType="com.moral.monitor.entity.User">
        insert into `user`(name,password,organization,sex,mobile,email,weixin,user_type,nickname,create_time) VALUES(#{name},#{password},#{organization},#{sex},#{mobile},#{email},#{weixin},#{user_type},#{nickname},NOW())
    </select>
 
    <!--根据用户名查找用户-->
    <select id="finduserbymobile" parameterType="String"  resultType="com.moral.monitor.entity.User">
       select * from `user` WHERE mobile=#{mobile}
    </select>
 
 
    <!--插入groupuser表-->
    <select id="intogroupuser">
        INSERT INTO group_user(`group`,`user`) VALUES(#{0},#{1})
    </select>
 
 
    <!--根据用户id 查找 groupuser用于回显 -->
    <select id="groupuser" parameterType="int" resultType="com.moral.monitor.entity.GroupUser">
        select * from group_user WHERE user=#{id}
    </select>
 
 
    <!--修改用户信息-->
    <select id="updateuser" parameterType="com.moral.monitor.entity.User">
        update `user` set
        name=#{name},
        sex=#{sex},
        mobile=#{mobile},
        email=#{email},
        weixin=#{weixin},
       `password`=#{password},
        organization=#{organization},
        user_type=#{user_type},
        nickname=#{nickname}
        WHERE id=#{id}
    </select>
 
     <!-- 修改用户的用户组信息,先删除再插入 -->
     <select id="deletegroupuser" parameterType="int">
         DELETE FROM group_user WHERE `user`=#{userid}
     </select>
 
 
 
 
  <!--  <resultMap  type="UserEntity" id="UserResult">
        <result column="ID" jdbcType="INTEGER" property="id" />
        <result column="NAME" jdbcType="VARCHAR" property="name" />
        <result column="SEX" jdbcType="VARCHAR" property="sex" />
        <result column="MOBILE" jdbcType="VARCHAR" property="mobile" />
        <result column="EMAIL" jdbcType="VARCHAR" property="email" />
        <result column="WEIXIN" jdbcType="VARCHAR" property="weixin" />
        <result column="PASSWORD" jdbcType="VARCHAR" property="password" />
        <result column="ORGANIZATION" jdbcType="VARCHAR" property="organization" />
        <result column="USER_TYPE" jdbcType="VARCHAR" property="user_type" />
        <result column="CREATE_TIME"  property="create_time" />
        <result column="NICKNAME" jdbcType="VARCHAR" property="nickname" />
    </resultMap>
 
 
    <select id="findAllUser" resultMap="UserResult">
        select id,name,password,organization,sex,mobile,email,weixin,
        case when (user_type)= 1 then '运维人员' when (user_type)=2 then '安装人员' end,
        create_time,nickname
        from user order by id desc
    </select>
    <insert id="insertUser" parameterType="UserEntity" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO user
        <trim prefix="(" suffix=")" suffixOverrides=",">
 
            NAME,
        <if test="sex!=null">
            SEX,
        </if>
            MOBILE,
            EMAIL,
            WEIXIN,
            PASSWORD,
            ORGANIZATION,
        <if test="user_type!=null">
            USER_TYPE,
        </if>
            CREATE_TIME,
            NICKNAME
 
 
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
 
            #{name,jdbcType=VARCHAR},
        <if test="sex!=null ">
            #{sex,jdbcType=VARCHAR},
        </if>
            #{mobile,jdbcType=VARCHAR},
            #{email,jdbcType=VARCHAR},
            #{weixin,jdbcType=VARCHAR},
            #{password,jdbcType=VARCHAR},
            #{organization,jdbcType=VARCHAR},
        <if test="user_type!=null">
            #{user_type,jdbcType=VARCHAR},
        </if>
            now(),
            #{nickname,jdbcType=VARCHAR}
 
 
        </trim>
    </insert>
    <update id="updataUser" parameterType="UserEntity">
        update user set
        NAME=#{name,jdbcType=VARCHAR},
        SEX=#{sex,jdbcType=VARCHAR},
        MOBILE=#{mobile,jdbcType=VARCHAR},
        EMAIL=#{email,jdbcType=VARCHAR},
        WEIXIN=#{weixin,jdbcType=VARCHAR},
         PASSWORD=#{password,jdbcType=VARCHAR},
         ORGANIZATION=#{organization,jdbcType=VARCHAR},
         USER_TYPE=#{user_type,jdbcType=VARCHAR},
         CREATE_TIME=now(),
         NICKNAME=#{nickname,jdbcType=VARCHAR}
        WHERE ID=#{id,jdbcType=INTEGER}
 
    </update>
    <delete id="deleUser" parameterType="int">
        DELETE  FROM  user where ID=#{id,jdbcType=INTEGER}
 
    </delete>
 
 
    <select id="selectuserbyname" resultType="com.moral.monitor.entity.UserEntity" parameterType="String">
       select * from user where name=#{username}
    </select>
 
    <select id="selectUserByid" resultType="com.moral.monitor.entity.UserEntity" parameterType="int">
        select * from user where id=#{id}
    </select>
    <select id="selectCountUser" parameterType="String" resultType="int">
        select count(*)from user where name=#{name}
    </select>
    <select id="findTotalUser" resultType="int">
        select count(*) from user
 
    </select>
    <select id="PaginationUser" parameterType="int" resultMap="UserResult">
        select id,name,password,organization,sex,mobile,email,weixin,
        (case when (user_type)='1' then '安装运维人员' when (user_type)='2' then '安装人员' end)as user_type,
        create_time,nickname from user order by create_time desc limit #{0},#{1}
    </select>
 
 
-->
 
 
</mapper>