<?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">
<!--  Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved. -->
<!--  文件内容由代码生成器产生，请不要手动修改！ -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-09-28 14:15:26  -->
<mapper namespace="net.northking.cctp.device.db.dao.CdPcUserDao">
  <resultMap id="BaseResultMap" type="net.northking.cctp.device.db.entity.CdPcUser">
      <!-- 主键id -->
    <id column="id" jdbcType="VARCHAR" property="id"/>
                    <!-- PC设备id -->
    <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
        <!-- windows账号 -->
    <result column="account" jdbcType="VARCHAR" property="account"/>
        <!-- windows密码 -->
    <result column="pwd" jdbcType="VARCHAR" property="pwd"/>
        <!-- 账号类型 1、管理员 2、用户 3、游客 -->
    <result column="account_type" jdbcType="VARCHAR" property="accountType"/>
    </resultMap>

  <sql id="Base_Column_List">
    id
    ,device_id
    ,account
    ,pwd
    ,account_type
  </sql>

  <sql id="Table_Name">
    ${defaultSchema}.cd_pc_user
  </sql>

  <select id="findByPrimaryKey" parameterType="String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </select>

  <select id="findByPrimaryKeys" parameterType="java.util.List">
    select
    <include refid="Base_Column_List"/>
    from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </select>

  <delete id="deleteByPrimaryKey" parameterType="String">
    delete from
    <include refid="Table_Name"/>
    where id = #{id,jdbcType=VARCHAR}
  </delete>

  <delete id="deleteByPrimaryKeys" parameterType="String">
    delete from
    <include refid="Table_Name"/>
    where id in
    <foreach collection="list" item="idItem" open="(" separator="," close=")">
      #{idItem, jdbcType=VARCHAR}
    </foreach>
  </delete>

  <delete id="deleteByExample" parameterType="net.northking.cctp.device.db.entity.CdPcUser">
    delete from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <choose>
        <when test="id != null">
          id = #{id,jdbcType=VARCHAR}
        </when>
      </choose>
              <if test="id != null">
          AND id=#{id,jdbcType=VARCHAR}
        </if>
              <if test="deviceId != null">
          AND device_id=#{deviceId,jdbcType=VARCHAR}
        </if>
              <if test="account != null">
          AND account=#{account,jdbcType=VARCHAR}
        </if>
              <if test="pwd != null">
          AND pwd=#{pwd,jdbcType=VARCHAR}
        </if>
              <if test="accountType != null">
          AND account_type=#{accountType,jdbcType=VARCHAR}
        </if>
          </trim>
  </delete>

  <insert id="insert" parameterType="net.northking.cctp.device.db.entity.CdPcUser">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="deviceId != null">
        device_id,
      </if>
      <if test="account != null">
        account,
      </if>
      <if test="pwd != null">
        pwd,
      </if>
      <if test="accountType != null">
        account_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
          #{id, jdbcType=VARCHAR},
      </if>
      <if test="deviceId != null">
          #{deviceId, jdbcType=VARCHAR},
      </if>
      <if test="account != null">
          #{account, jdbcType=VARCHAR},
      </if>
      <if test="pwd != null">
          #{pwd, jdbcType=VARCHAR},
      </if>
      <if test="accountType != null">
          #{accountType, jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="insertByBatch" parameterType="java.util.List">
    insert into
    <include refid="Table_Name"/>
    <trim prefix="(" suffix=")" suffixOverrides=",">
    id,
    device_id,
    account,
    pwd,
    account_type,
    </trim>
    values
    <foreach collection="list" item="item" index="index" separator=",">
      <trim prefix="(" suffix=")" suffixOverrides=",">
    #{item.id, jdbcType=VARCHAR},
    #{item.deviceId, jdbcType=VARCHAR},
    #{item.account, jdbcType=VARCHAR},
    #{item.pwd, jdbcType=VARCHAR},
    #{item.accountType, jdbcType=VARCHAR},
      </trim>
    </foreach>
  </insert>

  <update id="updateByPrimaryKey" parameterType="net.northking.cctp.device.db.entity.CdPcUser">
    update
    <include refid="Table_Name"/>
    <set>
      <if test="deviceId != null">
        device_id = #{deviceId, jdbcType=VARCHAR},
      </if>
      <if test="account != null">
        account = #{account, jdbcType=VARCHAR},
      </if>
      <if test="pwd != null">
        pwd = #{pwd, jdbcType=VARCHAR},
      </if>
      <if test="accountType != null">
        account_type = #{accountType, jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="query" resultMap="BaseResultMap" parameterType="net.northking.cctp.device.db.entity.CdPcUser">
    select
    <include refid="Base_Column_List" />
    from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id = #{id,jdbcType=VARCHAR}
      </if>
      <if test="deviceId != null">
        AND device_id = #{deviceId,jdbcType=VARCHAR}
      </if>
      <if test="account != null">
        AND account = #{account,jdbcType=VARCHAR}
      </if>
      <if test="pwd != null">
        AND pwd = #{pwd,jdbcType=VARCHAR}
      </if>
      <if test="accountType != null">
        AND account_type = #{accountType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

  <select id="queryCount" resultType="java.lang.Long" parameterType="net.northking.cctp.device.db.entity.CdPcUser">
    select count(*) from
    <include refid="Table_Name"/>
    <trim prefix="WHERE" prefixOverrides="AND" >
      <if test="id != null">
        AND id=#{id,jdbcType=VARCHAR}
      </if>
      <if test="deviceId != null">
        AND device_id=#{deviceId,jdbcType=VARCHAR}
      </if>
      <if test="account != null">
        AND account=#{account,jdbcType=VARCHAR}
      </if>
      <if test="pwd != null">
        AND pwd=#{pwd,jdbcType=VARCHAR}
      </if>
      <if test="accountType != null">
        AND account_type=#{accountType,jdbcType=VARCHAR}
      </if>
    </trim>
  </select>

</mapper>