UserMapper.xml 5.25 KB
<?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="cn.com.glsx.dj.system.mapper.UserMapper" >
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.system.model.User" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="account_name" property="accountName" jdbcType="VARCHAR" />
    <result column="dj_id" property="djId"/>
    <result column="employee_id" property="employeeId" jdbcType="INTEGER" />
    <result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
    <result column="user_type" property="userType" jdbcType="TINYINT" />
    <result column="password" property="password"/>
    <result column="phone" property="phone"/>
    <result column="reg_source" property="regSource"/>
    <result column="inviter_user_id" property="inviterUserId"/>
    <result column="enabled_flag" property="enabledFlag"/>
    <result column="uuid" property="uuid"/>
    <result column="created_by" property="createdBy" jdbcType="VARCHAR" />
    <result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
    <result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
    <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
    <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
  </resultMap>
  <resultMap id="DTOResultMap" type="cn.com.glsx.dj.system.dto.UserDTO" extends="BaseResultMap">
	  <result column="channel_id" property="channelId" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
    -->
    id, account_name,dj_id, employee_id, merchant_id, user_type,password,phone,reg_source,
    inviter_user_id,enabled_flag,uuid,created_by, created_date,updated_by, updated_date, deleted_flag
  </sql>
  
  <select id="getByMerchantId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  	select <include refid="Base_Column_List"/> from dj_system_user 
  	where deleted_flag = 'N' and merchant_id = #{merchantId} and user_type != 1 limit 1
  </select>
  
  <select id="list" parameterType="cn.com.glsx.dj.system.dto.UserDTO" resultMap="DTOResultMap">
  	select a.id, a.account_name,a.dj_id, a.employee_id, a.merchant_id, a.user_type,a.phone,a.reg_source,
  	a.inviter_user_id,a.enabled_flag,a.uuid,a.created_date, b.channel_id
  	from dj_system_user a
  	left join dj_system_merchant b on b.merchant_id=a.merchant_id and b.deleted_flag = 'N'
  	<where>
  		a.deleted_flag = 'N'
  		<if test="id != null">
  			and a.id = #{id}
  		</if>
  		<if test="djId != null and djId !=''">
  			and a.dj_id = #{djId}
  		</if>
  		<if test="accountName != null and accountName !=''">
  			and a.account_name = #{accountName}
  		</if>
  		<if test="employeeId != null">
  			and a.employee_id = #{employeeId}
  		</if>
  		<if test="merchantId != null">
  			and a.merchant_id = #{merchantId}
  		</if>
  		<if test="userType != null">
  			and a.user_type = #{userType}
  		</if>
  		<if test="merchantIds != null">
  			and a.merchant_id in 
  			<foreach collection="merchantIds" index="index" item="item" open="(" separator="," close=")">
                #{item}       
        	</foreach>  
  		</if>
  		<if test="userIds != null">
  			and a.id in 
  			<foreach collection="userIds" index="index" item="item" open="(" separator="," close=")">
                #{item}       
        	</foreach>  
  		</if>
  		<if test="regSource != null and regSource !=''">
  			and a.reg_source = #{regSource}
  		</if>
  		<if test="phone != null and phone !=''">
  			and a.phone = #{phone}
  		</if>
  		<if test="channelId != null">
  			and b.channel_id = #{channelId}
  		</if>
  		<if test="enabledFlag != null and enabledFlag !=''">
  			and a.enabled_flag = #{enabledFlag}
  		</if>
  		<if test="uuid != null and uuid !=''">
  			and a.uuid = #{uuid}
  		</if>
  	</where>
  	order by a.id desc
  </select>
  
  <update id="unbindLoginPhone" parameterType="java.lang.Integer">
  	update dj_system_user set phone=null where id = #{id}
  </update>
  
  <select id="count" parameterType="cn.com.glsx.dj.system.dto.UserDTO" resultType="java.lang.Long">
  	select count(a.id) from dj_system_user a
  	<where>
  		a.deleted_flag = 'N'
  		<if test="merchantId != null">
  			and a.merchant_id = #{merchantId}
  		</if>
  		<if test="userType != null">
  			and a.user_type = #{userType}
  		</if>
  		<if test="merchantIds != null">
  			and a.merchant_id in 
  			<foreach collection="merchantIds" index="index" item="item" open="(" separator="," close=")">
                #{item}       
        	</foreach>  
  		</if>
  		<if test="regSource != null and regSource !=''">
  			and a.reg_source = #{regSource}
  		</if>
  		<if test="phone != null and phone !=''">
  			and a.phone = #{phone}
  		</if>
  		<if test="enabledFlag != null and enabledFlag !=''">
  			and a.enabled_flag = #{enabledFlag}
  		</if>
  		<if test="inviterUserId != null">
  			and a.inviter_user_id = #{inviterUserId}
  		</if>
  		<if test="startRegTime != null">
       		 <![CDATA[  and a.created_date >= #{startRegTime} ]]>
		</if>
		<if test="endRegTime != null">
       		 <![CDATA[  and a.created_date <= #{endRegTime} ]]>
		</if>
  	</where>
  </select>
</mapper>