AlertLogMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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.dgtly.system.mapper.AlertLogMapper">
  6. <resultMap type="AlertLog" id="AlertLogResult">
  7. <result property="alertLogId" column="alert_log_id" />
  8. <result property="alertId" column="alert_id" />
  9. <result property="createBy" column="create_by" />
  10. <result property="createTime" column="create_time" />
  11. <result property="updateBy" column="update_by" />
  12. <result property="updateTime" column="update_time" />
  13. <result property="isDelete" column="is_delete" />
  14. <result property="userId" column="user_id" />
  15. <result property="loginName" column="login_name" />
  16. <result property="alertNum" column="alert_num" />
  17. <result property="userType" column="user_type" />
  18. <result property="isClearCache" column="is_clear_cache" />
  19. </resultMap>
  20. <sql id="selectAlertLogVo">
  21. select alert_log_id, alert_id, create_by, create_time, update_by, update_time, is_delete, user_id, login_name, alert_num, user_type,is_clear_cache from alert_log
  22. </sql>
  23. <select id="selectAlertLogList" parameterType="AlertLog" resultMap="AlertLogResult">
  24. <include refid="selectAlertLogVo"/>
  25. <where>
  26. <if test="alertId != null "> and alert_id = #{alertId}</if>
  27. <if test="isDelete != null "> and is_delete = #{isDelete}</if>
  28. <if test="userId != null "> and user_id = #{userId}</if>
  29. <if test="loginName != null and loginName != ''"> and login_name like concat('%', #{loginName}, '%')</if>
  30. <if test="alertNum != null "> and alert_num = #{alertNum}</if>
  31. <if test="userType != null and userType != ''"> and user_type = #{userType}</if>
  32. </where>
  33. </select>
  34. <select id="selectAlertLogById" parameterType="Long" resultMap="AlertLogResult">
  35. <include refid="selectAlertLogVo"/>
  36. where alert_log_id = #{alertLogId}
  37. </select>
  38. <select id="selectAlertLogByUserId" parameterType="AlertLog" resultMap="AlertLogResult">
  39. <include refid="selectAlertLogVo"/>
  40. where user_id = #{userId}
  41. </select>
  42. <select id="selectAlertLogByUserIdAndAlertId" parameterType="AlertLog" resultMap="AlertLogResult">
  43. <include refid="selectAlertLogVo"/>
  44. where 1=1
  45. <if test="userId!=null">and user_id = #{userId}</if>
  46. <if test="alertId != null ">and alert_id = #{alertId}</if>
  47. <if test="isCacheType !=null and isCacheType == '0'.toString()">
  48. and DATE_FORMAT(create_time,'%Y%m%d') = DATE_FORMAT(NOW(),'%Y%m%d')
  49. </if>
  50. <if test="userType != null ">and user_type = #{userType}</if>
  51. order by create_time desc
  52. limit 1
  53. </select>
  54. <insert id="insertAlertLog" parameterType="AlertLog" useGeneratedKeys="true" keyProperty="alertLogId">
  55. insert into alert_log
  56. <trim prefix="(" suffix=")" suffixOverrides=",">
  57. <if test="alertId != null ">alert_id,</if>
  58. <if test="createBy != null and createBy != ''">create_by,</if>
  59. <if test="createTime != null ">create_time,</if>
  60. <if test="updateBy != null and updateBy != ''">update_by,</if>
  61. <if test="updateTime != null ">update_time,</if>
  62. <if test="isDelete != null ">is_delete,</if>
  63. <if test="userId != null ">user_id,</if>
  64. <if test="loginName != null and loginName != ''">login_name,</if>
  65. <if test="alertNum != null ">alert_num,</if>
  66. <if test="userType != null and userType != ''">user_type,</if>
  67. <if test="isClearCache !=null and isClearCache !='' ">is_clear_cache,</if>
  68. </trim>
  69. <trim prefix="values (" suffix=")" suffixOverrides=",">
  70. <if test="alertId != null ">#{alertId},</if>
  71. <if test="createBy != null and createBy != ''">#{createBy},</if>
  72. <if test="createTime != null ">#{createTime},</if>
  73. <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
  74. <if test="updateTime != null ">#{updateTime},</if>
  75. <if test="isDelete != null ">#{isDelete},</if>
  76. <if test="userId != null ">#{userId},</if>
  77. <if test="loginName != null and loginName != ''">#{loginName},</if>
  78. <if test="alertNum != null ">#{alertNum},</if>
  79. <if test="userType != null and userType != ''">#{userType},</if>
  80. <if test="isClearCache !=null and isClearCache !='' ">#{isClearCache},</if>
  81. </trim>
  82. </insert>
  83. <update id="updateAlertLog" parameterType="AlertLog">
  84. update alert_log
  85. <trim prefix="SET" suffixOverrides=",">
  86. <if test="alertId != null ">alert_id = #{alertId},</if>
  87. <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
  88. <if test="createTime != null ">create_time = #{createTime},</if>
  89. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  90. <if test="updateTime != null ">update_time = #{updateTime},</if>
  91. <if test="isDelete != null ">is_delete = #{isDelete},</if>
  92. <if test="userId != null ">user_id = #{userId},</if>
  93. <if test="loginName != null and loginName != ''">login_name = #{loginName},</if>
  94. <if test="alertNum != null ">alert_num = #{alertNum},</if>
  95. <if test="userType != null and userType != ''">user_type = #{userType},</if>
  96. <if test="isClearCache !=null and isClearCache !='' ">is_clear_cache = #{isClearCache},</if>
  97. </trim>
  98. where alert_log_id = #{alertLogId}
  99. </update>
  100. <delete id="deleteAlertLogById" parameterType="Long">
  101. delete from alert_log where alert_log_id = #{alertLogId}
  102. </delete>
  103. <delete id="deleteAlertLogByIds" parameterType="String">
  104. delete from alert_log where alert_log_id in
  105. <foreach item="alertLogId" collection="array" open="(" separator="," close=")">
  106. #{alertLogId}
  107. </foreach>
  108. </delete>
  109. </mapper>