<?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.fjs.scenic.mapper.user.LinkManMapper">
  <resultMap id="BaseResultMap" type="com.fjs.scenic.entity.user.LinkMan">
    <constructor>
      <idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="name" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="phone" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="id_card" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="face_url" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="is_delete" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="is_defalt" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="user_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="type" javaType="java.lang.String" jdbcType="VARCHAR" />
    </constructor>
  </resultMap>
  
  	<resultMap id="BaseResultMap2" type="com.fjs.scenic.entity.user.LinkMan">
			<id property="id" column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
			<result property="name" column="name" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="phone" column="phone" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="idCard" column="id_card" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="faceUrl" column="face_url" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="isDelete" column="is_delete" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="isDefalt" column="is_defalt" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="userId" column="user_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
		     <result property="type" column="type" javaType="java.lang.String" jdbcType="VARCHAR" />
		     <result property="createTime" column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
	</resultMap>
	
  <sql id="Base_Column_List">
    id, name, phone, id_card, face_url, is_delete, is_defalt, user_id, type,create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from link_man
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from link_man
    where id = #{id,jdbcType=INTEGER} AND DATE_ADD(create_time,INTERVAL 180 DAY) &lt; NOW()
  </delete>
  <insert id="insert" parameterType="com.fjs.scenic.entity.user.LinkMan">
    insert into link_man (id, name, phone, 
      id_card, face_url, is_delete, 
      is_defalt, user_id, type
      )
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, 
      #{idCard,jdbcType=VARCHAR}, #{faceUrl,jdbcType=VARCHAR}, #{isDelete,jdbcType=VARCHAR}, 
      #{isDefalt,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.fjs.scenic.entity.user.LinkMan">
    insert into link_man
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="phone != null">
        phone,
      </if>
      <if test="idCard != null">
        id_card,
      </if>
      <if test="faceUrl != null">
        face_url,
      </if>
      <if test="isDelete != null">
        is_delete,
      </if>
      <if test="isDefalt != null">
        is_defalt,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="phone != null">
        #{phone,jdbcType=VARCHAR},
      </if>
      <if test="idCard != null">
        #{idCard,jdbcType=VARCHAR},
      </if>
      <if test="faceUrl != null">
        #{faceUrl,jdbcType=VARCHAR},
      </if>
      <if test="isDelete != null">
        #{isDelete,jdbcType=VARCHAR},
      </if>
      <if test="isDefalt != null">
        #{isDefalt,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
		#{createTime,jdbcType=TIMESTAMP},
	  </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.fjs.scenic.entity.user.LinkMan">
    update link_man
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="phone != null">
        phone = #{phone,jdbcType=VARCHAR},
      </if>
      <if test="idCard != null">
        id_card = #{idCard,jdbcType=VARCHAR},
      </if>
      <if test="faceUrl != null">
        face_url = #{faceUrl,jdbcType=VARCHAR},
      </if>
      <if test="isDelete != null">
        is_delete = #{isDelete,jdbcType=VARCHAR},
      </if>
      <if test="isDefalt != null">
        is_defalt = #{isDefalt,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fjs.scenic.entity.user.LinkMan">
    update link_man
    set name = #{name,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=VARCHAR},
      id_card = #{idCard,jdbcType=VARCHAR},
      face_url = #{faceUrl,jdbcType=VARCHAR},
      is_delete = #{isDelete,jdbcType=VARCHAR},
      is_defalt = #{isDefalt,jdbcType=VARCHAR},
      user_id = #{userId,jdbcType=INTEGER},
      type = #{type,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <delete id="delete" parameterType="com.fjs.scenic.entity.user.LinkMan">
		delete from link_man where 1=1
		<if test="id != null"> and id = #{id}</if>
		<if test="name != null">
         and name = #{name,jdbcType=VARCHAR}
      </if>
      <if test="phone != null">
         and phone = #{phone,jdbcType=VARCHAR}
      </if>
      <if test="idCard != null">
         and id_card = #{idCard,jdbcType=VARCHAR}
      </if>
      <if test="faceUrl != null">
         and face_url = #{faceUrl,jdbcType=VARCHAR}
      </if>
      <if test="isDelete != null">
         and is_delete = #{isDelete,jdbcType=VARCHAR}
      </if>
      <if test="isDefalt != null">
         and is_defalt = #{isDefalt,jdbcType=VARCHAR}
      </if>
      <if test="userId != null">
         and user_id = #{userId,jdbcType=INTEGER}
      </if>
      <if test="type != null">
         and type = #{type,jdbcType=VARCHAR}
      </if>
	</delete>

	<select id="select" resultMap="BaseResultMap2" parameterType="com.fjs.scenic.entity.user.LinkMan">
		select <include refid="Base_Column_List" /> from link_man where 1 = 1
		<if test="id != null"> and id = #{id}</if>
		<if test="name != null">
         and name = #{name,jdbcType=VARCHAR}
      </if>
      <if test="phone != null">
         and phone = #{phone,jdbcType=VARCHAR}
      </if>
      <if test="idCard != null">
         and id_card = #{idCard,jdbcType=VARCHAR}
      </if>
      <if test="faceUrl != null">
         and face_url = #{faceUrl,jdbcType=VARCHAR}
      </if>
      <if test="isDelete != null">
         and is_delete = #{isDelete,jdbcType=VARCHAR}
      </if>
      <if test="isDefalt != null">
         and is_defalt = #{isDefalt,jdbcType=VARCHAR}
      </if>
      <if test="userId != null">
         and user_id = #{userId,jdbcType=INTEGER}
      </if>
      <if test="type != null">
         and type = #{type,jdbcType=VARCHAR}
      </if>
	</select>
	
	<update id="updateByParam" parameterType="java.util.Map">
		<if test="param != null and param !=''">update link_man set ${param}</if>
	</update>
	
	<select id="selectByParam" resultMap="BaseResultMap"
		parameterType="java.util.Map">
		select
		<if test="field != null and field != ''"> ${field}</if>
		<if test="field == null or field == ''"> <include refid="Base_Column_List" /> </if>
		from link_man
		<if test="param != null and param != ''">where ${param}</if>
	</select>
	
	<select id="getLinkManCount" resultType="int">
		SELECT COUNT(1) FROM link_man WHERE user_id=#{userId,jdbcType=INTEGER}
	</select>
</mapper>