AttributeDao.xml 4.6 KB

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