SysLogMapper.xml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.ssm.mapper.system.SysLogMapper" >
  4. <resultMap id="BaseResultMap" type="com.ssm.model.system.SysLog" >
  5. <id column="ID" property="id" jdbcType="INTEGER" />
  6. <result column="UserID" property="userId" jdbcType="INTEGER" />
  7. <result column="CreatedDate" property="createdDate" jdbcType="TIMESTAMP" />
  8. <result column="Origin" property="origin" jdbcType="VARCHAR" />
  9. <result column="LogLevel" property="logLevel" jdbcType="VARCHAR" />
  10. <result column="LogMessage" property="logMessage" jdbcType="VARCHAR" />
  11. <result column="StackTrace" property="stackTrace" jdbcType="VARCHAR" />
  12. <result column="cd" property="cd" jdbcType="VARCHAR" />
  13. <result column="UserName" property="username" jdbcType="VARCHAR" />
  14. <result column="startDate" property="startDate" jdbcType="TIMESTAMP" />
  15. <result column="endDate" property="endDate" jdbcType="TIMESTAMP" />
  16. <result column="Params" property="params" jdbcType="VARCHAR" />
  17. <result column="IpAddress" property="ipAddress" jdbcType="VARCHAR" />
  18. </resultMap>
  19. <insert id="insert" parameterType="com.ssm.model.system.SysLog" >
  20. insert into SysLog (
  21. UserID, CreatedDate, Origin, LogLevel, LogMessage, StackTrace, Params, IpAddress)
  22. values (
  23. #{userId,jdbcType=INTEGER}, #{createdDate,jdbcType=TIMESTAMP}, #{origin,jdbcType=VARCHAR},
  24. #{logLevel,jdbcType=VARCHAR}, #{logMessage,jdbcType=VARCHAR}, #{stackTrace,jdbcType=VARCHAR},
  25. #{params, jdbcType=VARCHAR}, #{ipAddress, jdbcType=VARCHAR})
  26. </insert>
  27. <sql id="Base_Column_List">
  28. ID, Origin, LogLevel, LogMessage, StackTrace,UserName
  29. </sql>
  30. <select id="selectlog" resultMap="BaseResultMap">
  31. select
  32. <include refid="Base_Column_List" />
  33. ,date_format(CreatedDate, '%Y-%m-%d %H:%i:%s') as cd from SysLog LEFT JOIN SysUser on SysLog.UserID=SysUser.UserID
  34. where 1 = 1
  35. <if test="username != null and username != '' ">
  36. and SysUser.UserName like '%${username}%'
  37. </if>
  38. <if test="origin != null and origin != '' ">
  39. and SysLog.origin like '%${origin}%'
  40. </if>
  41. <if test="startDate != null and startDate != '' ">
  42. <![CDATA[ and SysLog.CreatedDate >= #{startDate} ]]>
  43. </if>
  44. <if test="endDate != null and endDate != '' ">
  45. <![CDATA[ and SysLog.CreatedDate <= #{endDate} ]]>
  46. </if>
  47. ORDER BY SysLog.CreatedDate Desc
  48. </select>
  49. <select id="selectById" resultMap="BaseResultMap">
  50. select SysLog.*, SysUser.UserName from SysLog LEFT JOIN SysUser on SysLog.UserID=SysUser.UserID
  51. where SysLog.ID = #{id}
  52. </select>
  53. </mapper>