<?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.huashe.park.core.mapper.PileMachineInfoMapper">

    <resultMap type="PileMachineInfo" id="PileMachineInfoResult">
        <result property="id" column="id"/>
        <result property="machineNum" column="machine_num"/>
        <result property="equipment" column="equipment"/>
        <result property="no" column="no"/>
        <result property="pwd" column="pwd"/>
        <result property="sn" column="sn"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <sql id="selectPileMachineInfoVo">
        select id,
               machine_num,
               equipment, no, pwd, sn, update_time, create_time, create_by, update_by
        from cons_pile_machine_info
    </sql>

    <select id="selectPileMachineInfoList" parameterType="PileMachineInfo" resultMap="PileMachineInfoResult">
        <include refid="selectPileMachineInfoVo"/>
        <where>
            <if test="machineNum != null  and machineNum != ''">and machine_num = #{machineNum}</if>
            <if test="equipment != null  and equipment != ''">and equipment = #{equipment}</if>
            <if test="no != null  and no != ''">and no = #{no}</if>
            <if test="pwd != null  and pwd != ''">and pwd = #{pwd}</if>
            <if test="sn != null  and sn != ''">and sn = #{sn}</if>
        </where>
    </select>

    <select id="selectPileMachineInfoById" parameterType="Long" resultMap="PileMachineInfoResult">
        <include refid="selectPileMachineInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertPileMachineInfo" parameterType="PileMachineInfo" useGeneratedKeys="true" keyProperty="id">
        insert into cons_pile_machine_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="machineNum != null and machineNum != ''">machine_num,</if>
            <if test="equipment != null and equipment != ''">equipment,</if>
            <if test="no !=null and no !='' ">no,</if>
            <if test="pwd != null and pwd != ''">pwd,</if>
            <if test="sn != null and sn != ''">sn,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="machineNum != null and machineNum != ''">#{machineNum},</if>
            <if test="equipment != null and equipment != ''">#{equipment},</if>
            <if test="no !=null and no !='' ">#{no},</if>
            <if test="pwd != null and pwd != ''">#{pwd},</if>
            <if test="sn != null and sn != ''">#{sn},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updatePileMachineInfo" parameterType="PileMachineInfo">
        update cons_pile_machine_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="machineNum != null and machineNum != ''">machine_num = #{machineNum},</if>
            <if test="equipment != null and equipment != ''">equipment = #{equipment},</if>
            <if test="no !=null and no !='' ">no = #{no},</if>
            <if test="pwd != null and pwd != ''">pwd = #{pwd},</if>
            <if test="sn != null and sn != ''">sn = #{sn},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePileMachineInfoById" parameterType="Long">
        delete
        from cons_pile_machine_info
        where id = #{id}
    </delete>

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