SpuCategoryMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.hobbystocks.auc.mapper.SpuCategoryMapper">
  6. <resultMap type="cn.hobbystocks.auc.domain.SpuCategory" id="BaseResultMap">
  7. <id property="id" column="id" />
  8. <result property="categoryName" column="category_name" />
  9. <result property="isCascade" column="is_cascade" />
  10. <result property="subLabel" column="sub_label" />
  11. <result property="sort" column="sort" />
  12. <result property="parentId" column="parent_id" />
  13. <result property="iconUrl" column="icon_url" />
  14. <result property="status" column="status" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateTime" column="update_time" />
  17. </resultMap>
  18. <sql id="baseColumnList">
  19. select id,category_name,is_cascade, sub_label,sort,parent_id,icon_url,status,create_time,update_time from spu_category
  20. </sql>
  21. <select id="querySpuCategory" resultMap="BaseResultMap">
  22. <include refid="baseColumnList"/>
  23. </select>
  24. <select id="getSpuSubCategory" resultMap="BaseResultMap">
  25. <include refid="baseColumnList"/>
  26. <where>
  27. parent_id=#{id}
  28. </where>
  29. </select>
  30. <select id="selectAllMainCategory" resultMap="BaseResultMap">
  31. <include refid="baseColumnList"/>
  32. <where>
  33. AND parent_id = 0
  34. AND status = 1
  35. AND del_flag = 0
  36. </where>
  37. </select>
  38. <select id="listChildByParentId" resultType="java.lang.Long">
  39. SELECT id FROM lot_category
  40. WHERE parent_id = #{mainCategoryId}
  41. AND del_flag = 0
  42. AND status = 1
  43. </select>
  44. <select id="selectChildCategoryByParentIds" resultType="cn.hobbystocks.auc.domain.SpuCategory">
  45. <include refid="baseColumnList"/>
  46. <where>
  47. AND status = 1
  48. AND del_flag = 0
  49. AND parent_id IN
  50. <foreach collection="list" item="parentId" open="(" separator="," close=")">
  51. #{parentId}
  52. </foreach>
  53. </where>
  54. </select>
  55. <select id="listLotIdsByCategoryIds" resultType="java.lang.Long">
  56. SELECT DISTINCT lot_id
  57. FROM lot_category_relation
  58. <where>
  59. category_id IN
  60. <foreach collection="categoryIds" item="categoryId" open="(" separator="," close=")">
  61. #{categoryId}
  62. </foreach>
  63. AND del_flag = 0
  64. </where>
  65. </select>
  66. <insert id="createCategory" parameterType="cn.hobbystocks.auc.domain.SpuCategory">
  67. insert into spu_category (category_name,is_cascade,sub_label,sort,parent_id,icon_url,status,create_time,update_time)
  68. values (#{categoryName},#{isCascade},#{subLabel},#{sort},#{parentId},#{iconUrl},#{status},#{createTime},#{updateTime})
  69. </insert>
  70. <update id="updateCategory">
  71. update spu_category
  72. <trim prefix="set" suffixOverrides=",">
  73. <if test="categoryName!=null and categoryName!=''">
  74. category_name=#{categoryName},
  75. </if>
  76. <if test="isCascade!=null">
  77. is_cascade=#{isCascade},
  78. </if>
  79. <if test="subLabel!=null and subLabel!=''">
  80. sub_label=#{subLabel},
  81. </if>
  82. <if test="sort!=null">
  83. sort=#{sort},
  84. </if>
  85. <if test="parentId!=null">
  86. parent_id=#{parentId},
  87. </if>
  88. <if test="iconUrl!=null and iconUrl!=''">
  89. icon_url=#{iconUrl},
  90. </if>
  91. <if test="status!=null">
  92. status=#{status},
  93. </if>
  94. <if test="updateTime!=null">
  95. update_time=#{updateTime},
  96. </if>
  97. </trim>
  98. where id=#{id}
  99. </update>
  100. </mapper>