|
@@ -0,0 +1,159 @@
|
|
|
+<?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.huaxu.dao.LoginLogMapper">
|
|
|
+
|
|
|
+ <!-- 结果集 -->
|
|
|
+ <resultMap type="com.huaxu.dto.LoginLogDto" id="LoginLogMap">
|
|
|
+ <result property="id" column="id" jdbcType="BIGINT"/>
|
|
|
+ <result property="name" column="name" jdbcType="VARCHAR"/>
|
|
|
+ <result property="phone" column="phone" jdbcType="VARCHAR"/>
|
|
|
+ <result property="companyId" column="company_id" jdbcType="INTEGER"/>
|
|
|
+ <result property="departmentId" column="DEPARTMENT_ID" jdbcType="INTEGER"/>
|
|
|
+ <result property="type" column="type" jdbcType="VARCHAR"/>
|
|
|
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="loginIp" column="login_ip" jdbcType="VARCHAR"/>
|
|
|
+ <result property="companyName" column="companyName" jdbcType="VARCHAR"/>
|
|
|
+ <result property="departmentName" column="departmentName" jdbcType="VARCHAR"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 基本字段 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ a.id,
|
|
|
+ a.name,
|
|
|
+ a.phone,
|
|
|
+ a.company_id,
|
|
|
+ a.DEPARTMENT_ID,
|
|
|
+ a.type,
|
|
|
+ a.create_time,
|
|
|
+ a.login_ip,
|
|
|
+ com.ORG_NAME as "companyName",
|
|
|
+ dep.ORG_NAME as "departmentName"
|
|
|
+ </sql>
|
|
|
+ <!-- 外联表 -->
|
|
|
+ <sql id="loginLogJoins">
|
|
|
+ left join uims_org com on com.id = a.company_id
|
|
|
+ left join uims_org dep on dep.id = a.DEPARTMENT_ID
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询单个 -->
|
|
|
+ <select id="selectById" resultMap="LoginLogMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_login_log a
|
|
|
+ <include refid="loginLogJoins"/>
|
|
|
+ where a.id = #{id}
|
|
|
+ </select>
|
|
|
+ <!-- 查询全部 -->
|
|
|
+ <select id="selectAll" resultMap="LoginLogMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_login_log a
|
|
|
+ <include refid="loginLogJoins"/>
|
|
|
+ </select>
|
|
|
+ <!--通过实体作为筛选条件查询-->
|
|
|
+ <select id="selectList" resultMap="LoginLogMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_login_log a
|
|
|
+ <include refid="loginLogJoins"/>
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and a.id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="condition != null and condition != ''">
|
|
|
+ and (a.name like concat('%', #{condition},'%')
|
|
|
+ or a.phone like concat('%', #{condition},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ and a.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="departmentId != null">
|
|
|
+ and a.DEPARTMENT_ID = #{departmentId}
|
|
|
+ </if>
|
|
|
+ <if test="beginTime != null">
|
|
|
+ and a.create_time >= #{beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null">
|
|
|
+ and a.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <!-- 新增所有列 -->
|
|
|
+ <insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into uims_login_log( name, phone, company_id, DEPARTMENT_ID, type, create_time, login_ip)
|
|
|
+ values ( #{name}, #{phone}, #{companyId}, #{departmentId}, #{type}, #{createTime}, #{loginIp})
|
|
|
+ </insert>
|
|
|
+ <!-- 批量新增 -->
|
|
|
+ <insert id="batchInsert">
|
|
|
+ insert into uims_login_log( name, phone, company_id, DEPARTMENT_ID, type, create_time, login_ip)
|
|
|
+ values
|
|
|
+ <foreach collection="loginLogs" item="item" index="index" separator=",">
|
|
|
+ ( #{item.name}, #{item.phone}, #{item.companyId}, #{item.departmentId}, #{item.type},
|
|
|
+ #{item.createTime}, #{item.loginIp} )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+ <!-- 通过主键修改数据 -->
|
|
|
+ <update id="update">
|
|
|
+ update uims.uims_login_log
|
|
|
+ <set>
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ name = #{name},
|
|
|
+ </if>
|
|
|
+ <if test="phone != null and phone != ''">
|
|
|
+ phone = #{phone},
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ company_id = #{companyId},
|
|
|
+ </if>
|
|
|
+ <if test="departmentId != null">
|
|
|
+ DEPARTMENT_ID = #{departmentId},
|
|
|
+ </if>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ type = #{type},
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ create_time = #{createTime},
|
|
|
+ </if>
|
|
|
+ <if test="loginIp != null and loginIp != ''">
|
|
|
+ login_ip = #{loginIp},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+ <!--通过主键删除-->
|
|
|
+ <delete id="deleteById">
|
|
|
+ delete from uims_login_log where id = #{id}
|
|
|
+ </delete>
|
|
|
+ <!-- 总数 -->
|
|
|
+ <select id="count" resultType="int">
|
|
|
+ select count(*) from uims_login_log
|
|
|
+ </select>
|
|
|
+ <select id="selectPage" resultMap="LoginLogMap">
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from uims_login_log a
|
|
|
+ <include refid="loginLogJoins"/>
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and a.id = #{loginLogDto.id}
|
|
|
+ </if>
|
|
|
+ <if test="condition != null and condition != ''">
|
|
|
+ and (a.name like concat('%', #{loginLogDto.condition},'%')
|
|
|
+ or a.phone like concat('%', #{loginLogDto.condition},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ and a.company_id = #{loginLogDto.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="departmentId != null">
|
|
|
+ and a.DEPARTMENT_ID = #{loginLogDto.departmentId}
|
|
|
+ </if>
|
|
|
+ <if test="beginTime != null">
|
|
|
+ and a.create_time >= #{loginLogDto.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null">
|
|
|
+ and a.create_time <= #{loginLogDto.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|