OperateLogMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.huaxu.dao.OperateLogMapper">
  4. <!-- 结果集 -->
  5. <resultMap type="com.huaxu.dto.OperateLogDto" id="OperateLogMap">
  6. <result property="id" column="ID" jdbcType="BIGINT"/>
  7. <result property="userName" column="USER_NAME" jdbcType="VARCHAR"/>
  8. <result property="phone" column="PHONE" jdbcType="VARCHAR"/>
  9. <result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>
  10. <result property="companyId" column="COMPANY_ID" jdbcType="INTEGER"/>
  11. <result property="departmentId" column="DEPARTMENT_ID" jdbcType="INTEGER"/>
  12. <result property="operateContent" column="OPERATE_CONTENT" jdbcType="VARCHAR"/>
  13. <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
  14. <result property="companyName" column="companyName" jdbcType="VARCHAR"/>
  15. <result property="departmentName" column="departmentName" jdbcType="VARCHAR"/>
  16. </resultMap>
  17. <!-- 基本字段 -->
  18. <sql id="Base_Column_List">
  19. a.id,
  20. a.USER_NAME,
  21. a.phone,
  22. a.tenant_id,
  23. a.company_id,
  24. a.DEPARTMENT_ID,
  25. a.operate_content,
  26. a.create_time,
  27. com.ORG_NAME as "companyName",
  28. dep.ORG_NAME as "departmentName"
  29. </sql>
  30. <!-- 外联表 -->
  31. <sql id="loginLogJoins">
  32. left join uims_org com on com.id = a.company_id
  33. left join uims_org dep on dep.id = a.DEPARTMENT_ID
  34. </sql>
  35. <!-- 查询单个 -->
  36. <select id="selectById" resultMap="OperateLogMap">
  37. select
  38. <include refid="Base_Column_List"/>
  39. from uims_opr_log a
  40. <include refid="loginLogJoins"/>
  41. where a.id = #{id}
  42. </select>
  43. <!-- 查询全部 -->
  44. <select id="selectAll" resultMap="OperateLogMap">
  45. select
  46. <include refid="Base_Column_List"/>
  47. from uims_opr_log a
  48. <include refid="loginLogJoins"/>
  49. </select>
  50. <!--通过实体作为筛选条件查询-->
  51. <select id="selectList" resultMap="OperateLogMap">
  52. select
  53. <include refid="Base_Column_List"/>
  54. from uims_opr_log a
  55. <include refid="loginLogJoins"/>
  56. <where>
  57. <if test="id != null">
  58. and a.id = #{id}
  59. </if>
  60. <if test="condition != null and condition != ''">
  61. and (a.USER_NAME like concat('%', #{condition},'%')
  62. or a.phone like concat('%', #{condition},'%'))
  63. </if>
  64. <if test="companyId != null">
  65. and a.company_id = #{companyId}
  66. </if>
  67. <if test="departmentId != null">
  68. and a.DEPARTMENT_ID = #{departmentId}
  69. </if>
  70. <if test="beginTime != null">
  71. and a.create_time >= #{beginTime}
  72. </if>
  73. <if test="endTime != null">
  74. and a.create_time &lt;= #{endTime} </if>
  75. </where>
  76. </select>
  77. <!--通过实体作为筛选条件查询-->
  78. <select id="selectListByIds" resultMap="OperateLogMap">
  79. select
  80. <include refid="Base_Column_List"/>
  81. from uims_opr_log a
  82. <include refid="loginLogJoins"/>
  83. <where>
  84. a.id in
  85. <foreach collection = "ids" item = "dramaId" open = "(" close = ")" separator = "," >
  86. #{dramaId}
  87. </foreach>
  88. </where>
  89. </select>
  90. <!-- 新增所有列 -->
  91. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  92. insert into uims_opr_log( USER_NAME, tenant_id, phone, company_id, DEPARTMENT_ID, operate_content, create_time, operate_parameter)
  93. values ( #{userName}, #{tenantId}, #{phone}, #{companyId}, #{departmentId}, #{operateContent}, #{createTime}, #{operateParameter})
  94. </insert>
  95. <!-- 批量新增 -->
  96. <insert id="batchInsert">
  97. insert into uims_opr_log( USER_NAME, tenant_id,phone, company_id, DEPARTMENT_ID, operate_content, create_time, operate_parameter )
  98. values
  99. <foreach collection="loginLogs" item="item" index="index" separator=",">
  100. ( #{item.userName}, #{item.tenantId},#{item.phone}, #{item.companyId}, #{item.departmentId}, #{item.operateContent},
  101. #{item.createTime}, #{item.operateParameter})
  102. </foreach>
  103. </insert>
  104. <!-- 通过主键修改数据 -->
  105. <update id="update">
  106. update uims.uims_opr_log
  107. <set>
  108. <if test="userName != null and userName != ''">
  109. USER_NAME = #{userName},
  110. </if>
  111. <if test="phone != null and phone != ''">
  112. phone = #{phone},
  113. </if>
  114. <if test="companyId != null">
  115. company_id = #{companyId},
  116. </if>
  117. <if test="departmentId != null">
  118. DEPARTMENT_ID = #{departmentId},
  119. </if>
  120. <if test="operateContent != null and operateContent != ''">
  121. operate_content = #{operateContent},
  122. </if>
  123. <if test="createTime != null">
  124. create_time = #{createTime},
  125. </if>
  126. <if test="operateParameter != null and operateParameter != ''">
  127. operate_parameter = #{operateParameter},
  128. </if>
  129. </set>
  130. where id = #{id}
  131. </update>
  132. <!--通过主键删除-->
  133. <delete id="deleteById">
  134. delete from uims_opr_log where id = #{id}
  135. </delete>
  136. <!-- 总数 -->
  137. <select id="count" resultType="int">
  138. select count(*) from uims_opr_log
  139. </select>
  140. <select id="selectPage" resultMap="OperateLogMap">
  141. select
  142. <include refid="Base_Column_List"/>
  143. from uims_opr_log a
  144. <include refid="loginLogJoins"/>
  145. <where>
  146. <if test="operateLogDto.id != null">
  147. and a.id = #{operateLogDto.id}
  148. </if>
  149. <if test="operateLogDto.tenantId != null and operateLogDto.tenantId != ''">
  150. and a.tenant_id = #{operateLogDto.tenantId}
  151. </if>
  152. <if test="operateLogDto.condition != null and operateLogDto.condition != ''">
  153. and (a.USER_NAME like concat('%', #{operateLogDto.condition},'%')
  154. or a.phone like concat('%', #{operateLogDto.condition},'%'))
  155. </if>
  156. <if test="operateLogDto.companyId != null">
  157. and a.company_id = #{operateLogDto.companyId}
  158. </if>
  159. <if test="operateLogDto.departmentId != null">
  160. and (a.DEPARTMENT_ID = #{operateLogDto.departmentId} or a.company_id = #{operateLogDto.departmentId})
  161. </if>
  162. <if test="operateLogDto.beginTime != null">
  163. and a.create_time >= #{operateLogDto.beginTime}
  164. </if>
  165. <if test="operateLogDto.endTime != null">
  166. and a.create_time &lt;= DATE_ADD(#{operateLogDto.endTime},INTERVAL 1 DAY)
  167. </if>
  168. </where>
  169. </select>
  170. </mapper>