AssessRuleMapper.xml 5.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.zhyc.xps.lylc.mapper.AssessRuleMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="AssessRuleDtoResultMap" type="com.zhyc.xps.lylc.dto.AssessRuleDto">
  6. <result column="story_id" property="storyId" jdbcType="BIGINT" />
  7. <result column="story_title" property="storyTitle" jdbcType="VARCHAR" />
  8. <result column="rule_percent" property="rulePercent" jdbcType="BIGINT" />
  9. <result column="rule_desc" property="ruleDesc" jdbcType="VARCHAR" />
  10. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  11. </resultMap>
  12. <!-- 通用查询结果列 -->
  13. <sql id="AssessRuleDto_Cols">
  14. A.story_id,
  15. B.story_title,
  16. A.rule_percent,
  17. A.is_fixed,
  18. A.rule_desc
  19. </sql>
  20. <!--基于ID查询-->
  21. <select id="getById" resultMap="AssessRuleDtoResultMap">
  22. SELECT
  23. <include refid="AssessRuleDto_Cols"/>
  24. FROM assess_rule AS A
  25. LEFT JOIN assess_story AS B ON (A.story_id = B.story_id)
  26. WHERE A.deleted_flag = 0
  27. <if test="storyId != null">
  28. AND A.story_id = #{storyId ,jdbcType=BIGINT}
  29. </if>
  30. </select>
  31. <!--分页查询-->
  32. <select id="getByPage" resultMap="AssessRuleDtoResultMap" parameterType="java.util.Map" >
  33. SELECT
  34. <include refid="AssessRuleDto_Cols"/>
  35. FROM assess_rule AS A
  36. LEFT JOIN assess_story AS B ON (A.story_id = B.story_id)
  37. WHERE A.deleted_flag = 0
  38. <if test="keywords != null and keywords != ''">
  39. and B.story_title like "%"#{keywords}"%"
  40. </if>
  41. ORDER BY A.story_id ASC
  42. </select>
  43. <!--列表查询-->
  44. <select id="getByList" resultMap="AssessRuleDtoResultMap" >
  45. SELECT
  46. <include refid="AssessRuleDto_Cols"/>
  47. FROM assess_rule AS A
  48. LEFT JOIN assess_story AS B ON (A.story_id = B.story_id)
  49. WHERE A.deleted_flag = 0
  50. </select>
  51. <insert id="create" parameterType="com.zhyc.xps.lylc.entity.AssessRule">
  52. INSERT INTO assess_rule
  53. <trim prefix="(" suffix=")" suffixOverrides=",">
  54. <if test="storyId != null">
  55. story_id,
  56. </if>
  57. <if test="rulePercent != null">
  58. rule_percent,
  59. </if>
  60. <if test="ruleDesc != null and ruleDesc != ''">
  61. rule_desc,
  62. </if>
  63. <if test="isFixed != null">
  64. is_fixed,
  65. </if>
  66. <if test="createdBy != null">
  67. created_by,
  68. </if>
  69. <if test="createdAt != null">
  70. created_at,
  71. </if>
  72. </trim>
  73. <trim prefix="values (" suffix=")" suffixOverrides=",">
  74. <if test="storyId != null">
  75. #{storyId ,jdbcType=BIGINT},
  76. </if>
  77. <if test="rulePercent != null ">
  78. #{rulePercent ,jdbcType=BIGINT},
  79. </if>
  80. <if test="ruleDesc != null and ruleDesc != ''">
  81. #{ruleDesc ,jdbcType=VARCHAR},
  82. </if>
  83. <if test="isFixed != null">
  84. #{isFixed,jdbcType=BIGINT},
  85. </if>
  86. <if test="createdBy != null">
  87. #{createdBy ,jdbcType=BIGINT},
  88. </if>
  89. <if test="createdAt != null">
  90. #{createdAt ,jdbcType=TIMESTAMP},
  91. </if>
  92. </trim>
  93. </insert>
  94. <!--更新-->
  95. <update id="update" parameterType="com.zhyc.xps.lylc.entity.AssessRule">
  96. UPDATE assess_rule
  97. <trim suffixOverrides=",">
  98. <set>
  99. <if test="rulePercent != null">
  100. rule_percent = #{rulePercent ,jdbcType=BIGINT},
  101. </if>
  102. <if test="ruleDesc != null and ruleDesc != ''">
  103. rule_desc = #{ruleDesc, jdbcType=VARCHAR},
  104. </if>
  105. <if test="updatedBy != null ">
  106. updated_by = #{updatedBy ,jdbcType=BIGINT},
  107. </if>
  108. <if test="updatedAt != null">
  109. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  110. </if>
  111. </set>
  112. </trim>
  113. WHERE 1 = 1
  114. <if test="storyId != null">
  115. AND story_id = #{storyId ,jdbcType=BIGINT}
  116. </if>
  117. </update>
  118. <!--删除-->
  119. <update id="delete" parameterType="java.util.Map">
  120. UPDATE assess_rule
  121. <trim suffixOverrides=",">
  122. <set>
  123. <if test="deletedFlag != null">
  124. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  125. </if>
  126. <if test="deletedTime != null">
  127. deleted_time = #{deletedTime,jdbcType=TIMESTAMP},
  128. </if>
  129. <if test="deletedBy != null">
  130. deleted_by = #{deletedBy,jdbcType=BIGINT},
  131. </if>
  132. </set>
  133. </trim>
  134. WHERE 1 = 1
  135. <if test="storyId != null">
  136. AND story_id = #{storyId ,jdbcType=BIGINT}
  137. </if>
  138. </update>
  139. </mapper>