GiveUserGiftRecordMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.juxiao.xchat.module.xbd.mapper.record.GiveUserGiftRecordMapper">
  4. <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.record.GiveUserGiftRecord" >
  5. <id column="record_id" property="recordId" jdbcType="INTEGER" />
  6. <result column="uid" property="uid" jdbcType="BIGINT" />
  7. <result column="gift_id" property="giftId" jdbcType="INTEGER" />
  8. <result column="gift_num" property="giftNum" jdbcType="INTEGER" />
  9. <result column="admin_id" property="adminId" jdbcType="INTEGER" />
  10. <result column="type" property="type" jdbcType="INTEGER" />
  11. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  12. </resultMap>
  13. <sql id="Base_Column_List" >
  14. record_id, uid, gift_id, gift_num, admin_id, type, create_time
  15. </sql>
  16. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  17. select
  18. <include refid="Base_Column_List" />
  19. from give_user_gift_record
  20. where record_id = #{recordId,jdbcType=INTEGER}
  21. </select>
  22. <insert id="insert" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiveUserGiftRecord" >
  23. <selectKey resultType="java.lang.Integer" keyProperty="recordId" order="AFTER" >
  24. SELECT LAST_INSERT_ID()
  25. </selectKey>
  26. insert into give_user_gift_record (uid, gift_id, gift_num,
  27. admin_id, type, create_time
  28. )
  29. values (#{uid,jdbcType=BIGINT}, #{giftId,jdbcType=INTEGER}, #{giftNum,jdbcType=INTEGER},
  30. #{adminId,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
  31. )
  32. </insert>
  33. <insert id="insertSelective" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiveUserGiftRecord" >
  34. <selectKey resultType="java.lang.Integer" keyProperty="recordId" order="AFTER" >
  35. SELECT LAST_INSERT_ID()
  36. </selectKey>
  37. insert into give_user_gift_record
  38. <trim prefix="(" suffix=")" suffixOverrides="," >
  39. <if test="uid != null" >
  40. uid,
  41. </if>
  42. <if test="giftId != null" >
  43. gift_id,
  44. </if>
  45. <if test="giftNum != null" >
  46. gift_num,
  47. </if>
  48. <if test="adminId != null" >
  49. admin_id,
  50. </if>
  51. <if test="type != null" >
  52. type,
  53. </if>
  54. <if test="createTime != null" >
  55. create_time,
  56. </if>
  57. </trim>
  58. <trim prefix="values (" suffix=")" suffixOverrides="," >
  59. <if test="uid != null" >
  60. #{uid,jdbcType=BIGINT},
  61. </if>
  62. <if test="giftId != null" >
  63. #{giftId,jdbcType=INTEGER},
  64. </if>
  65. <if test="giftNum != null" >
  66. #{giftNum,jdbcType=INTEGER},
  67. </if>
  68. <if test="adminId != null" >
  69. #{adminId,jdbcType=INTEGER},
  70. </if>
  71. <if test="type != null" >
  72. #{type,jdbcType=INTEGER},
  73. </if>
  74. <if test="createTime != null" >
  75. #{createTime,jdbcType=TIMESTAMP},
  76. </if>
  77. </trim>
  78. </insert>
  79. <update id="updateByPrimaryKeySelective" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiveUserGiftRecord" >
  80. update give_user_gift_record
  81. <set >
  82. <if test="uid != null" >
  83. uid = #{uid,jdbcType=BIGINT},
  84. </if>
  85. <if test="giftId != null" >
  86. gift_id = #{giftId,jdbcType=INTEGER},
  87. </if>
  88. <if test="giftNum != null" >
  89. gift_num = #{giftNum,jdbcType=INTEGER},
  90. </if>
  91. <if test="adminId != null" >
  92. admin_id = #{adminId,jdbcType=INTEGER},
  93. </if>
  94. <if test="type != null" >
  95. type = #{type,jdbcType=INTEGER},
  96. </if>
  97. <if test="createTime != null" >
  98. create_time = #{createTime,jdbcType=TIMESTAMP},
  99. </if>
  100. </set>
  101. where record_id = #{recordId,jdbcType=INTEGER}
  102. </update>
  103. <update id="updateByPrimaryKey" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiveUserGiftRecord" >
  104. update give_user_gift_record
  105. set uid = #{uid,jdbcType=BIGINT},
  106. gift_id = #{giftId,jdbcType=INTEGER},
  107. gift_num = #{giftNum,jdbcType=INTEGER},
  108. admin_id = #{adminId,jdbcType=INTEGER},
  109. type = #{type,jdbcType=INTEGER},
  110. create_time = #{createTime,jdbcType=TIMESTAMP}
  111. where record_id = #{recordId,jdbcType=INTEGER}
  112. </update>
  113. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  114. delete from give_user_gift_record
  115. where record_id = #{recordId,jdbcType=INTEGER}
  116. </delete>
  117. <select id="selectGiftPushRecords" resultType="com.juxiao.xchat.module.xbd.vo.GiftPushRecordVO">
  118. SELECT u.nick, u.avatar, u.erban_no as erbanNo, g.gift_name as giftName, r.gift_num as giftNum, su.user_name as adminName, DATE_FORMAT(r.create_time,'%Y-%m-%d %H:%i:%s') as createTime
  119. from give_user_gift_record r
  120. LEFT JOIN users u on r.uid = u.uid
  121. LEFT JOIN gift g on g.gift_id = r.gift_id
  122. LEFT JOIN sys_user su on su.user_id = r.admin_id
  123. where 1 = 1
  124. <if test="erbanNo != null">
  125. and u.erban_no = #{erbanNo}
  126. </if>
  127. <if test="adminName != null and adminName != ''">
  128. and su.user_name = #{adminName}
  129. </if>
  130. <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
  131. and r.create_time between #{beginTime} and #{endTime}
  132. </if>
  133. order by r.create_time desc, r.uid
  134. </select>
  135. </mapper>