GiftCarPurseRecordMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.GiftCarPurseRecordMapper">
  4. <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.record.GiftCarPurseRecord" >
  5. <id column="record_id" property="recordId" jdbcType="BIGINT" />
  6. <result column="uid" property="uid" jdbcType="BIGINT" />
  7. <result column="car_id" property="carId" jdbcType="BIGINT" />
  8. <result column="car_date" property="carDate" jdbcType="INTEGER" />
  9. <result column="total_gold_num" property="totalGoldNum" jdbcType="BIGINT" />
  10. <result column="is_use" property="isUse" jdbcType="TINYINT" />
  11. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  12. </resultMap>
  13. <sql id="Base_Column_List" >
  14. record_id, uid, car_id, car_date, total_gold_num, is_use, create_time
  15. </sql>
  16. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  17. select
  18. <include refid="Base_Column_List" />
  19. from gift_car_purse_record
  20. where record_id = #{recordId,jdbcType=BIGINT}
  21. </select>
  22. <insert id="insert" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiftCarPurseRecord" >
  23. <selectKey resultType="java.lang.Long" keyProperty="recordId" order="AFTER" >
  24. SELECT LAST_INSERT_ID()
  25. </selectKey>
  26. insert into gift_car_purse_record (uid, car_id, car_date,
  27. total_gold_num, is_use, create_time
  28. )
  29. values (#{uid,jdbcType=BIGINT}, #{carId,jdbcType=BIGINT}, #{carDate,jdbcType=INTEGER},
  30. #{totalGoldNum,jdbcType=BIGINT}, #{isUse,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}
  31. )
  32. </insert>
  33. <insert id="insertSelective" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiftCarPurseRecord" >
  34. <selectKey resultType="java.lang.Long" keyProperty="recordId" order="AFTER" >
  35. SELECT LAST_INSERT_ID()
  36. </selectKey>
  37. insert into gift_car_purse_record
  38. <trim prefix="(" suffix=")" suffixOverrides="," >
  39. <if test="uid != null" >
  40. uid,
  41. </if>
  42. <if test="carId != null" >
  43. car_id,
  44. </if>
  45. <if test="carDate != null" >
  46. car_date,
  47. </if>
  48. <if test="totalGoldNum != null" >
  49. total_gold_num,
  50. </if>
  51. <if test="isUse != null" >
  52. is_use,
  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="carId != null" >
  63. #{carId,jdbcType=BIGINT},
  64. </if>
  65. <if test="carDate != null" >
  66. #{carDate,jdbcType=INTEGER},
  67. </if>
  68. <if test="totalGoldNum != null" >
  69. #{totalGoldNum,jdbcType=BIGINT},
  70. </if>
  71. <if test="isUse != null" >
  72. #{isUse,jdbcType=TINYINT},
  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.GiftCarPurseRecord" >
  80. update gift_car_purse_record
  81. <set >
  82. <if test="uid != null" >
  83. uid = #{uid,jdbcType=BIGINT},
  84. </if>
  85. <if test="carId != null" >
  86. car_id = #{carId,jdbcType=BIGINT},
  87. </if>
  88. <if test="carDate != null" >
  89. car_date = #{carDate,jdbcType=INTEGER},
  90. </if>
  91. <if test="totalGoldNum != null" >
  92. total_gold_num = #{totalGoldNum,jdbcType=BIGINT},
  93. </if>
  94. <if test="isUse != null" >
  95. is_use = #{isUse,jdbcType=TINYINT},
  96. </if>
  97. <if test="createTime != null" >
  98. create_time = #{createTime,jdbcType=TIMESTAMP},
  99. </if>
  100. </set>
  101. where record_id = #{recordId,jdbcType=BIGINT}
  102. </update>
  103. <update id="updateByPrimaryKey" parameterType="com.juxiao.xchat.module.xbd.domain.record.GiftCarPurseRecord" >
  104. update gift_car_purse_record
  105. set uid = #{uid,jdbcType=BIGINT},
  106. car_id = #{carId,jdbcType=BIGINT},
  107. car_date = #{carDate,jdbcType=INTEGER},
  108. total_gold_num = #{totalGoldNum,jdbcType=BIGINT},
  109. is_use = #{isUse,jdbcType=TINYINT},
  110. create_time = #{createTime,jdbcType=TIMESTAMP}
  111. where record_id = #{recordId,jdbcType=BIGINT}
  112. </update>
  113. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
  114. delete from gift_car_purse_record
  115. where record_id = #{recordId,jdbcType=BIGINT}
  116. </delete>
  117. <select id="selectGiveCarUsersInfoByQuery" resultType="com.juxiao.xchat.module.xbd.vo.GiveCarUsersVO">
  118. select u.uid, u.erban_no as erBanNo,u.avatar , u.nick,CONCAT(u.erban_no,',',gc.car_id) as erBanNoOrCarId,gc.car_name as carName, gc.gold_price as goldPrice,gc.car_id as carId
  119. from users u
  120. left join gift_car gc on 1 = 1
  121. where u.def_user = 1
  122. and u.erban_no = #{erBanNo} and gc.car_id = #{carId}
  123. </select>
  124. <select id="selectCarDaysByCarId" resultType="java.lang.Integer">
  125. select ifnull(gcpr.car_date,0) as carDate
  126. from users u
  127. LEFT JOIN gift_car gc on 1 = 1
  128. LEFT JOIN gift_car_purse_record gcpr on u.uid = gcpr.uid and gc.car_id = gcpr.car_id
  129. where u.uid = #{uid} and gc.car_id = #{carId}
  130. </select>
  131. <select id="selectGiftCarPurseRecordByUid" resultMap="BaseResultMap">
  132. select
  133. <include refid="Base_Column_List" />
  134. from gift_car_purse_record
  135. where uid = #{uid}
  136. </select>
  137. <select id="selectGiftCarPurseRecordByCarIdOrUid" resultMap="BaseResultMap">
  138. select
  139. <include refid="Base_Column_List" />
  140. from gift_car_purse_record
  141. where uid = #{uid} and car_id = #{carId}
  142. </select>
  143. </mapper>