PropertyUserMapper.xml 2.91 KB
<?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="PropertyUserV1ServiceDaoImpl">

    <insert id="savePropertyUser" parameterType="com.java110.po.property.PropertyUserPo">
        INSERT INTO property_user(user_id, name, tel, work_type, role, status, device_id, store_id, community_id, create_time, update_time)
        VALUES(#{userId}, #{name}, #{tel}, #{workType}, #{role}, #{status}, #{deviceId}, #{storeId}, #{communityId}, NOW(), NOW())
    </insert>

    <update id="updatePropertyUser" parameterType="com.java110.po.property.PropertyUserPo">
        UPDATE property_user
        <set>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="tel != null and tel != ''">tel = #{tel},</if>
            <if test="workType != null and workType != ''">work_type = #{workType},</if>
            <if test="role != null and role != ''">role = #{role},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
            <if test="communityId != null and communityId != ''">community_id = #{communityId},</if>
            update_time = NOW()
        </set>
        WHERE user_id = #{userId}
    </update>

    <delete id="deletePropertyUser" parameterType="com.java110.po.property.PropertyUserPo">
        DELETE FROM property_user WHERE user_id = #{userId}
    </delete>

    <select id="queryPropertyUsers" parameterType="map" resultType="map">
        SELECT * FROM property_user WHERE 1=1
        <if test="userId != null and userId != ''">AND user_id = #{userId}</if>
        <if test="workType != null and workType != ''">AND work_type = #{workType}</if>
        <if test="status != null and status != ''">AND status = #{status}</if>
        <if test="name != null and name != ''">AND name LIKE CONCAT('%', #{name}, '%')</if>
        <if test="tel != null and tel != ''">AND tel = #{tel}</if>
        <if test="storeId != null and storeId != ''">AND store_id = #{storeId}</if>
        ORDER BY create_time DESC
        <if test="page != null and page != '' and row != null and row != ''">
            LIMIT #{page}, #{row}
        </if>
    </select>

    <select id="queryPropertyUsersCount" parameterType="map" resultType="map">
        SELECT COUNT(1) count FROM property_user WHERE 1=1
        <if test="userId != null and userId != ''">AND user_id = #{userId}</if>
        <if test="workType != null and workType != ''">AND work_type = #{workType}</if>
        <if test="status != null and status != ''">AND status = #{status}</if>
        <if test="name != null and name != ''">AND name LIKE CONCAT('%', #{name}, '%')</if>
        <if test="tel != null and tel != ''">AND tel = #{tel}</if>
        <if test="storeId != null and storeId != ''">AND store_id = #{storeId}</if>
    </select>

</mapper>