ProductMapper.xml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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="cn.cslg.pas.mapper.ProductMapper">
  4. <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
  5. <select id="getProduct" resultType="cn.cslg.pas.common.vo.business.ProductVO">
  6. select product.id as id ,product.name as name , product.license_rate as licenseRate
  7. ,product.category_id as categoryId,product.show_type as showType
  8. ,product.description as description,
  9. product.create_id as createId, product.tenant_id as tenantId,
  10. product.market_time as
  11. marketTime,product.create_time as createTime,
  12. product.company_name,product.description as description
  13. from
  14. product as product left join product_category as category
  15. on category.id = product.category_id
  16. <if test="sql1!=''">
  17. where ${sql1}
  18. </if>
  19. ${sql2} ${sql3}
  20. </select>
  21. <select id="getProductCount" resultType="java.lang.Long">
  22. select count(*)
  23. from product as product left join product_category as category
  24. on category.id = product.category_id
  25. <if test="sql!=''">
  26. where ${sql}
  27. </if>
  28. </select>
  29. <select id="getProductOrCategoryNameOrder" resultType="cn.cslg.pas.common.vo.ProductOrCategoryVO">
  30. select *
  31. from (select id as id, name as name, 2 as type
  32. from product
  33. union all
  34. select id as id, name as name, 3 as type
  35. from product_category) as c
  36. order by name
  37. <if test="orderType==0">
  38. asc
  39. </if>
  40. <if test="orderType!=0">
  41. desc
  42. </if>
  43. </select>
  44. </mapper>