PhoneLogMapper.xml 6.23 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.runsa.portal.base.dao.PhoneLogMapper" >
  <resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.PhoneLog" >
    <id column="eplId" property="id" jdbcType="INTEGER" />
    <result column="emPhone" property="emphone" jdbcType="VARCHAR" />
    <result column="eplType" property="type" jdbcType="INTEGER" />
    <result column="eplStatus" property="status" jdbcType="INTEGER" />
    <result column="emType" property="emType" jdbcType="INTEGER" />
    <result column="ptUpTime" property="uptime" jdbcType="TIMESTAMP" />
    <result column="ptUpdater" property="updater" jdbcType="INTEGER" />
    <result column="ptUpdater" property="updater" jdbcType="INTEGER" />
    <result column="ptUpdaterName" property="updaterName" jdbcType="INTEGER" />
    <association property="employee" javaType="cn.runsa.portal.base.entity.Employee">
    	<id column="plId" property="id" />
    	<result column="emName" property="name"/>
    	<result column="emCode" property="code"/>
    </association>
    <association property="corp" javaType="cn.runsa.portal.base.entity.Corp">
    	<id column="coId" property="id" />
    	<result column="coName" property="name"/>
    </association>
    <association property="dept" javaType="cn.runsa.portal.base.entity.Dept">
    	<id column="deId" property="id" />
    	<result column="deName" property="name"/>
    </association>
    <association property="post" javaType="cn.runsa.portal.base.entity.Post">
    	<id column="poId" property="id" />
    	<result column="poName" property="name"/>
    </association>
  </resultMap>
  <sql id="Base_Column_List" >
    eplId, emPhone, eplType, eplStatus, ptUpTime, ptUpdater
  </sql>
  <select id="selectByEmPhone" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from smPhoneLog
    where emPhone = #{emPhone,jdbcType=VARCHAR}
    AND eplStatus=1 
	ORDER BY ptUpTime DESC 
	LIMIT 1
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from smPhoneLog
    where eplId = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="cn.runsa.portal.base.entity.PhoneLog" >
    <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into smPhoneLog (emPhone, eplType, eplStatus, 
      ptUpTime, ptUpdater)
    values (#{emphone,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, 
      #{uptime,jdbcType=TIMESTAMP}, #{updater,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.portal.base.entity.PhoneLog" >
    <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into smPhoneLog
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="emphone != null" >
        emPhone,
      </if>
      <if test="type != null" >
        eplType,
      </if>
      <if test="status != null" >
        eplStatus,
      </if>
      <if test="uptime != null" >
        ptUpTime,
      </if>
      <if test="updater != null" >
        ptUpdater,
      </if>
      <if test="plId != null" >
        plId,
      </if>
      <if test="emType != null" >
        emType,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="emphone != null" >
        #{emphone,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        #{type,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        #{status,jdbcType=INTEGER},
      </if>
      <if test="uptime != null" >
        #{uptime,jdbcType=TIMESTAMP},
      </if>
      <if test="updater != null" >
        #{updater,jdbcType=INTEGER},
      </if>
       <if test="plId != null" >
        #{plId,jdbcType=INTEGER},
      </if>
      <if test="emType != null" >
        #{emType,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateSelective" parameterType="cn.runsa.portal.base.entity.PhoneLog" >
    update smPhoneLog
    <set >
      <if test="emphone != null" >
        emPhone = #{emphone,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        eplType = #{type,jdbcType=INTEGER},
      </if>
      <if test="status != null" >
        eplStatus = #{status,jdbcType=INTEGER},
      </if>
      <if test="uptime != null" >
        ptUpTime = #{uptime,jdbcType=TIMESTAMP},
      </if>
      <if test="updater != null" >
        ptUpdater = #{updater,jdbcType=INTEGER},
      </if>
    </set>
    where eplId = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.portal.base.entity.PhoneLog" >
    update smPhoneLog
    set emPhone = #{emphone,jdbcType=VARCHAR},
      eplType = #{type,jdbcType=INTEGER},
      eplStatus = #{status,jdbcType=INTEGER},
      ptUpTime = #{uptime,jdbcType=TIMESTAMP},
      ptUpdater = #{updater,jdbcType=INTEGER}
    where eplId = #{id,jdbcType=INTEGER}
  </update>
  <select id="findList" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.PhoneLog" >
    select 
     ph.eplId, ph.emPhone, ph.eplType, ph.eplStatus, ph.ptUpTime, ph.ptUpdater,em.emName as ptUpdaterName
    from 
    smPhoneLog ph
	LEFT JOIN mtEmployee em ON ph.ptUpdater = em.emId
	where ph.ptUpdater = #{updater,jdbcType=INTEGER}
	order by ph.ptUpTime DESC
  </select>
  <select id="existsByName" resultType="java.lang.Integer" parameterType="cn.runsa.portal.base.entity.PhoneLog">
	SELECT count(*) FROM smUsername usn LEFT JOIN smUsers us ON us.emId = usn.emId WHERE usn.usnType=2 AND usn.usnName =#{emphone,jdbcType=VARCHAR}
  </select>
  <select id="findPhone" resultMap="BaseResultMap" parameterType="cn.runsa.portal.base.entity.PhoneLog">
  	SELECT
		t1.usnName,
		t2.emCode,
		t2.emName,
		t3.coName,
		t5.deName,
		t7.poName
	FROM
		smUsername t1
	INNER JOIN mtEmployee t2 ON t1.emId = t2.emId
	LEFT JOIN mtCorp t3 ON t2.coId = t3.coId
	LEFT JOIN mtEmployeeDept t4 ON t4.emId = t1.emId
	LEFT JOIN mtDept t5 ON t5.deId = t4.deId
	LEFT JOIN mtEmployeePost t6 ON t6.emId = t1.emId
	LEFT JOIN mtPost t7 ON t7.poId = t6.poId
	WHERE
		t1.usnName = #{emphone,jdbcType=VARCHAR}
  </select>
</mapper>