MaterialCategoryDao.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.backendsys.modules.material.dao.MaterialCategoryDao">
  4. <sql id="includeMaterialCategory">
  5. mc.id,
  6. mc.id category_id,
  7. mc.lora_id,
  8. mcl.lora_name,
  9. mc.category_name,
  10. mc.is_share,
  11. mc.sort
  12. </sql>
  13. <!-- COALESCE(content_type, '') content_type, -->
  14. <resultMap id="resultMapMaterialCategory" type="com.backendsys.modules.material.entity.MaterialCategory">
  15. <id property="id" column="id" jdbcType="BIGINT" />
  16. <result property="category_id" column="id" javaType="java.lang.Long" />
  17. <result property="lora_id" column="lora_id" javaType="java.lang.Long" />
  18. <result property="lora_name" column="lora_name" />
  19. <result property="category_name" column="category_name" />
  20. <result property="is_share" column="is_share" javaType="java.lang.Integer"/>
  21. <result property="sort" column="sort" javaType="java.lang.Integer" />
  22. </resultMap>
  23. <select id="selectMaterialCategoryList" resultMap="resultMapMaterialCategory">
  24. SELECT
  25. <include refid="includeMaterialCategory" />
  26. FROM ai_material_category mc
  27. LEFT JOIN ai_material_lora mcl ON mc.lora_id = mcl.id
  28. <where>
  29. <if test="lora_id != null and lora_id != ''">
  30. AND mc.lora_id = #{lora_id}
  31. </if>
  32. <if test="category_name != null and category_name != ''">
  33. AND mc.category_name like concat('%', #{category_name}, '%')
  34. </if>
  35. <if test="is_share != null and is_share != ''">
  36. AND mc.is_share = #{is_share}
  37. </if>
  38. </where>
  39. ORDER BY mc.sort DESC
  40. </select>
  41. </mapper>