OperationLogMapper.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.welampiot.dao.OperationLogDao">
  4. <select id="getListByVO" resultType="com.welampiot.dto.OperationLogDTO" parameterType="com.welampiot.vo.OperationLogVO">
  5. select time,acount,remark,operaType,operation,sectionid as sectionId,areaid as areaId from operation_log a
  6. where 1=1
  7. <if test="userIdList != null and !userIdList.isEmpty()">
  8. and a.userid in
  9. <foreach item="vo" collection="userIdList" open="(" separator="," close=")">
  10. #{vo}
  11. </foreach>
  12. </if>
  13. <if test="devType != null">
  14. and a.devtype = #{devType}
  15. </if>
  16. <choose>
  17. <when test="version == 1">
  18. and a.type = 1
  19. </when>
  20. <when test="version == 2">
  21. and a.type = 2
  22. </when>
  23. <otherwise>
  24. and a.type = 0
  25. </otherwise>
  26. </choose>
  27. <if test="operaType != null">
  28. and a.operaType = #{operaType}
  29. </if>
  30. order by a.time desc
  31. <if test="offset != null and limit != null">
  32. limit #{offset},#{limit}
  33. </if>
  34. </select>
  35. <select id="getLogListByVO" resultType="com.welampiot.dto.OperationLogDTO" parameterType="com.welampiot.vo.OperationLogVO">
  36. select u.name,o.operaType,o.deviceName,o.sn,o.remark,u.company,o.devtype,o.time as updateTime,o.section,o.area,s.timezone
  37. from operation_log o left join user u on o.userid = u.id
  38. left join section s on o.sectionid = s.id
  39. where 1=1
  40. <if test="role != 1">
  41. and o.userid = #{userId}
  42. </if>
  43. <if test="keyword != null and keyword != ''">
  44. and (u.name like '%${keyword}%' or o.sn like '%${keyword}%' or o.deviceName like '%${keyword}%')
  45. </if>
  46. <if test="operaType != null">
  47. and o.operaType = #{operaType}
  48. </if>
  49. <if test="devType != null">
  50. and o.devtype = #{devType}
  51. </if>
  52. order by o.time desc
  53. <if test="offset >= 0 and limit > 0">
  54. limit #{offset},#{limit}
  55. </if>
  56. </select>
  57. <select id="getRoleByUsername" resultType="Integer">
  58. select u.role
  59. from user u
  60. where u.username = #{username}
  61. </select>
  62. <select id="getUserIdByUsername" resultType="Integer">
  63. select u.id
  64. from user u
  65. where u.username = #{username}
  66. </select>
  67. <select id="getLogTotalByUserId" resultType="Integer">
  68. select count(o.id) as total from operation_log o
  69. <if test="role != 1">
  70. where o.userid = #{userId}
  71. </if>
  72. </select>
  73. <delete id="deleteLogListById">
  74. delete from operation_log where id = #{id}
  75. </delete>
  76. </mapper>