ApiAttributeMapper.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.api.dao.ApiAttributeMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.AttributeVo" id="attributeMap">
  6. <result property="id" column="id"/>
  7. <result property="attribute_category_id" column="attribute_category_id"/>
  8. <result property="name" column="name"/>
  9. <result property="input_type" column="input_type"/>
  10. <result property="value" column="value"/>
  11. <result property="sort_order" column="sort_order"/>
  12. </resultMap>
  13. <select id="queryObject" resultMap="attributeMap">
  14. select * from mall_attribute where id = #{value}
  15. </select>
  16. <select id="queryList" resultMap="attributeMap">
  17. select
  18. <if test="fields != null and fields != ''">
  19. ${fields}
  20. </if>
  21. <if test="fields == null or fields == ''">
  22. *
  23. </if>
  24. from mall_attribute na
  25. left join mall_goods_attribute nga ON nga.attribute_id=na.id
  26. <where>
  27. <if test="goods_id != null">
  28. and nga.goods_id = #{goods_id}
  29. </if>
  30. </where>
  31. <choose>
  32. <when test="sidx != null and sidx.trim() != ''">
  33. order by ${sidx} ${order}
  34. </when>
  35. <otherwise>
  36. order by na.id desc
  37. </otherwise>
  38. </choose>
  39. <if test="offset != null and limit != null">
  40. limit #{offset}, #{limit}
  41. </if>
  42. </select>
  43. <select id="queryTotal" resultType="int">
  44. select count(*) from mall_attribute
  45. </select>
  46. <insert id="save" parameterType="com.kmall.api.entity.AttributeVo" useGeneratedKeys="true" keyProperty="id">
  47. insert into mall_attribute
  48. (
  49. `attribute_category_id`,
  50. `name`,
  51. `input_type`,
  52. `value`,
  53. `sort_order`
  54. )
  55. values
  56. (
  57. #{attribute_category_id},
  58. #{name},
  59. #{input_type},
  60. #{value},
  61. #{sort_order}
  62. )
  63. </insert>
  64. <update id="update" parameterType="com.kmall.api.entity.AttributeVo">
  65. update mall_attribute
  66. <set>
  67. <if test="attribute_category_id != null">`attribute_category_id` = #{attribute_category_id},</if>
  68. <if test="name != null">`name` = #{name},</if>
  69. <if test="input_type != null">`input_type` = #{input_type},</if>
  70. <if test="value != null">`value` = #{value},</if>
  71. <if test="sort_order != null">`sort_order` = #{sort_order}</if>
  72. </set>
  73. where id = #{id}
  74. </update>
  75. <delete id="delete">
  76. delete from mall_attribute where id = #{value}
  77. </delete>
  78. <delete id="deleteBatch">
  79. delete from mall_attribute where id in
  80. <foreach item="id" collection="array" open="(" separator="," close=")">
  81. #{id}
  82. </foreach>
  83. </delete>
  84. </mapper>