SysLoginLogMapper.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.aidex.system.mapper.SysLoginLogMapper">
  6. <sql id="sysLoginLogColumns">
  7. a.id as "id",
  8. a.user_name as "userName",
  9. a.status as "status",
  10. a.ipaddr as "ipaddr",
  11. a.login_location as "loginLocation",
  12. a.browser as "browser",
  13. a.os as "os",
  14. a.msg as "msg",
  15. a.login_time as "loginTime"
  16. </sql>
  17. <sql id="sysLoginLogJoins">
  18. </sql>
  19. <sql id="sysLoginLogOrderBy">
  20. order by a.login_time desc
  21. </sql>
  22. <select id="get" resultType="SysLoginLog">
  23. SELECT
  24. <include refid="sysLoginLogColumns"/>
  25. FROM sys_login_log a
  26. where id = #{id}
  27. </select>
  28. <select id="findList" resultType="SysLoginLog">
  29. SELECT
  30. <include refid="sysLoginLogColumns"/>
  31. FROM sys_login_log a
  32. <include refid="sysLoginLogJoins"/>
  33. where a.del_flag = #{DEL_FLAG_NORMAL}
  34. <if test="ipaddr != null and ipaddr != ''">
  35. AND ipaddr like concat('%', #{ipaddr}, '%')
  36. </if>
  37. <if test="msg != null and msg != ''">
  38. AND msg like concat('%', #{msg}, '%')
  39. </if>
  40. <if test="status != null and status != ''">
  41. AND status = #{status}
  42. </if>
  43. <if test="userName != null and userName != ''">
  44. AND user_name like concat('%', #{userName}, '%')
  45. </if>
  46. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  47. and date_format(login_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
  48. </if>
  49. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  50. and date_format(login_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
  51. </if>
  52. <include refid="sysLoginLogOrderBy"/>
  53. </select>
  54. <insert id="insert" parameterType="SysLoginLog">
  55. insert into sys_login_log
  56. (
  57. id,
  58. user_name,
  59. status,
  60. ipaddr,
  61. login_location,
  62. browser,
  63. os,
  64. msg,
  65. login_time)
  66. values
  67. (
  68. #{id},
  69. #{userName},
  70. #{status},
  71. #{ipaddr},
  72. #{loginLocation},
  73. #{browser},
  74. #{os},
  75. #{msg},
  76. sysdate(),
  77. #{createBy})
  78. </insert>
  79. <insert id="addLoginLog" parameterType="SysLoginLog">
  80. insert into sys_login_log
  81. (
  82. id,
  83. user_name,
  84. status,
  85. ipaddr,
  86. login_location,
  87. browser,
  88. os,
  89. msg,
  90. login_time)
  91. values
  92. (
  93. #{id},
  94. #{userName},
  95. #{status},
  96. #{ipaddr},
  97. #{loginLocation},
  98. #{browser},
  99. #{os},
  100. #{msg},
  101. sysdate()
  102. )
  103. </insert>
  104. <update id="deleteLoginLogByIds" parameterType="java.util.Map">
  105. UPDATE sys_login_log SET
  106. del_flag = #{DEL_FLAG_DELETE}
  107. WHERE id in
  108. <foreach collection="infoIds" item="ids" open="(" separator="," close=")">
  109. #{ids}
  110. </foreach>
  111. </update>
  112. <update id="cleanLoginLog">
  113. truncate table sys_login_log
  114. </update>
  115. <update id="deleteLoginLogBySaveDay" parameterType="java.lang.String">
  116. delete from sys_login_log where datediff(SYSDATE(),login_time) >= #{saveDay}
  117. </update>
  118. </mapper>