1
0

AttributeDao.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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="name != null and name.trim() != ''">
  54. AND a.name LIKE concat('%', #{name},'%')
  55. </if>
  56. <if test="categoryName != null and categoryName.trim() != ''">
  57. AND c.name LIKE concat('%', #{categoryName},'%')
  58. </if>
  59. <if test="attributeCategoryId != null and attributeCategoryId.trim() != ''">
  60. AND a.attribute_category_id = #{attributeCategoryId}
  61. </if>
  62. <choose>
  63. <when test="sidx != null and sidx.trim() != ''">
  64. order by ${sidx} ${order}
  65. </when>
  66. <otherwise>
  67. order by a.attribute_category_id desc
  68. </otherwise>
  69. </choose>
  70. <if test="offset != null and limit != null">
  71. limit #{offset}, #{limit}
  72. </if>
  73. </select>
  74. <select id="queryTotal" resultType="int">
  75. select count(*) from mall_attribute a
  76. LEFT JOIN mall_category c ON a.attribute_category_id = c.id
  77. WHERE 1=1
  78. <if test="storeId != null and storeId != ''">
  79. AND a.store_id = #{storeId}
  80. </if>
  81. <if test="merchSn != null and merchSn.trim() != ''">
  82. AND a.merch_sn = #{merchSn}
  83. </if>
  84. <if test="name != null and name.trim() != ''">
  85. AND a.name LIKE concat('%', #{name},'%')
  86. </if>
  87. <if test="categoryName != null and categoryName.trim() != ''">
  88. AND c.name LIKE concat('%', #{categoryName},'%')
  89. </if>
  90. <if test="attributeCategoryId != null and attributeCategoryId.trim() != ''">
  91. AND a.attribute_category_id = #{attributeCategoryId}
  92. </if>
  93. </select>
  94. <insert id="save" parameterType="com.kmall.admin.entity.AttributeEntity" useGeneratedKeys="true" keyProperty="id">
  95. insert into mall_attribute(
  96. `attribute_category_id`,
  97. `name`,
  98. `store_id`,
  99. `merch_sn`,
  100. `input_type`,
  101. `value`,
  102. `sort_order`)
  103. values(
  104. #{attributeCategoryId},
  105. #{name},
  106. #{storeId},
  107. #{merchSn},
  108. #{inputType},
  109. #{value},
  110. #{sortOrder})
  111. </insert>
  112. <update id="update" parameterType="com.kmall.admin.entity.AttributeEntity">
  113. update mall_attribute
  114. <set>
  115. <if test="attributeCategoryId != null">`attribute_category_id` = #{attributeCategoryId},</if>
  116. <if test="name != null">`name` = #{name},</if>
  117. <if test="storeId != null">`store_id` = #{storeId}, </if>
  118. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  119. <if test="inputType != null">`input_type` = #{inputType},</if>
  120. <if test="value != null">`value` = #{value},</if>
  121. <if test="sortOrder != null">`sort_order` = #{sortOrder}</if>
  122. </set>
  123. where id = #{id}
  124. </update>
  125. <delete id="delete">
  126. delete from mall_attribute where id = #{value}
  127. </delete>
  128. <delete id="deleteBatch">
  129. delete from mall_attribute where id in
  130. <foreach item="id" collection="array" open="(" separator="," close=")">
  131. #{id}
  132. </foreach>
  133. </delete>
  134. </mapper>