TYehuaqiUserMapper.xml 6.19 KB
Newer Older
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
<?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.zehong.system.mapper.TYehuaqiUserMapper">
    
    <resultMap type="TYehuaqiUser" id="TYehuaqiUserResult">
        <result property="userId"    column="user_id"    />
        <result property="username"    column="username"    />
        <result property="nickName"    column="nick_name"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="userType"    column="user_type"    />
        <result property="address"    column="address"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="linkman"    column="linkman"    />
        <result property="phone"    column="phone"    />
        <result property="email"    column="email"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
        <result property="deviceNum"    column="deviceNum"    />
        <result property="zxnum"    column="zxnum"    />
    </resultMap>

    <sql id="selectTYehuaqiUserVo">
        select user_id, username, nick_name, beyond_enterprise_id, user_type, address, longitude, latitude, linkman, phone, email, create_time, update_time, is_del, remarks from t_yehuaqi_user
    </sql>

    <select id="selectTYehuaqiUserList" parameterType="TYehuaqiUser" resultMap="TYehuaqiUserResult">
        <include refid="selectTYehuaqiUserVo"/>
        <where>  
            <if test="username != null  and username != ''"> and username like concat('%', #{username}, '%')</if>
            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
        </where>
    </select>
    <select id="selectTYehuaqiUserListTwo" parameterType="TYehuaqiUser" resultMap="TYehuaqiUserResult">
          SELECT t2.zs as deviceNum,t2.zx as zxnum,t1.* FROM t_yehuaqi_user t1
          LEFT JOIN (SELECT MAX(user_id)user_id,COUNT(user_id)zs,COUNT(detector_status)zx
          FROM t_yehuaqi_device GROUP BY user_id) t2 ON t1.user_id=t2.user_id
        <where>
            <if test="userId != null  and userId != ''"> and t1.user_id = #{userId}</if>
        </where>
    </select>
    <select id="selectTYehuaqiUserById" parameterType="Long" resultMap="TYehuaqiUserResult">
        <include refid="selectTYehuaqiUserVo"/>
        where user_id = #{userId}
    </select>
        
    <insert id="insertTYehuaqiUser" parameterType="TYehuaqiUser" useGeneratedKeys="true" keyProperty="userId">
        insert into t_yehuaqi_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="username != null">username,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id,</if>
            <if test="userType != null">user_type,</if>
            <if test="address != null">address,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="linkman != null">linkman,</if>
            <if test="phone != null">phone,</if>
            <if test="email != null">email,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="username != null">#{username},</if>
            <if test="nickName != null">#{nickName},</if>
            <if test="beyondEnterpriseId != null">#{beyondEnterpriseId},</if>
            <if test="userType != null">#{userType},</if>
            <if test="address != null">#{address},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="linkman != null">#{linkman},</if>
            <if test="phone != null">#{phone},</if>
            <if test="email != null">#{email},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTYehuaqiUser" parameterType="TYehuaqiUser">
        update t_yehuaqi_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="username != null">username = #{username},</if>
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id = #{beyondEnterpriseId},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="address != null">address = #{address},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="linkman != null">linkman = #{linkman},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="email != null">email = #{email},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where user_id = #{userId}
    </update>

    <delete id="deleteTYehuaqiUserById" parameterType="Long">
        delete from t_yehuaqi_user where user_id = #{userId}
    </delete>

    <delete id="deleteTYehuaqiUserByIds" parameterType="String">
        delete from t_yehuaqi_user where user_id in 
        <foreach item="userId" collection="array" open="(" separator="," close=")">
            #{userId}
        </foreach>
    </delete>
</mapper>