物联网平台 +Web 组态
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
6.5 KiB

2 years ago
<?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="UserInfo">
<!-- 新增, 并返回id -->
<insert id="insert" parameterType="com.lp.bo.UserInfoBO">
INSERT INTO user_info
(name,password,phone,email,user_key,nick_name,real_name,id_no,type,status,sex,img_id,remark,register_time,wx_open_id,validate_code,validate_time,aid)
VALUES
(#{name},#{password},#{phone},#{email},#{user_key},#{nick_name},#{real_name},#{id_no},#{type},#{status},#{sex},#{img_id},#{remark},#{register_time},#{wx_open_id},#{validate_code},#{validate_time},#{aid})
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
select id from user_info ORDER BY id desc LIMIT 1
</selectKey>
</insert>
<update id="updatePassword" parameterType="com.lp.bo.UserInfoBO">
UPDATE user_info SET password=#{password} WHERE id=#{id} AND email=#{email}
</update>
<update id="updatePasswordByKey" parameterType="com.lp.bo.UserInfoBO">
UPDATE user_info SET password=#{password} WHERE user_key=#{user_key}
</update>
<update id="updateAid" parameterType="com.lp.bo.UserInfoBO" >
UPDATE user_info SET aid=#{aid} where id=#{id}
</update>
<!-- 修改 -->
<update id="update" parameterType="com.lp.bo.UserInfoBO">
UPDATE user_info SET id=id
<if test="name!=null and name !=''">
,name=#{name}
</if>
<if test="password!=null and password !=''">
,password=#{password}
</if>
<if test="phone!=null and phone !=''">
,phone=#{phone}
</if>
<if test="wx_img_url != null and wx_img_url !=''">
,wx_img_url=#{wx_img_url}
</if>
<if test="email!=null and email !=''">
,email=#{email}
</if>
<if test="user_key!=null and user_key !=''">
,user_key=#{user_key}
</if>
<if test="nick_name!=null and nick_name !=''">
,nick_name=#{nick_name}
</if>
<if test="real_name!=null and real_name !=''">
,real_name=#{real_name}
</if>
<if test="id_no!=null and id_no !=''">
,id_no=#{id_no}
</if>
<if test="type!=null">
,type=#{type}
</if>
<if test="status!=null">
,status=#{status}
</if>
<if test="sex!=null">
,sex=#{sex}
</if>
<if test="img_id!=null">
,img_id=#{img_id}
</if>
<if test="remark!=null and remark !=''">
,remark=#{remark}
</if>
<if test="register_time!=null">
,register_time=#{register_time}
</if>
<if test="wx_open_id!=null and wx_open_id !=''">
,wx_open_id=#{wx_open_id}
</if>
<if test="wp_id !=null and wp_id !=''">
,wp_id=#{wp_id}
</if>
<if test="validate_code!=null and validate_code !=''">
,validate_code=#{validate_code}
</if>
<if test="validate_time!=null">
,validate_time=#{validate_time}
</if>
<if test="delete_flag!=null">
,delete_flag=#{delete_flag}
</if>
WHERE id=#{id}
<if test="aid !=null">
AND aid=#{aid}
</if>
</update>
<!-- 统计用户(大屏) -->
<select id="selectUserScreen" parameterType="com.lp.bo.UserInfoBO"
resultType="java.util.HashMap">
select d.`name`,u.count AS `value` from (select u.type,count(u.id) as count from user_info AS u
WHERE u.delete_flag = 0
GROUP BY u.type) as u
LEFT JOIN pro_dictionary_info AS d ON d.`code` = u.type AND d.p_dictionary_name='USER_TYPE'
ORDER BY d.`code` DESC
</select>
<!-- 检索记录 -->
<select id="selectOne" parameterType="com.lp.bo.UserInfoBO"
resultType="com.lp.bo.UserInfoBO">
<include refid="sql_select_field"/>
<include refid="sql_select_condition" />
LIMIT 1
</select>
<select id="selectOneLogin" parameterType="com.lp.bo.UserInfoBO"
resultType="com.lp.bo.UserInfoBO">
<include refid="sql_select_field"/>
WHERE o.name =#{name}
AND o.password = #{password}
AND o.delete_flag=0
LIMIT 1
</select>
<!-- 检索记录字段 -->
<sql id="sql_select_field">
SELECT o.* , ua.sms_num , ua.voice_num FROM user_info o LEFT JOIN user_account_info ua ON o.id = ua.user_id
</sql>
<sql id="sql_select_field_ADD_subacout_num">
SELECT o.* , ( SELECT COUNT(1) FROM iot_scene_user_relation ics where ics.user_id = o.id ) scene_num FROM user_info o
</sql>
<!-- 检索记录条件 -->
<sql id="sql_select_condition">
WHERE 1=1
<if test="id!=null">
AND o.id=#{id}
</if>
<if test="name!=null and name !=''">
AND o.name=#{name}
</if>
<if test="password!=null and password !=''">
AND o.password = #{password}
</if>
<if test="phone!=null and phone !=''">
AND o.phone = #{phone}
</if>
<if test="email!=null and email !=''">
AND o.email =#{email}
</if>
<if test="user_key!=null and user_key !=''">
AND o.user_key =#{user_key}
</if>
<if test="nick_name!=null and nick_name !=''">
AND o.nick_name =#{nick_name}
</if>
<if test="real_name!=null and real_name !=''">
AND o.real_name =#{real_name}
</if>
<if test="id_no!=null and id_no !=''">
AND o.id_no = #{id_no}
</if>
<if test="type!=null">
AND o.type=#{type}
</if>
<if test="status!=null">
AND o.status=#{status}
</if>
<if test="sex!=null">
AND o.sex=#{sex}
</if>
<if test="img_id!=null">
AND o.img_id=#{img_id}
</if>
<if test="remark!=null and remark !=''">
AND o.remark =#{remark}
</if>
<if test="register_time!=null">
AND o.register_time=#{register_time}
</if>
<if test="wp_id !=null and wp_id !=''">
AND o.wp_id =#{wp_id}
</if>
<if test="wx_open_id!=null and wx_open_id !=''">
AND o.wx_open_id =#{wx_open_id}
</if>
<if test="validate_code!=null and validate_code !=''">
AND o.validate_code =#{validate_code}
</if>
<if test="validate_time!=null">
AND o.validate_time=#{validate_time}
</if>
<if test="aid !=null">
AND o.aid=#{aid}
</if>
<if test="delete_flag !=null">
AND o.delete_flag =#{delete_flag}
</if>
</sql>
<select id="selects" parameterType="com.lp.bo.UserInfoBO"
resultType="com.lp.bo.UserInfoBO">
<include refid="sql_select_field" />
<include refid="sql_select_condition" />
</select>
<!-- 检索记录列表 -->
<select id="select" parameterType="com.lp.bo.UserInfoBO"
resultType="com.lp.bo.UserInfoBO">
<if test="scene_num_flag != null and scene_num_flag == 1">
<include refid="sql_select_field_ADD_subacout_num" />
</if>
<if test="scene_num_flag == null ">
<include refid="sql_select_field" />
</if>
<include refid="sql_select_condition" />
ORDER BY o.id DESC
<include refid="Base.sql_limit_condition" />
</select>
<!-- 检索记录数量 -->
<select id="selectCount" resultType="java.lang.Integer" parameterType="com.lp.bo.UserInfoBO">
SELECT COUNT(1) FROM user_info o
<include refid="sql_select_condition" />
</select>
</mapper>