LogMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.tuoren.forward.mapper.LogMapper">
  4. <resultMap id="BaseResultMap" type="com.tuoren.forward.entity.Log">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="ip" jdbcType="VARCHAR" property="ip" />
  7. <result column="userid" jdbcType="VARCHAR" property="userid" />
  8. <result column="username" jdbcType="VARCHAR" property="username" />
  9. <result column="module" jdbcType="VARCHAR" property="module" />
  10. <result column="operation" jdbcType="VARCHAR" property="operation" />
  11. <result column="method" jdbcType="VARCHAR" property="method" />
  12. <result column="status" jdbcType="CHAR" property="status" />
  13. <result column="url" jdbcType="VARCHAR" property="url" />
  14. <result column="style" jdbcType="VARCHAR" property="style" />
  15. <result column="param" jdbcType="VARCHAR" property="param" />
  16. <result column="body" jdbcType="VARCHAR" property="body" />
  17. <result column="result" jdbcType="VARCHAR" property="result" />
  18. <result column="waste" jdbcType="VARCHAR" property="waste" />
  19. <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
  20. </resultMap>
  21. <sql id="Base_Column_List">
  22. id, ip, userid, username, module, operation, method, status, url, style, param, body,
  23. result, waste, createtime
  24. </sql>
  25. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  26. select
  27. <include refid="Base_Column_List" />
  28. from log
  29. where id = #{id,jdbcType=VARCHAR}
  30. </select>
  31. <select id="select" parameterType="LogDto" resultType="Log">
  32. select
  33. <include refid="Base_Column_List" />
  34. from log
  35. <where>
  36. <if test="username != null and username != ''">
  37. and username like CONCAT('%',#{username,jdbcType=VARCHAR},'%')
  38. </if>
  39. <if test="operation != null and operation != ''">
  40. and operation like CONCAT('%',#{operation,jdbcType=VARCHAR},'%')
  41. </if>
  42. <if test="status != null and status != ''">
  43. and status = #{status,jdbcType=VARCHAR}
  44. </if>
  45. <if test="startTime != null">
  46. and createtime <![CDATA[>=]]> #{startTime,jdbcType=TIMESTAMP}
  47. </if>
  48. <if test="endTime != null">
  49. and createtime <![CDATA[<=]]> #{endTime,jdbcType=TIMESTAMP}
  50. </if>
  51. </where>
  52. <if test="sort != null and sort != ''">
  53. order by ${sort}
  54. <if test="order != null "> ${order}</if>
  55. </if>
  56. </select>
  57. <select id="existLoginTodayByUseid" parameterType="java.lang.String" resultType="java.lang.Integer" >
  58. select 1
  59. from log
  60. where operation='登录' and userid=#{userid,jdbcType=VARCHAR}
  61. and DATEDIFF(current_date(),createtime) =0
  62. limit 1
  63. </select>
  64. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  65. delete from log
  66. where id = #{id,jdbcType=VARCHAR}
  67. </delete>
  68. <insert id="insert" parameterType="com.tuoren.forward.entity.Log">
  69. insert into log (id, ip, userid,
  70. username, module, operation,
  71. method, status, url, style,
  72. param, body, result,
  73. waste, createtime)
  74. values (#{id,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{userid,jdbcType=VARCHAR},
  75. #{username,jdbcType=VARCHAR}, #{module,jdbcType=VARCHAR}, #{operation,jdbcType=VARCHAR},
  76. #{method,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{url,jdbcType=VARCHAR}, #{style,jdbcType=VARCHAR},
  77. #{param,jdbcType=VARCHAR}, #{body,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR},
  78. #{waste,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP})
  79. </insert>
  80. <insert id="insertSelective" parameterType="com.tuoren.forward.entity.Log">
  81. insert into log
  82. <trim prefix="(" suffix=")" suffixOverrides=",">
  83. <if test="id != null">
  84. id,
  85. </if>
  86. <if test="ip != null">
  87. ip,
  88. </if>
  89. <if test="userid != null">
  90. userid,
  91. </if>
  92. <if test="username != null">
  93. username,
  94. </if>
  95. <if test="module != null">
  96. module,
  97. </if>
  98. <if test="operation != null">
  99. operation,
  100. </if>
  101. <if test="method != null">
  102. method,
  103. </if>
  104. <if test="status != null">
  105. status,
  106. </if>
  107. <if test="url != null">
  108. url,
  109. </if>
  110. <if test="style != null">
  111. style,
  112. </if>
  113. <if test="param != null">
  114. param,
  115. </if>
  116. <if test="body != null">
  117. body,
  118. </if>
  119. <if test="result != null">
  120. result,
  121. </if>
  122. <if test="waste != null">
  123. waste,
  124. </if>
  125. <if test="createtime != null">
  126. createtime,
  127. </if>
  128. </trim>
  129. <trim prefix="values (" suffix=")" suffixOverrides=",">
  130. <if test="id != null">
  131. #{id,jdbcType=VARCHAR},
  132. </if>
  133. <if test="ip != null">
  134. #{ip,jdbcType=VARCHAR},
  135. </if>
  136. <if test="userid != null">
  137. #{userid,jdbcType=VARCHAR},
  138. </if>
  139. <if test="username != null">
  140. #{username,jdbcType=VARCHAR},
  141. </if>
  142. <if test="module != null">
  143. #{module,jdbcType=VARCHAR},
  144. </if>
  145. <if test="operation != null">
  146. #{operation,jdbcType=VARCHAR},
  147. </if>
  148. <if test="method != null">
  149. #{method,jdbcType=VARCHAR},
  150. </if>
  151. <if test="status != null">
  152. #{status,jdbcType=CHAR},
  153. </if>
  154. <if test="url != null">
  155. #{url,jdbcType=VARCHAR},
  156. </if>
  157. <if test="style != null">
  158. #{style,jdbcType=VARCHAR},
  159. </if>
  160. <if test="param != null">
  161. #{param,jdbcType=VARCHAR},
  162. </if>
  163. <if test="body != null">
  164. #{body,jdbcType=VARCHAR},
  165. </if>
  166. <if test="result != null">
  167. #{result,jdbcType=VARCHAR},
  168. </if>
  169. <if test="waste != null">
  170. #{waste,jdbcType=VARCHAR},
  171. </if>
  172. <if test="createtime != null">
  173. #{createtime,jdbcType=TIMESTAMP},
  174. </if>
  175. </trim>
  176. </insert>
  177. <update id="updateByPrimaryKeySelective" parameterType="com.tuoren.forward.entity.Log">
  178. update log
  179. <set>
  180. <if test="ip != null">
  181. ip = #{ip,jdbcType=VARCHAR},
  182. </if>
  183. <if test="userid != null">
  184. userid = #{userid,jdbcType=VARCHAR},
  185. </if>
  186. <if test="username != null">
  187. username = #{username,jdbcType=VARCHAR},
  188. </if>
  189. <if test="module != null">
  190. module = #{module,jdbcType=VARCHAR},
  191. </if>
  192. <if test="operation != null">
  193. operation = #{operation,jdbcType=VARCHAR},
  194. </if>
  195. <if test="method != null">
  196. method = #{method,jdbcType=VARCHAR},
  197. </if>
  198. <if test="status != null">
  199. status = #{status,jdbcType=CHAR},
  200. </if>
  201. <if test="url != null">
  202. url = #{url,jdbcType=VARCHAR},
  203. </if>
  204. <if test="style != null">
  205. style = #{style,jdbcType=VARCHAR},
  206. </if>
  207. <if test="param != null">
  208. param = #{param,jdbcType=VARCHAR},
  209. </if>
  210. <if test="body != null">
  211. body = #{body,jdbcType=VARCHAR},
  212. </if>
  213. <if test="result != null">
  214. result = #{result,jdbcType=VARCHAR},
  215. </if>
  216. <if test="waste != null">
  217. waste = #{waste,jdbcType=VARCHAR},
  218. </if>
  219. <if test="createtime != null">
  220. createtime = #{createtime,jdbcType=TIMESTAMP},
  221. </if>
  222. </set>
  223. where id = #{id,jdbcType=VARCHAR}
  224. </update>
  225. <update id="updateByPrimaryKey" parameterType="com.tuoren.forward.entity.Log">
  226. update log
  227. set ip = #{ip,jdbcType=VARCHAR},
  228. userid = #{userid,jdbcType=VARCHAR},
  229. username = #{username,jdbcType=VARCHAR},
  230. module = #{module,jdbcType=VARCHAR},
  231. operation = #{operation,jdbcType=VARCHAR},
  232. method = #{method,jdbcType=VARCHAR},
  233. status = #{status,jdbcType=CHAR},
  234. url = #{url,jdbcType=VARCHAR},
  235. style = #{style,jdbcType=VARCHAR},
  236. param = #{param,jdbcType=VARCHAR},
  237. body = #{body,jdbcType=VARCHAR},
  238. result = #{result,jdbcType=VARCHAR},
  239. waste = #{waste,jdbcType=VARCHAR},
  240. createtime = #{createtime,jdbcType=TIMESTAMP}
  241. where id = #{id,jdbcType=VARCHAR}
  242. </update>
  243. </mapper>