RewardClaimsMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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, typeHandler=org.apache.ibatis.type.JdbcType.VARCHAR},</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="id != null">AND id = #{id}</if>
  85. <if test="tournamentId != null">AND tournament_id = #{tournamentId}</if>
  86. <if test="playerId != null">AND player_id = #{playerId}</if>
  87. <if test="rank != null">AND rank = #{rank}</if>
  88. <if test="playerName != null and playerName != ''">
  89. AND player_name LIKE CONCAT('%', #{playerName}, '%')
  90. </if>
  91. <if test="phone != null and phone != ''">AND phone = #{phone}</if>
  92. <if test="claimed != null">AND claimed = #{claimed}</if>
  93. </where>
  94. </select>
  95. <!-- 根据主键删除 -->
  96. <delete id="deleteById">
  97. DELETE FROM reward_claims
  98. WHERE id = #{id}
  99. </delete>
  100. <!-- 条件删除 -->
  101. <delete id="deleteByCriteria">
  102. DELETE FROM reward_claims
  103. <where>
  104. <if test="id != null">AND id = #{id}</if>
  105. <if test="tournamentId != null">AND tournament_id = #{tournamentId}</if>
  106. </where>
  107. </delete>
  108. </mapper>