SSM sql.xml日志查询mapper.xml

Posted Kikyo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SSM sql.xml日志查询mapper.xml相关的知识,希望对你有一定的参考价值。

LogInfoMapper.xml

<?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.kikyo.sys.mapper.LogInfoMapper">
    <resultMap id="BaseResultMap" type="com.kikyo.sys.domain.LogInfo">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="loginname" jdbcType="VARCHAR" property="loginname"/>
        <result column="loginip" jdbcType="VARCHAR" property="loginip"/>
        <result column="logintime" jdbcType="TIMESTAMP" property="logintime"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, loginname, loginip, logintime
  </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from sys_log_login
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from sys_log_login
    where id = #{id,jdbcType=INTEGER}
  </delete>
    <insert id="insert" parameterType="com.kikyo.sys.domain.LogInfo">
    insert into sys_log_login (id, loginname, loginip, 
      logintime)
    values (#{id,jdbcType=INTEGER}, #{loginname,jdbcType=VARCHAR}, #{loginip,jdbcType=VARCHAR}, 
      #{logintime,jdbcType=TIMESTAMP})
  </insert>
    <insert id="insertSelective" parameterType="com.kikyo.sys.domain.LogInfo">
        insert into sys_log_login
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="loginname != null">
                loginname,
            </if>
            <if test="loginip != null">
                loginip,
            </if>
            <if test="logintime != null">
                logintime,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="loginname != null">
                #{loginname,jdbcType=VARCHAR},
            </if>
            <if test="loginip != null">
                #{loginip,jdbcType=VARCHAR},
            </if>
            <if test="logintime != null">
                #{logintime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.kikyo.sys.domain.LogInfo">
        update sys_log_login
        <set>
            <if test="loginname != null">
                loginname = #{loginname,jdbcType=VARCHAR},
            </if>
            <if test="loginip != null">
                loginip = #{loginip,jdbcType=VARCHAR},
            </if>
            <if test="logintime != null">
                logintime = #{logintime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.kikyo.sys.domain.LogInfo">
    update sys_log_login
    set loginname = #{loginname,jdbcType=VARCHAR},
      loginip = #{loginip,jdbcType=VARCHAR},
      logintime = #{logintime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

    <!-- 查询日志 -->
    <select id="queryAllLogInfo" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from sys_log_login
        <where>
            <if test="loginname!=null and loginname!=‘‘">
                and loginname like concat("%",#{loginname},"%")
            </if>
            <if test="loginip!=null and loginip!=‘‘">
                and loginip like concat("%",#{loginip},"%")
            </if>
            <if test="startTime!=null">
                and logintime >=#{startTime}
            </if>
            <if test="endTime!=null">
                <!-- and logintime &lt; = #{endTime} -->
                and logintime  <![CDATA[<=]]> #{endTime}
            </if>
        </where>
        order by logintime desc
    </select>
</mapper>

 

以上是关于SSM sql.xml日志查询mapper.xml的主要内容,如果未能解决你的问题,请参考以下文章

Java SSM 项目实战 day09 SSMAOP日志

Java SSM 项目实战 day09 SSMAOP日志

08 SSM整合案例(企业权限管理系统):09.用户操作

使用 ssm 实现登录日志记录

sql SQL XML查询示例

在SSM框架中定义日志信息