EmployeeMapper.xml 6.66 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.EmployeeMapper" >
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.system.model.Employee" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="employee_id" property="employeeId" jdbcType="INTEGER" />
    <result column="account_name" property="accountName" jdbcType="VARCHAR" />
    <result column="duty" property="duty" jdbcType="VARCHAR" />
    <result column="account_group" property="accountGroup"/>
    <result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
    <result column="merchant_name" property="merchantName"/>
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="is_open_card" property="isOpenCard" jdbcType="BIT" />
    <result column="photo" property="photo" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="wechat_num" property="wechatNum" jdbcType="VARCHAR" />
    <result column="customer_num" property="customerNum"/>
   	<result column="customer_count" property="customerCount"/>
   	<result column="duty_conf_key" property="dutyConfKey"/>
    <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.EmployeeDTO" extends="BaseResultMap">
  	<result column="user_id" property="userId"/>
  	<result column="login_phone" property="loginPhone"/>
  	<result column="enabled_flag" property="enabledFlag"/>
  </resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
    -->
    id, employee_id, account_name, duty,account_group, merchant_id,merchant_name, name, is_open_card, photo, phone, 
    wechat_num,customer_num,customer_count,duty_conf_key, created_by, created_date, updated_by, updated_date, deleted_flag
  </sql>
  
  <select id="list" parameterType="cn.com.glsx.dj.system.dto.EmployeeDTO" resultMap="DTOResultMap">
  	select a.id, a.employee_id, a.account_name, a.duty,a.account_group, a.merchant_id,a.merchant_name, a.name, a.is_open_card, a.photo, a.phone, 
    a.wechat_num,a.customer_num,a.customer_count,a.duty_conf_key, a.created_date, a.updated_date, b.id user_id,b.phone login_phone,b.enabled_flag
  	from dj_system_employee a
  	left join dj_system_user b on b.employee_id=a.employee_id and b.deleted_flag='N'
  	<where>
  		a.deleted_flag = 'N'
  		<if test="id != null">
  			and a.id = #{id}
  		</if>
  		<if test="employeeId != null">
  			and a.employee_id = #{employeeId}
  		</if>
  		<if test="merchantId != null">
  			and a.merchant_id = #{merchantId}
  		</if>
		<if test="merchantIdList != null and merchantIdList.size()>0">
			and  a.merchant_id in
			<foreach collection="merchantIdList" separator="," close=")" open="(" index="index" item="item">
				#{item}
			</foreach>
		</if>
  		<if test="merchantName != null and merchantName !=''">
  			and a.merchant_name like CONCAT('%',#{merchantName},'%')
  		</if>
  		<if test="name != null and name !=''">
  			and a.name like CONCAT('%',#{name},'%')
  		</if>
  		<if test="accountName != null and accountName !=''">
  			and a.account_name like CONCAT('%',#{accountName},'%')
  		</if>
  		<if test="photo != null and photo !=''">
  			and a.photo like CONCAT('%',#{photo},'%')
  		</if>
  		<if test="wechatNum != null and wechatNum !=''">
  			and a.wechat_num like CONCAT('%',#{wechatNum},'%')
  		</if>
  		<if test="isOpenCard != null">
  			and a.is_open_card = #{isOpenCard}
  		</if>
  		<if test="loginPhone != null and loginPhone!=''">
  			and b.phone = #{loginPhone}
  		</if>
  		<if test="accountGroupList != null and accountGroupList.size() > 0">
  			and a.account_group in 
  			<foreach collection="accountGroupList" index="index" item="item" open="(" separator="," close=")">
                #{item}       
        	</foreach>  
  		</if>
  		<if test="dutyConfKey != null and dutyConfKey !=''">
  			and a.duty_conf_key=#{dutyConfKey}
  		</if>
  	</where>
  	order by a.updated_date desc,a.id desc
  </select>

	<select id="listSumary" parameterType="cn.com.glsx.dj.system.dto.EmployeeDTO" resultMap="DTOResultMap">
		select b.id user_id, a.name
		from dj_system_employee a
		left join dj_system_user b on b.employee_id=a.employee_id and b.deleted_flag='N'
		<where>
			a.deleted_flag = 'N'
			<if test="id != null">
				and a.id = #{id}
			</if>
			<if test="employeeId != null">
				and a.employee_id = #{employeeId}
			</if>
			<if test="merchantId != null">
				and a.merchant_id = #{merchantId}
			</if>
			<if test="merchantIdList != null and merchantIdList.size()>0">
				and  a.merchant_id in
				<foreach collection="merchantIdList" separator="," close=")" open="(" index="index" item="item">
					#{item}
				</foreach>
			</if>
			<if test="merchantName != null and merchantName !=''">
				and a.merchant_name like CONCAT('%',#{merchantName},'%')
			</if>
			<if test="name != null and name !=''">
				and a.name like CONCAT('%',#{name},'%')
			</if>
			<if test="accountName != null and accountName !=''">
				and a.account_name like CONCAT('%',#{accountName},'%')
			</if>
			<if test="photo != null and photo !=''">
				and a.photo like CONCAT('%',#{photo},'%')
			</if>
			<if test="wechatNum != null and wechatNum !=''">
				and a.wechat_num like CONCAT('%',#{wechatNum},'%')
			</if>
			<if test="isOpenCard != null">
				and a.is_open_card = #{isOpenCard}
			</if>
			<if test="loginPhone != null and loginPhone!=''">
				and b.phone = #{loginPhone}
			</if>
			<if test="accountGroupList != null and accountGroupList.size() > 0">
				and a.account_group in
				<foreach collection="accountGroupList" index="index" item="item" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
			<if test="dutyConfKey != null and dutyConfKey !=''">
				and a.duty_conf_key=#{dutyConfKey}
			</if>
		</where>
		order by a.updated_date desc,a.id desc
	</select>
  
  <update id="updateTotalCount" parameterType="cn.com.glsx.dj.system.dto.EmployeeDTO">
  	update dj_system_employee 
  	<set>
  		<if test="customerNum != null">
  			customer_num = customer_num + #{customerNum},
  		</if>
  		<if test="customerCount != null">
  			customer_count = customer_count + #{customerCount},
  		</if>
  	</set>
  	where employee_id = #{employeeId}
  </update>
</mapper>