CustomGoodsCategoryMapper.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.gree.mall.manager.commonmapper.CustomGoodsCategoryMapper">
  4. <resultMap id="listResultMap" type="com.gree.mall.manager.bean.goods.GoodsCategoryBean">
  5. <id column="categoryId" property="categoryId"/>
  6. <collection property="children" column="{categoryId=categoryId}"
  7. select="com.gree.mall.manager.commonmapper.CustomGoodsCategoryMapper.findChildrenByCategoryId">
  8. </collection>
  9. </resultMap>
  10. <select id="list" resultMap="listResultMap">
  11. SELECT
  12. category_id AS categoryId,
  13. name AS name,
  14. status AS status,
  15. img_url AS imgUrl,
  16. goods_num AS goodsNum,
  17. level AS level,
  18. parent_id AS parentId,
  19. sort_num AS sortNum,
  20. main_name AS mainName,
  21. main_number AS mainNumber,
  22. tax_number,
  23. tax_percent,
  24. goods_number,
  25. is_service_show,
  26. update_by,
  27. update_time,
  28. company_wechat_id,
  29. company_name,
  30. create_by,
  31. create_time AS createTime
  32. FROM goods_category
  33. <where>
  34. del = 0
  35. <if test='level != null'>
  36. AND level = #{level}
  37. </if>
  38. <if test="type != null">
  39. and type = #{type}
  40. </if>
  41. <if test='status != null'>
  42. AND status = #{status}
  43. </if>
  44. <if test='name != null'>
  45. AND name like concat('%',#{name,jdbcType=VARCHAR},'%')
  46. </if>
  47. <if test=' companyWechatIds != null and companyWechatIds.size > 0' >
  48. AND company_wechat_id in
  49. <foreach collection="companyWechatIds" open="(" close=")" item="companyWechatId" separator=",">
  50. #{companyWechatId}
  51. </foreach>
  52. </if>
  53. </where>
  54. order by sort_num asc
  55. </select>
  56. <select id="findChildrenByCategoryId" resultType="com.gree.mall.manager.bean.goods.GoodsCategoryBean">
  57. SELECT * FROM goods_category
  58. WHERE parent_id = #{categoryId} AND del = 0
  59. order by sort_num asc
  60. </select>
  61. </mapper>