<?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">
<!--suppress ALL -->
<mapper namespace="com.xhpc.card.mapper.TIccardDeviceMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.card.pojo.TIccardDevice">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="devName" jdbcType="VARCHAR" property="devname"/>
        <result column="devType" jdbcType="VARCHAR" property="devtype"/>
        <result column="serialNumber" jdbcType="VARCHAR" property="serialnumber"/>
        <result column="corpIndex" jdbcType="INTEGER" property="corpindex"/>
        <result column="createTime" jdbcType="TIMESTAMP" property="createtime"/>
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , devName, devType, serialNumber, corpIndex, createTime, tenant_id, type
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_iccard_device
        where id = #{id,jdbcType=INTEGER}
    </select>
    <select id="selectAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_iccard_device
        where del_flag = 0
    </select>
    <select id="selectDeletedStatusByDeviceId" resultType="com.xhpc.card.pojo.TIccardDevice">
        select
        <include refid="Base_Column_List"/>
        from t_iccard_device
        where del_flag = 1 and id = #{deviceId}
    </select>
    <select id="selectAllByPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_iccard_device
        where del_flag = 0
        limit #{currentPage},#{items}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from t_iccard_device
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardDevice"
            useGeneratedKeys="true">
        insert into t_iccard_device (devName, devType, serialNumber,
                                     corpIndex, createTime, tenant_id)
        values (#{devname,jdbcType=VARCHAR}, #{devtype,jdbcType=VARCHAR}, #{serialnumber,jdbcType=VARCHAR},
                #{corpindex,jdbcType=INTEGER}, #{createtime,jdbcType=TIMESTAMP}, #{tenantId,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardDevice"
            useGeneratedKeys="true">
        insert into t_iccard_device
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="devname != null">
                devName,
            </if>
            <if test="devtype != null">
                devType,
            </if>
            <if test="serialnumber != null">
                serialNumber,
            </if>
            <if test="corpindex != null">
                corpIndex,
            </if>
            <if test="createtime != null">
                createTime,
            </if>
            <if test="tenantId != null">
                tenant_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="devname != null">
                #{devname,jdbcType=VARCHAR},
            </if>
            <if test="devtype != null">
                #{devtype,jdbcType=VARCHAR},
            </if>
            <if test="serialnumber != null">
                #{serialnumber,jdbcType=VARCHAR},
            </if>
            <if test="corpindex != null">
                #{corpindex,jdbcType=INTEGER},
            </if>
            <if test="createtime != null">
                #{createtime,jdbcType=TIMESTAMP},
            </if>
            <if test="tenantId != null">
                #{tenantId,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.TIccardDevice">
        update t_iccard_device
        <set>
            <if test="devname != null">
                devName = #{devname,jdbcType=VARCHAR},
            </if>
            <if test="devtype != null">
                devType = #{devtype,jdbcType=VARCHAR},
            </if>
            <if test="serialnumber != null">
                serialNumber = #{serialnumber,jdbcType=VARCHAR},
            </if>
            <if test="corpindex != null">
                corpIndex = #{corpindex,jdbcType=INTEGER},
            </if>
            <if test="createtime != null">
                createTime = #{createtime,jdbcType=TIMESTAMP},
            </if>
            <if test="tenantId != null">
                tenant_id = #{tenantId,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.TIccardDevice">
        update t_iccard_device
        set devName      = #{devname,jdbcType=VARCHAR},
            devType      = #{devtype,jdbcType=VARCHAR},
            serialNumber = #{serialnumber,jdbcType=VARCHAR},
            corpIndex    = #{corpindex,jdbcType=INTEGER},
            createTime   = #{createtime,jdbcType=TIMESTAMP},
            tenant_id    = #{tenantId,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateCardDeviceStatusIsDel">
        update t_iccard_device
        set del_flag = 1
        where id = #{deviceId}
    </update>
</mapper>