<?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.face.attachment.mapper.FaceInfoMapper">
  <resultMap id="BaseResultMap" type="com.face.attachment.entity.FaceInfo">
    <id column="face_Id" jdbcType="VARCHAR" property="faceId" />
    <result column="x" jdbcType="INTEGER" property="x" />
    <result column="y" jdbcType="INTEGER" property="y" />
    <result column="width" jdbcType="INTEGER" property="width" />
    <result column="height" jdbcType="INTEGER" property="height" />
    <result column="material_Id" jdbcType="VARCHAR" property="materialId" />
    <result column="material_Name" jdbcType="VARCHAR" property="materialName" />
    <result column="Activity_Id" jdbcType="VARCHAR" property="activityId" />
    <result column="face_url" jdbcType="VARCHAR" property="faceUrl" />
    <result column="Activity_NAME" jdbcType="VARCHAR" property="activityName" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.face.attachment.entity.FaceInfo">
    <result column="face_base" jdbcType="LONGVARBINARY" property="faceBase" />
  </resultMap>
  <sql id="Base_Column_List">
    face_Id, x, y, width, height, material_Id, material_Name, Activity_Id, face_url, 
    Activity_NAME
  </sql>
  <sql id="Blob_Column_List">
    face_base
  </sql>
  <insert id="insertForXml" parameterType="com.face.attachment.entity.FaceInfo">
    insert into t_face_info (face_Id, x, y, 
      width, height, material_Id, 
      material_Name, Activity_Id, face_url, 
      Activity_NAME, face_base)
    values (#{faceId,jdbcType=VARCHAR}, #{x,jdbcType=INTEGER}, #{y,jdbcType=INTEGER}, 
      #{width,jdbcType=INTEGER}, #{height,jdbcType=INTEGER}, #{materialId,jdbcType=VARCHAR},
      #{materialName,jdbcType=VARCHAR}, #{activityId,jdbcType=VARCHAR}, #{faceUrl,jdbcType=VARCHAR}, 
      #{activityName,jdbcType=VARCHAR}, #{faceBase,jdbcType=LONGVARBINARY})
  </insert>
  <sql id="pageAllFrom">
     from t_face_info a 
  </sql>
  <sql id="pageAllWhere">
    		<where>
			<if test="page.faceId != null and page.faceId != ''">
			 and a.face_Id=#{page.faceId}
			</if>
			<if test="page.x != null">
			 and a.x=#{page.x}
			</if>
			<if test="page.y != null">
			 and a.y=#{page.y}
			</if>
			<if test="page.width != null">
			 and a.width=#{page.width}
			</if>
			<if test="page.height != null">
			 and a.height=#{page.height}
			</if>
			<if test="page.materialId != null">
			 and a.material_Id=#{page.materialId}
			</if>
			<if test="page.materialName != null and page.materialName != ''">
			 and a.material_Name=#{page.materialName}
			</if>
			<if test="page.activityId != null and page.activityId != ''">
			 and a.Activity_Id=#{page.activityId}
			</if>
			<if test="page.faceUrl != null and page.faceUrl != ''">
			 and a.face_url=#{page.faceUrl}
			</if>
			<if test="page.activityName != null and page.activityName != ''">
			 and a.Activity_NAME=#{page.activityName}
			</if>
			<if test="page.faceBase != null">
			 and a.face_base=#{page.faceBase}
			</if>
		</where>

  </sql>
  <select id="pageAll" resultType="com.face.attachment.entity.FaceInfo">
    select * 
    <include refid="pageAllFrom" />
    <include refid="pageAllWhere" />
    		 order by a.face_Id asc 
    limit #{page.start}, #{page.pageSize}
  </select>
  <select id="pageCountAll" resultType="java.lang.Long">
    select count(*) 
    <include refid="pageAllFrom" />
    <include refid="pageAllWhere" />
  </select>

    <select id="queryAllActivity" resultType="com.face.attachment.vo.FaceInfoTxRequestVO">
        select distinct a.Activity_Id,a.Activity_NAME from t_face_info a
    </select>

    <select id="queryAllFaceInfo" resultType="com.face.attachment.entity.FaceInfo">
        select * from t_face_info a
        where 1=1
        <if test="vo != null and vo.activityId != null and vo.activityId != '' ">
            and a.Activity_Id=#{vo.activityId}
        </if>
    </select>
</mapper>