<?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.deer.wms.base.system.dao.OperatorMapper">
  <resultMap id="BaseResultMap" type="com.deer.wms.base.system.model.Operator">
      <!--
         WARNING - @mbg.generated
       -->
      <id column="operator_id" jdbcType="INTEGER" property="operatorId" />
      <result column="operator_name" jdbcType="VARCHAR" property="operatorName" />
      <result column="operator_card" jdbcType="VARCHAR" property="operatorCard" />
      <result column="emp_no" jdbcType="VARCHAR" property="empNo" />
      <result column="autoverify_permission" jdbcType="INTEGER" property="autoverifyPermission" />
      <result column="back_ware_permission" jdbcType="INTEGER" property="backWarePermission" />
      <result column="combine_permission" jdbcType="INTEGER" property="combinePermission" />
      <result column="return_item_permission" jdbcType="INTEGER" property="returnItemPermission" />
      <result column="quality_check_permission" jdbcType="INTEGER" property="qualityCheckPermission" />
      <result column="scrap_permission" jdbcType="INTEGER" property="scrapPermission" />
      <result column="manual_out_permission" jdbcType="INTEGER" property="manualOutPermission" />
      <result column="transfer_warehouse_permission" jdbcType="INTEGER" property="transferWarehousePermission" />
      <result column="logout_flag" jdbcType="INTEGER" property="logoutFlag" />
      <result column="many_batch_permission" jdbcType="INTEGER" property="manyBatchPermission" />
      <result column="check_permission" jdbcType="INTEGER" property="checkPermission" />
  </resultMap>
  <select id="findByCard" parameterType="java.lang.String" resultMap="BaseResultMap">
        select * from operator where operator_card = #{card} and logout_flag = 1
  </select>
  <select id="findList" parameterType="com.deer.wms.base.system.model.OperatorCriteria" resultMap="BaseResultMap">
        select * from operator
        where 1=1
        and logout_flag = 1
        <if test="operatorCard != '' and operatorCard != null">
          and operator_card = #{operatorCard}
        </if>
        <if test="empNo != '' and empNo != null">
          and emp_no = #{empNo}
        </if>
        <if test="keyWordList != null">
            and
            <foreach collection="keyWordList" item="keyWord" index="index" open="(" separator="and" close=")">
                (operator_card LIKE binary CONCAT('%', #{keyWord}, '%')
                or emp_no LIKE binary CONCAT('%', #{keyWord}, '%')
                or operator_name LIKE binary CONCAT('%', #{keyWord}, '%')
                )
            </foreach>
        </if>
  </select>

    <select id="checkOperatorCard" parameterType="String" resultType="int">
		select count(1) from operator where operator_card = #{OperatorCard}
	</select>

    <select id="findByOperatorCard" parameterType="java.lang.String" resultMap="BaseResultMap">
        select * from operator where operator_card = #{card}
  </select>
</mapper>