RewardClaimsMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="org.dromara.business.mapper.RewardClaimsMapper">
  6. <select id="selectVoPage2" resultType="org.dromara.business.domain.vo.RewardClaimsVo">
  7. SELECT
  8. id,
  9. tournament_id,
  10. player_id,
  11. `rank`,
  12. player_name,
  13. phone,
  14. reward_json,
  15. claimed,
  16. created_at,
  17. updated_at
  18. FROM
  19. reward_claims ${ew.customSqlSegment}
  20. </select>
  21. <!-- 插入数据:每个字段都做非空判断 -->
  22. <insert id="insert" useGeneratedKeys="true" keyProperty="id">
  23. INSERT INTO reward_claims
  24. <trim prefix="(" suffix=")" suffixOverrides=",">
  25. <if test="tournamentId != null">tournament_id,</if>
  26. <if test="playerId != null">player_id,</if>
  27. <if test="rank != null">`rank`,</if>
  28. <if test="playerName != null and playerName != ''">player_name,</if>
  29. <if test="phone != null and phone != ''">phone,</if>
  30. <if test="rewardJson != null">reward_json,</if>
  31. <if test="claimed != null">claimed,</if>
  32. </trim>
  33. VALUES
  34. <trim prefix="(" suffix=")" suffixOverrides=",">
  35. <if test="tournamentId != null">#{tournamentId},</if>
  36. <if test="playerId != null">#{playerId},</if>
  37. <if test="rank != null">#{rank},</if>
  38. <if test="playerName != null and playerName != ''">#{playerName},</if>
  39. <if test="phone != null and phone != ''">#{phone},</if>
  40. <if test="rewardJson != null">#{rewardJson},</if>
  41. <if test="claimed != null">#{claimed},</if>
  42. </trim>
  43. </insert>
  44. <!-- 更新数据:每个字段都做非空判断 -->
  45. <update id="updateById">
  46. UPDATE reward_claims
  47. <set>
  48. <if test="tournamentId != null">
  49. tournament_id = #{tournamentId},
  50. </if>
  51. <if test="playerId != null">
  52. player_id = #{playerId},
  53. </if>
  54. <if test="rank != null">
  55. rank = #{rank},
  56. </if>
  57. <if test="playerName != null and playerName != ''">
  58. player_name = #{playerName},
  59. </if>
  60. <if test="phone != null and phone != ''">
  61. phone = #{phone},
  62. </if>
  63. <if test="rewardJson != null">
  64. reward_json = #{rewardJson, typeHandler=org.apache.ibatis.type.JdbcType.VARCHAR},
  65. </if>
  66. <if test="claimed != null">
  67. claimed = #{claimed},
  68. </if>
  69. updated_at = NOW()
  70. </set>
  71. WHERE id = #{id}
  72. </update>
  73. <!-- 根据主键查询 -->
  74. <select id="selectInfoById" resultType="org.dromara.business.domain.vo.RewardClaimsVo">
  75. SELECT *
  76. FROM reward_claims
  77. WHERE id = #{id}
  78. </select>
  79. <!-- 条件查询 -->
  80. <select id="selectByCriteria" resultType="org.dromara.business.domain.vo.RewardClaimsVo">
  81. SELECT *
  82. FROM reward_claims
  83. <where>
  84. <if test="tournamentId != null">AND tournament_id = #{tournamentId}</if>
  85. </where>
  86. </select>
  87. <!-- 根据主键删除 -->
  88. <delete id="deleteById">
  89. DELETE FROM reward_claims
  90. WHERE id = #{id}
  91. </delete>
  92. <!-- 条件删除 -->
  93. <update id="deleteByCriteria">
  94. UPDATE reward_claims SET
  95. is_delete = true
  96. <where>
  97. <if test="id != null">AND id = #{id}</if>
  98. <if test="tournamentId != null">AND tournament_id = #{tournamentId}</if>
  99. </where>
  100. </update>
  101. <update id="updateUserRewardClaimed">
  102. UPDATE reward_claims
  103. SET
  104. claimed = 1,
  105. updated_at = NOW()
  106. WHERE id=#{id}
  107. </update>
  108. <update id="delUserRewardClaimed">
  109. UPDATE reward_claims
  110. SET
  111. is_delete = true
  112. updated_at = NOW()
  113. WHERE id=#{id}
  114. </update>
  115. <select id="selectUserRewardCount" resultType="int">
  116. SELECT COUNT(DISTINCT tournament_id) AS rewardCount
  117. FROM reward_claims
  118. WHERE player_id = #{playerId}
  119. </select>
  120. </mapper>