PhysicalMemberLevelConfigMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.physical.mapper.PhysicalMemberLevelConfigMapper">
  6. <!-- 字段列表(用于 SELECT) -->
  7. <sql id="columns">
  8. id,
  9. level_name,
  10. level_code,
  11. status,
  12. image_url,
  13. main_tournament_gift_count,
  14. side_tournament_gift_count,
  15. service_voucher_gift_count,
  16. allow_gift,
  17. promotion_conditions,
  18. retention_conditions,
  19. created_at,
  20. updated_at,
  21. deleted_at
  22. </sql>
  23. <!-- 基础 WHERE 条件(排除已逻辑删除的记录) -->
  24. <sql id="where_not_deleted">
  25. WHERE deleted_at IS NULL
  26. </sql>
  27. <!-- 1. 查询所有(未删除) -->
  28. <select id="selectPhysicalMemberLevelConfigPage" resultType="org.dromara.physical.domain.vo.PhysicalMemberLevelConfigVo">
  29. SELECT
  30. <include refid="columns"/>
  31. FROM physical_member_level_config
  32. ${ew.customSqlSegment}
  33. </select>
  34. <!-- 2. 根据 ID 查询 -->
  35. <select id="selectPhysicalMemberLevelConfigById" parameterType="long" resultType="org.dromara.physical.domain.vo.PhysicalMemberLevelConfigVo">
  36. SELECT
  37. <include refid="columns"/>
  38. FROM physical_member_level_config
  39. WHERE id = #{id}
  40. </select>
  41. <!-- 1. 查询所有(未删除) -->
  42. <select id="selectPhysicalMemberLevelConfigList" resultType="org.dromara.physical.domain.vo.PhysicalMemberLevelConfigVo">
  43. SELECT
  44. <include refid="columns"/>
  45. FROM physical_member_level_config
  46. ${ew.customSqlSegment}
  47. </select>
  48. <!-- 5. 新增记录 -->
  49. <insert id="insertPhysicalMemberLevelConfig" useGeneratedKeys="true" keyProperty="id">
  50. INSERT INTO physical_member_level_config (
  51. <trim suffixOverrides=",">
  52. <if test="levelName != null and levelName != ''">level_name,</if>
  53. <if test="levelCode != null and levelCode != ''">level_code,</if>
  54. <if test="status != null and status != ''">status,</if>
  55. <if test="imageUrl != null">image_url,</if>
  56. <if test="mainTournamentGiftCount != null">main_tournament_gift_count,</if>
  57. <if test="sideTournamentGiftCount != null">side_tournament_gift_count,</if>
  58. <if test="serviceVoucherGiftCount != null">service_voucher_gift_count,</if>
  59. <if test="allowGift != null">allow_gift,</if>
  60. <if test="promotionConditions != null">promotion_conditions,</if>
  61. <if test="retentionConditions != null">retention_conditions,</if>
  62. created_at,
  63. updated_at
  64. </trim>
  65. ) VALUES (
  66. <trim suffixOverrides=",">
  67. <if test="levelName != null and levelName != ''">#{levelName},</if>
  68. <if test="levelCode != null and levelCode != ''">#{levelCode},</if>
  69. <if test="status != null and status != ''">#{status},</if>
  70. <if test="imageUrl != null">#{imageUrl},</if>
  71. <if test="mainTournamentGiftCount != null">#{mainTournamentGiftCount},</if>
  72. <if test="sideTournamentGiftCount != null">#{sideTournamentGiftCount},</if>
  73. <if test="serviceVoucherGiftCount != null">#{serviceVoucherGiftCount},</if>
  74. <if test="allowGift != null">#{allowGift},</if>
  75. <if test="promotionConditions != null">#{promotionConditions},</if>
  76. <if test="retentionConditions != null">#{retentionConditions},</if>
  77. NOW(),
  78. NOW()
  79. </trim>
  80. )
  81. </insert>
  82. <!-- 6. 更新记录(仅更新非空字段) -->
  83. <update id="updatePhysicalMemberLevelConfigById">
  84. UPDATE physical_member_level_config
  85. <set>
  86. <if test="levelName != null and levelName != ''">level_name = #{levelName},</if>
  87. <if test="levelCode != null and levelCode != ''">level_code = #{levelCode},</if>
  88. <if test="status != null and status != ''">status = #{status},</if>
  89. <if test="imageUrl != null">image_url = #{imageUrl},</if>
  90. <if test="mainTournamentGiftCount != null">main_tournament_gift_count = #{mainTournamentGiftCount},</if>
  91. <if test="sideTournamentGiftCount != null">side_tournament_gift_count = #{sideTournamentGiftCount},</if>
  92. <if test="serviceVoucherGiftCount != null">service_voucher_gift_count = #{serviceVoucherGiftCount},</if>
  93. <if test="allowGift != null">allow_gift = #{allowGift},</if>
  94. <if test="promotionConditions != null">promotion_conditions = #{promotionConditions},</if>
  95. <if test="retentionConditions != null">retention_conditions = #{retentionConditions},</if>
  96. updated_at = NOW()
  97. </set>
  98. WHERE id = #{id}
  99. AND deleted_at IS NULL
  100. </update>
  101. <!-- 删除记录 -->
  102. <delete id="deletePhysicalMemberLevelConfigById">
  103. DELETE FROM physical_member_level_config
  104. <where>
  105. id IN
  106. <foreach item="id" collection="ids" open="(" separator="," close=")">
  107. <if test="id > 0">
  108. #{id}
  109. </if>
  110. </foreach>
  111. </where>
  112. </delete>
  113. </mapper>