DeptInfoMapper.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.diagbot.mapper.DeptInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.DeptInfo">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="name" property="name" />
  13. <result column="remark" property="remark" />
  14. </resultMap>
  15. <select id="getAllDeptInfo" resultType="com.diagbot.dto.GetDeptInfoDTO">
  16. SELECT
  17. a.id,a.gmt_create,b.gmt_modified,b.creator,b.modifier,a.`name`,a.remark,c.type
  18. FROM
  19. `icss_dept_info` a
  20. LEFT JOIN icss_question_usual b ON a.id = b.dept_id
  21. LEFT JOIN icss_question_info c ON b.question_id = c.id
  22. WHERE
  23. a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N'
  24. <if test="name != null and name != ''">
  25. AND a.`name` LIKE CONCAT('%',#{name},'%')
  26. </if>
  27. GROUP BY a.id,c.type
  28. ORDER BY
  29. b.gmt_modified DESC
  30. </select>
  31. <select id="getDeptName" resultType="com.diagbot.dto.DeptInfoDTO">
  32. SELECT
  33. *
  34. FROM
  35. `icss_dept_info` a
  36. WHERE
  37. a.is_deleted = 'N'
  38. AND a.id NOT IN (
  39. SELECT
  40. b.dept_id
  41. FROM
  42. icss_question_usual b
  43. WHERE
  44. b.is_deleted = 'N'
  45. AND b.dept_id IN (
  46. SELECT
  47. c.id
  48. FROM
  49. `icss_dept_info` c
  50. WHERE c.is_deleted = 'N'
  51. )
  52. )
  53. </select>
  54. </mapper>