LoginLog.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.LoginLogMapper">
  4. <!-- 结果集 -->
  5. <resultMap type="com.huaxu.dto.LoginLogDto" id="LoginLogMap">
  6. <result property="id" column="id" jdbcType="BIGINT"/>
  7. <result property="name" column="name" jdbcType="VARCHAR"/>
  8. <result property="phone" column="phone" jdbcType="VARCHAR"/>
  9. <result property="companyId" column="company_id" jdbcType="INTEGER"/>
  10. <result property="departmentId" column="DEPARTMENT_ID" jdbcType="INTEGER"/>
  11. <result property="type" column="type" jdbcType="VARCHAR"/>
  12. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  13. <result property="loginIp" column="login_ip" jdbcType="VARCHAR"/>
  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.name,
  21. a.phone,
  22. a.company_id,
  23. a.DEPARTMENT_ID,
  24. a.type,
  25. a.create_time,
  26. a.login_ip,
  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="LoginLogMap">
  37. select
  38. <include refid="Base_Column_List"/>
  39. from uims_login_log a
  40. <include refid="loginLogJoins"/>
  41. where a.id = #{id}
  42. </select>
  43. <!-- 查询全部 -->
  44. <select id="selectAll" resultMap="LoginLogMap">
  45. select
  46. <include refid="Base_Column_List"/>
  47. from uims_login_log a
  48. <include refid="loginLogJoins"/>
  49. </select>
  50. <!--通过实体作为筛选条件查询-->
  51. <select id="selectList" resultMap="LoginLogMap">
  52. select
  53. <include refid="Base_Column_List"/>
  54. from uims_login_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.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}
  75. </if>
  76. </where>
  77. </select>
  78. <!--通过实体作为筛选条件查询-->
  79. <select id="selectListByIds" resultMap="LoginLogMap">
  80. select
  81. <include refid="Base_Column_List"/>
  82. from uims_login_log a
  83. <include refid="loginLogJoins"/>
  84. <where>
  85. a.id in
  86. <foreach collection = "ids" item = "dramaId" open = "(" close = ")" separator = "," >
  87. #{dramaId}
  88. </foreach>
  89. </where>
  90. </select>
  91. <!-- 新增所有列 -->
  92. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  93. insert into uims_login_log( name, phone, company_id, DEPARTMENT_ID, type, create_time, login_ip)
  94. values ( #{name}, #{phone}, #{companyId}, #{departmentId}, #{type}, #{createTime}, #{loginIp})
  95. </insert>
  96. <!-- 批量新增 -->
  97. <insert id="batchInsert">
  98. insert into uims_login_log( name, phone, company_id, DEPARTMENT_ID, type, create_time, login_ip)
  99. values
  100. <foreach collection="loginLogs" item="item" index="index" separator=",">
  101. ( #{item.name}, #{item.phone}, #{item.companyId}, #{item.departmentId}, #{item.type},
  102. #{item.createTime}, #{item.loginIp} )
  103. </foreach>
  104. </insert>
  105. <!-- 通过主键修改数据 -->
  106. <update id="update">
  107. update uims.uims_login_log
  108. <set>
  109. <if test="name != null and name != ''">
  110. name = #{name},
  111. </if>
  112. <if test="phone != null and phone != ''">
  113. phone = #{phone},
  114. </if>
  115. <if test="companyId != null">
  116. company_id = #{companyId},
  117. </if>
  118. <if test="departmentId != null">
  119. DEPARTMENT_ID = #{departmentId},
  120. </if>
  121. <if test="type != null and type != ''">
  122. type = #{type},
  123. </if>
  124. <if test="createTime != null">
  125. create_time = #{createTime},
  126. </if>
  127. <if test="loginIp != null and loginIp != ''">
  128. login_ip = #{loginIp},
  129. </if>
  130. </set>
  131. where id = #{id}
  132. </update>
  133. <!--通过主键删除-->
  134. <delete id="deleteById">
  135. delete from uims_login_log where id = #{id}
  136. </delete>
  137. <!-- 总数 -->
  138. <select id="count" resultType="int">
  139. select count(*) from uims_login_log
  140. </select>
  141. <select id="selectPage" resultMap="LoginLogMap">
  142. select
  143. <include refid="Base_Column_List"/>
  144. from uims_login_log a
  145. <include refid="loginLogJoins"/>
  146. <where>
  147. <if test="id != null">
  148. and a.id = #{loginLogDto.id}
  149. </if>
  150. <if test="condition != null and condition != ''">
  151. and (a.name like concat('%', #{loginLogDto.condition},'%')
  152. or a.phone like concat('%', #{loginLogDto.condition},'%'))
  153. </if>
  154. <if test="companyId != null">
  155. and a.company_id = #{loginLogDto.companyId}
  156. </if>
  157. <if test="departmentId != null">
  158. and a.DEPARTMENT_ID = #{loginLogDto.departmentId}
  159. </if>
  160. <if test="beginTime != null">
  161. and a.create_time >= #{loginLogDto.beginTime}
  162. </if>
  163. <if test="endTime != null">
  164. and a.create_time &lt;= #{loginLogDto.endTime}
  165. </if>
  166. </where>
  167. </select>
  168. </mapper>