LogMapperEx.xml 2.7 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.jsh.erp.datasource.mappers.LogMapperEx">
  4. <resultMap extends="com.jsh.erp.datasource.mappers.LogMapper.BaseResultMap" id="ResultExMap" type="com.jsh.erp.datasource.vo.LogVo4List">
  5. <result column="userName" jdbcType="VARCHAR" property="userName" />
  6. <result column="login_name" jdbcType="VARCHAR" property="loginName" />
  7. </resultMap>
  8. <select id="selectByConditionLog" parameterType="com.jsh.erp.datasource.entities.LogExample" resultMap="ResultExMap">
  9. select l.*,u.login_name,u.username userName
  10. FROM jsh_log l
  11. left join jsh_user u on l.user_id = u.id
  12. left join jsh_tenant t on l.tenant_id=t.tenant_id
  13. where 1=1
  14. <if test="operation != null">
  15. <bind name="bindOperation" value="'%'+operation+'%'"/>
  16. and l.operation like #{bindOperation}
  17. </if>
  18. <if test="userInfo != null">
  19. <bind name="bindUserInfo" value="'%'+userInfo+'%'"/>
  20. and (u.username like #{bindUserInfo} or u.login_name like #{bindUserInfo})
  21. </if>
  22. <if test="clientIp != null">
  23. <bind name="bindClientIp" value="'%'+clientIp+'%'"/>
  24. and l.client_ip like #{bindClientIp}
  25. </if>
  26. <if test="tenantLoginName != null">
  27. and t.login_name = #{tenantLoginName}
  28. </if>
  29. <if test="tenantType != null">
  30. and t.type = #{tenantType}
  31. </if>
  32. <if test="beginTime != null">
  33. and l.create_time &gt;= #{beginTime}
  34. </if>
  35. <if test="endTime != null">
  36. and l.create_time &lt;= #{endTime}
  37. </if>
  38. <if test="content != null">
  39. <bind name="bindContent" value="'%'+content+'%'"/>
  40. and l.content like #{bindContent}
  41. </if>
  42. order by l.create_time desc
  43. </select>
  44. <select id="getCountByIpAndDate" resultType="java.lang.Long">
  45. select count(1) from jsh_log
  46. where user_id=#{userId} and operation=#{moduleName} and client_ip=#{clientIp} and create_time=#{createTime}
  47. </select>
  48. <insert id="insertLogWithUserId" parameterType="com.jsh.erp.datasource.entities.Log">
  49. insert into jsh_log (user_id, operation,
  50. client_ip, create_time, status,
  51. content, tenant_id)
  52. values (#{userId,jdbcType=BIGINT}, #{operation,jdbcType=VARCHAR},
  53. #{clientIp,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=TINYINT},
  54. #{content,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT})
  55. </insert>
  56. </mapper>