TournamentEntryConditionsMapper.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.TournamentEntryConditionsMapper">
  6. <!-- 插入数据,字段为空则插入默认值或不插入 -->
  7. <insert id="insert" useGeneratedKeys="true" keyProperty="id">
  8. INSERT INTO tournament_entry_conditions
  9. <trim prefix="(" suffix=")" suffixOverrides=",">
  10. <if test="tournamentId != null and tournamentId.toString() != ''">tournament_id,</if>
  11. <if test="itemId != null and itemId.toString() != ''">item_id,</if>
  12. <if test="requiredQuantity != null and requiredQuantity.toString() != ''">required_quantity,</if>
  13. </trim>
  14. VALUES
  15. <trim prefix="(" suffix=")" suffixOverrides=",">
  16. <if test="tournamentId != null and tournamentId.toString() != ''">#{tournamentId},</if>
  17. <if test="itemId != null and itemId.toString() != ''">#{itemId},</if>
  18. <if test="requiredQuantity != null and requiredQuantity.toString() != ''">#{requiredQuantity},</if>
  19. </trim>
  20. </insert>
  21. <!-- 动态更新记录 -->
  22. <update id="updateByTournamentId">
  23. UPDATE tournament_entry_conditions
  24. <set>
  25. <if test="itemId != null and itemId.toString() != ''">
  26. item_id = #{itemId},
  27. </if>
  28. <if test="requiredQuantity != null and requiredQuantity.toString() != ''">
  29. required_quantity = #{requiredQuantity},
  30. </if>
  31. updated_at = CURRENT_TIMESTAMP
  32. </set>
  33. WHERE tournament_id = #{tournamentId}
  34. </update>
  35. <!-- 删除记录,只在id有效时删除 -->
  36. <delete id="deleteById">
  37. DELETE FROM tournament_entry_conditions
  38. WHERE id = #{id}
  39. AND #{id} IS NOT NULL
  40. </delete>
  41. <!-- 查询单条记录 -->
  42. <select id="selectById" resultType="org.dromara.business.domain.vo.TournamentEntryConditionsVo">
  43. SELECT *
  44. FROM tournament_entry_conditions
  45. WHERE id = #{id}
  46. </select>
  47. <!-- 根据比赛ID查询报名条件 -->
  48. <select id="selectByTournamentId" resultType="org.dromara.business.domain.vo.TournamentEntryConditionsVo">
  49. SELECT *
  50. FROM tournament_entry_conditions
  51. WHERE tournament_id = #{tournamentId}
  52. </select>
  53. <select id="selectByTournamentInfo" resultType="org.dromara.business.domain.vo.TournamentEntryConditionsVo">
  54. SELECT a.tournament_id,a.item_id,a.required_quantity,b.name itemsName
  55. FROM tournament_entry_conditions a left join items b on a.item_id=b.id
  56. WHERE a.tournament_id = #{tournamentId}
  57. </select>
  58. </mapper>