<?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.zcxk.dao.UserTagMapper">
    <resultMap type="UserTagEntity" id="UserTagResult">
          <result property="id"    column="id"    />
           <result property="userId"    column="user_id"    />
           <result property="tagId"    column="tag_id"    />
           <result property="status"    column="status"    />
           <result property="dateCreate"    column="date_create"    />
           <result property="createBy"    column="create_by"    />
           <result property="dateUpdate"    column="date_update"    />
           <result property="updateBy"    column="update_by"    />
     </resultMap>
    <!--  实体栏位  --> 
    <sql id="userTagColumns">
         a.id as "id" ,
         a.user_id as "userId" ,
         a.tag_id as "tagId" ,
         a.status as "status" ,
         a.date_create as "dateCreate" ,
         a.create_by as "createBy" ,
         a.date_update as "dateUpdate" ,
         a.update_by as "updateBy" 
     </sql>
    <!--  根据主键获取实体   -->
     <select id="findUserTagById"  resultType="com.zcxk.entity.UserTagEntity" >
          SELECT 
			<include refid="userTagColumns"/>
		FROM  uims_user_tag a
		WHERE a.id = #{id} and a.status=1
    </select>
     <!--  根据获取实体List   -->
     <select id="findList" resultType="com.zcxk.entity.UserTagEntity">
		SELECT 
			<include refid="userTagColumns"/>
		FROM uims_user_tag a
		<where>
              a.status=1
              <if test="userId != null "> and a.user_id = #{userId} </if>
              <if test="tagId != null "> and a.tag_id = #{tagId} </if>
              <if test="status != null "> and a.status = #{status} </if>
              <if test="dateCreate != null "> and a.date_create = #{dateCreate} </if>
              <if test="dateUpdate != null "> and a.date_update = #{dateUpdate} </if>
		</where>
	 </select>
	  <!--  根据获取实体 page   -->
     <select id="findPage" resultType="com.zcxk.entity.UserTagEntity">
		SELECT 
			<include refid="userTagColumns"/>
		FROM uims_user_tag a
		<where>
               a.status=1
               <if test="userTag.userId != null "> and a.user_id = #{userTag.userId} </if>
               <if test="userTag.tagId != null "> and a.tag_id = #{userTag.tagId} </if>
               <if test="userTag.status != null "> and a.status = #{userTag.status} </if>
               <if test="userTag.dateCreate != null "> and a.date_create = #{userTag.dateCreate} </if>
               <if test="userTag.dateUpdate != null "> and a.date_update = #{userTag.dateUpdate} </if>
		</where>
	 </select>
</mapper>