LabelRuleDetailMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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="com.yijia.label.mapper.LabelRuleDetailMapper">
  6. <resultMap type="LabelRuleDetail" id="LabelRuleDetailResult">
  7. <result property="id" column="id" />
  8. <result property="parentId" column="parent_id" />
  9. <result property="oilName" column="oil_name" />
  10. <result property="discountTerm" column="discount_term" />
  11. <result property="discountLitersAmt" column="discount_liters_amt" />
  12. <result property="discountAmt" column="discount_amt" />
  13. <result property="createBy" column="create_by" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateBy" column="update_by" />
  16. <result property="updateTime" column="update_time" />
  17. <result property="delFlag" column="del_flag" />
  18. </resultMap>
  19. <sql id="selectLabelRuleDetailVo">
  20. select id, parent_id, oil_name, discount_term, discount_liters_amt, discount_amt, create_by, create_time, update_by, update_time, del_flag
  21. from label_rule_detail
  22. </sql>
  23. <select id="selectLabelRuleDetailList" parameterType="LabelRuleDetail" resultMap="LabelRuleDetailResult">
  24. <include refid="selectLabelRuleDetailVo"/>
  25. <where>
  26. <if test="parentId != null "> and parent_id = #{parentId}</if>
  27. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  28. <if test="discountTerm != null and discountTerm != ''"> and discount_term = #{discountTerm}</if>
  29. <if test="discountLitersAmt != null and discountLitersAmt != ''"> and discount_liters_amt = #{discountLitersAmt}</if>
  30. <if test="discountAmt != null and discountAmt != ''"> and discount_amt = #{discountAmt}</if>
  31. <if test="delFlag != null and delFlag != ''"> and del_flag = #{delFlag}</if>
  32. </where>
  33. </select>
  34. <select id="labelRuleDetailList" parameterType="LabelRuleDetail" resultMap="LabelRuleDetailResult">
  35. select d.*,dept_name as station_name,r.station_id from label_rule r join label_rule_detail d on r.id=d.parent_id
  36. join sys_dept p on r.station_id = p.dept_id
  37. <where>
  38. <if test="parentId != null "> and parent_id = #{parentId}</if>
  39. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  40. <if test="discountTerm != null and discountTerm != ''"> and discount_term = #{discountTerm}</if>
  41. <if test="discountLitersAmt != null and discountLitersAmt != ''"> and discount_liters_amt = #{discountLitersAmt}</if>
  42. <if test="discountAmt != null and discountAmt != ''"> and discount_amt = #{discountAmt}</if>
  43. </where>
  44. </select>
  45. <select id="selectLabelRuleDetailById" parameterType="Integer" resultMap="LabelRuleDetailResult">
  46. <include refid="selectLabelRuleDetailVo"/>
  47. where id = #{id}
  48. </select>
  49. <insert id="insertLabelRuleDetail" parameterType="LabelRuleDetail" useGeneratedKeys="true" keyProperty="id">
  50. insert into label_rule_detail
  51. <trim prefix="(" suffix=")" suffixOverrides=",">
  52. <if test="parentId != null">parent_id,</if>
  53. <if test="oilName != null">oil_name,</if>
  54. <if test="discountTerm != null">discount_term,</if>
  55. <if test="discountLitersAmt != null">discount_liters_amt,</if>
  56. <if test="discountAmt != null">discount_amt,</if>
  57. <if test="createBy != null">create_by,</if>
  58. <if test="createTime != null">create_time,</if>
  59. <if test="updateBy != null">update_by,</if>
  60. <if test="updateTime != null">update_time,</if>
  61. <if test="delFlag != null">del_flag,</if>
  62. </trim>
  63. <trim prefix="values (" suffix=")" suffixOverrides=",">
  64. <if test="parentId != null">#{parentId},</if>
  65. <if test="oilName != null">#{oilName},</if>
  66. <if test="discountTerm != null">#{discountTerm},</if>
  67. <if test="discountLitersAmt != null">#{discountLitersAmt},</if>
  68. <if test="discountAmt != null">#{discountAmt},</if>
  69. <if test="createBy != null">#{createBy},</if>
  70. <if test="createTime != null">#{createTime},</if>
  71. <if test="updateBy != null">#{updateBy},</if>
  72. <if test="updateTime != null">#{updateTime},</if>
  73. <if test="delFlag != null">#{delFlag},</if>
  74. </trim>
  75. </insert>
  76. <update id="updateLabelRuleDetail" parameterType="LabelRuleDetail">
  77. update label_rule_detail
  78. <trim prefix="SET" suffixOverrides=",">
  79. <if test="parentId != null">parent_id = #{parentId},</if>
  80. <if test="oilName != null">oil_name = #{oilName},</if>
  81. <if test="discountTerm != null">discount_term = #{discountTerm},</if>
  82. <if test="discountLitersAmt != null">discount_liters_amt = #{discountLitersAmt},</if>
  83. <if test="discountAmt != null">discount_amt = #{discountAmt},</if>
  84. <if test="createBy != null">create_by = #{createBy},</if>
  85. <if test="createTime != null">create_time = #{createTime},</if>
  86. <if test="updateBy != null">update_by = #{updateBy},</if>
  87. <if test="updateTime != null">update_time = #{updateTime},</if>
  88. <if test="delFlag != null">del_flag = #{delFlag},</if>
  89. </trim>
  90. where id = #{id}
  91. </update>
  92. <delete id="deleteLabelRuleDetailById" parameterType="Integer">
  93. delete from label_rule_detail where id = #{id}
  94. </delete>
  95. <delete id="deleteLabelRuleDetailByIds" parameterType="String">
  96. delete from label_rule_detail where id in
  97. <foreach item="id" collection="array" open="(" separator="," close=")">
  98. #{id}
  99. </foreach>
  100. </delete>
  101. </mapper>