AttributeDao.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.kmall.admin.dao.AttributeDao">
  4. <resultMap type="com.kmall.admin.entity.AttributeEntity" id="attributeMap">
  5. <result property="id" column="id"/>
  6. <result property="attributeCategoryId" column="attribute_category_id"/>
  7. <result property="name" column="name"/>
  8. <result property="storeId" column="store_id"/>
  9. <result property="merchSn" column="merch_sn"/>
  10. <result property="inputType" column="input_type"/>
  11. <result property="value" column="value"/>
  12. <result property="sortOrder" column="sort_order"/>
  13. <result property="storeName" column="storeName"/>
  14. <result column="merchName" property="merchName" />
  15. </resultMap>
  16. <select id="queryObject" resultType="com.kmall.admin.entity.AttributeEntity">
  17. select
  18. id,
  19. attribute_category_id,
  20. name,
  21. store_id,
  22. merch_sn,
  23. input_type,
  24. value,
  25. sort_order
  26. from mall_attribute
  27. where id = #{id}
  28. </select>
  29. <select id="queryList" resultType="com.kmall.admin.entity.AttributeEntity">
  30. SELECT
  31. a.id,
  32. a.attribute_category_id,
  33. a.NAME,
  34. a.store_id,
  35. a.merch_sn,
  36. a.input_type,
  37. a.VALUE,
  38. a.sort_order,
  39. c.NAME category_name,
  40. s.store_name storeName,
  41. m.merch_name merchName
  42. FROM mall_attribute a
  43. LEFT JOIN mall_category c ON a.attribute_category_id = c.id
  44. left join mall_store s on a.store_id = s.id
  45. left join mall_merch m on a.merch_sn = m.merch_sn
  46. WHERE 1=1
  47. <if test="storeId != null and storeId != ''">
  48. AND a.store_id = #{storeId}
  49. </if>
  50. <if test="merchSn != null and merchSn.trim() != ''">
  51. AND a.merch_sn = #{merchSn}
  52. </if>
  53. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  54. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  55. </if>
  56. <if test="name != null and name.trim() != ''">
  57. AND a.name LIKE concat('%', #{name},'%')
  58. </if>
  59. <if test="categoryName != null and categoryName.trim() != ''">
  60. AND c.name LIKE concat('%', #{categoryName},'%')
  61. </if>
  62. <if test="attributeCategoryId != null and attributeCategoryId.trim() != ''">
  63. AND a.attribute_category_id = #{attributeCategoryId}
  64. </if>
  65. <choose>
  66. <when test="sidx != null and sidx.trim() != ''">
  67. order by ${sidx} ${order}
  68. </when>
  69. <otherwise>
  70. order by a.attribute_category_id desc
  71. </otherwise>
  72. </choose>
  73. <if test="offset != null and limit != null">
  74. limit #{offset}, #{limit}
  75. </if>
  76. </select>
  77. <select id="queryTotal" resultType="int">
  78. select count(*) from mall_attribute a
  79. LEFT JOIN mall_category c ON a.attribute_category_id = c.id
  80. left join mall_store s on a.store_id = s.id
  81. WHERE 1=1
  82. <if test="storeId != null and storeId != ''">
  83. AND a.store_id = #{storeId}
  84. </if>
  85. <if test="merchSn != null and merchSn.trim() != ''">
  86. AND a.merch_sn = #{merchSn}
  87. </if>
  88. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  89. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  90. </if>
  91. <if test="name != null and name.trim() != ''">
  92. AND a.name LIKE concat('%', #{name},'%')
  93. </if>
  94. <if test="categoryName != null and categoryName.trim() != ''">
  95. AND c.name LIKE concat('%', #{categoryName},'%')
  96. </if>
  97. <if test="attributeCategoryId != null and attributeCategoryId.trim() != ''">
  98. AND a.attribute_category_id = #{attributeCategoryId}
  99. </if>
  100. </select>
  101. <insert id="save" parameterType="com.kmall.admin.entity.AttributeEntity" useGeneratedKeys="true" keyProperty="id">
  102. insert into mall_attribute(
  103. `attribute_category_id`,
  104. `name`,
  105. `store_id`,
  106. `merch_sn`,
  107. `input_type`,
  108. `value`,
  109. `sort_order`)
  110. values(
  111. #{attributeCategoryId},
  112. #{name},
  113. #{storeId},
  114. #{merchSn},
  115. #{inputType},
  116. #{value},
  117. #{sortOrder})
  118. </insert>
  119. <update id="update" parameterType="com.kmall.admin.entity.AttributeEntity">
  120. update mall_attribute
  121. <set>
  122. <if test="attributeCategoryId != null">`attribute_category_id` = #{attributeCategoryId},</if>
  123. <if test="name != null">`name` = #{name},</if>
  124. <if test="storeId != null">`store_id` = #{storeId}, </if>
  125. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  126. <if test="inputType != null">`input_type` = #{inputType},</if>
  127. <if test="value != null">`value` = #{value},</if>
  128. <if test="sortOrder != null">`sort_order` = #{sortOrder}</if>
  129. </set>
  130. where id = #{id}
  131. </update>
  132. <delete id="delete">
  133. delete from mall_attribute where id = #{value}
  134. </delete>
  135. <delete id="deleteBatch">
  136. delete from mall_attribute where id in
  137. <foreach item="id" collection="array" open="(" separator="," close=")">
  138. #{id}
  139. </foreach>
  140. </delete>
  141. </mapper>