KwsUserLoginDao.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.sckw.system.dao.KwsUserLoginDao">
  4. <insert id="saveBatch" parameterType="com.sckw.system.model.KwsUserLogin">
  5. insert into kws_user_login
  6. <trim prefix="(" suffix=")" suffixOverrides=",">
  7. `id`,
  8. `pid`,
  9. `ip`,
  10. `user_agent`,
  11. `user_id`,
  12. `token`,
  13. `valid_time`,
  14. `first`,
  15. `lock`,
  16. `type`,
  17. `out_time`,
  18. `source`,
  19. `create_by`,
  20. `create_time`,
  21. `update_by`,
  22. `update_time`,
  23. `del_flag`
  24. </trim>
  25. values
  26. <foreach collection="list" item="item" separator=",">
  27. <trim prefix="(" suffix=")" suffixOverrides=",">
  28. #{item.id, jdbcType=BIGINT},
  29. #{item.pid, jdbcType=VARCHAR},
  30. #{item.ip, jdbcType=VARCHAR},
  31. #{item.userAgent, jdbcType=VARCHAR},
  32. #{item.userId, jdbcType=BIGINT},
  33. #{item.token, jdbcType=VARCHAR},
  34. #{item.validTime, jdbcType=VARCHAR},
  35. #{item.first, jdbcType=INTEGER},
  36. #{item.lock, jdbcType=INTEGER},
  37. #{item.type, jdbcType=INTEGER},
  38. #{item.outTime, jdbcType=TIMESTAMP},
  39. #{item.source, jdbcType=VARCHAR},
  40. #{item.createBy, jdbcType=BIGINT},
  41. #{item.createTime, jdbcType=TIMESTAMP},
  42. #{item.updateBy, jdbcType=BIGINT},
  43. #{item.updateTime, jdbcType=TIMESTAMP},
  44. #{item.delFlag, jdbcType=INTEGER}
  45. </trim>
  46. </foreach>
  47. </insert>
  48. <insert id="insert">
  49. insert into kws_user_login
  50. <trim prefix="(" suffix=")" suffixOverrides=",">
  51. `id`,
  52. `pid`,
  53. `ip`,
  54. `user_agent`,
  55. `user_id`,
  56. `token`,
  57. `valid_time`,
  58. `first`,
  59. `lock`,
  60. `type`,
  61. `out_time`,
  62. `source`,
  63. `create_by`,
  64. `create_time`,
  65. `update_by`,
  66. `update_time`,
  67. `del_flag`
  68. </trim>
  69. values
  70. <trim prefix="(" suffix=")" suffixOverrides=",">
  71. #{id, jdbcType=BIGINT},
  72. #{pid, jdbcType=VARCHAR},
  73. #{ip, jdbcType=VARCHAR},
  74. #{userAgent, jdbcType=VARCHAR},
  75. #{userId, jdbcType=BIGINT},
  76. #{token, jdbcType=VARCHAR},
  77. #{validTime, jdbcType=VARCHAR},
  78. #{first, jdbcType=INTEGER},
  79. #{lock, jdbcType=INTEGER},
  80. #{type, jdbcType=INTEGER},
  81. #{outTime, jdbcType=TIMESTAMP},
  82. #{source, jdbcType=VARCHAR},
  83. #{createBy, jdbcType=BIGINT},
  84. #{createTime, jdbcType=TIMESTAMP},
  85. #{updateBy, jdbcType=BIGINT},
  86. #{updateTime, jdbcType=TIMESTAMP},
  87. #{delFlag, jdbcType=INTEGER}
  88. </trim>
  89. </insert>
  90. <select id="findAllByUserId" resultType="com.sckw.system.model.KwsUserLogin">
  91. select *
  92. from kws_user_login
  93. where user_id = #{userId}
  94. <if test="startTime != null">
  95. and create_time >= #{startTime}
  96. </if>
  97. <if test="endTime != null">
  98. and create_time &lt; date_add(#{endTime}, INTERVAL 1 DAY)
  99. </if>
  100. order by create_time desc
  101. </select>
  102. <select id="currentDayLogin" resultType="com.sckw.system.model.KwsUserLogin">
  103. select a.*
  104. from kws_user_login a
  105. where a.user_id = #{userId}
  106. and a.create_time >= current_date()
  107. order by a.create_time
  108. limit 1
  109. </select>
  110. </mapper>