SpuCategoryMapper.xml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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="com.poyee.mapper.SpuCategoryMapper">
  6. <sql id="spuCategoryQuery">
  7. select id,category_name categoryName,is_cascade isCascade, sub_label subLabel,sort,parent_id parentId,icon_url iconUrl,status,create_time createTime,update_time updateTime from spu_category
  8. </sql>
  9. <select id="querySpuCategory" resultType="spuCategoryDto">
  10. <include refid="spuCategoryQuery"></include>
  11. </select>
  12. <select id="getSpuSubCategory" resultType="spuCategoryDto">
  13. <include refid="spuCategoryQuery"></include>
  14. <where>
  15. parent_id=#{id}
  16. </where>
  17. </select>
  18. <insert id="createCategory" parameterType="com.poyee.domain.SpuCategory">
  19. insert into spu_category (category_name,is_cascade,sub_label,sort,parent_id,icon_url,status,create_time,update_time)
  20. values (#{categoryName},#{isCascade},#{subLabel},#{sort},#{parentId},#{iconUrl},#{status},#{createTime},#{updateTime})
  21. </insert>
  22. <update id="updateCategory">
  23. update spu_category
  24. <trim prefix="set" suffixOverrides=",">
  25. <if test="categoryName!=null and categoryName!=''">
  26. category_name=#{categoryName},
  27. </if>
  28. <if test="isCascade!=null">
  29. is_cascade=#{isCascade},
  30. </if>
  31. <if test="subLabel!=null and subLabel!=''">
  32. sub_label=#{subLabel},
  33. </if>
  34. <if test="sort!=null">
  35. sort=#{sort},
  36. </if>
  37. <if test="parentId!=null">
  38. parent_id=#{parentId},
  39. </if>
  40. <if test="iconUrl!=null and iconUrl!=''">
  41. icon_url=#{iconUrl},
  42. </if>
  43. <if test="status!=null">
  44. status=#{status},
  45. </if>
  46. <if test="updateTime!=null">
  47. update_time=#{updateTime},
  48. </if>
  49. </trim>
  50. where id=#{id}
  51. </update>
  52. </mapper>