BizQuestionGroupMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.tr.module.smart.common.repository.BizQuestionGroupRepository">
  6. <select id="selectQuestionAndDeptList"
  7. resultType="cn.tr.module.smart.app.controller.vo.AppQuestionAndDeptListVO">
  8. SELECT
  9. bqg.id AS questionGroupId,
  10. bqg.name,
  11. bqd.dept_id as deptId
  12. FROM
  13. biz_question_group bqg
  14. JOIN biz_question_dept bqd ON bqg.ID = bqd.question_group_id
  15. </select>
  16. <select id="selectQuestionAndDeptList"
  17. resultType="cn.tr.module.smart.app.controller.vo.AppQuestionAndDeptListVO">
  18. SELECT
  19. bqg.id AS questionGroupId,
  20. bqg.name,
  21. bqd.dept_id as deptId
  22. FROM
  23. biz_question_group bqg
  24. JOIN biz_question_dept bqd ON bqg.ID = bqd.question_group_id
  25. <where>
  26. and bqg.type ='AFTER'
  27. <if test="deptId != null">
  28. AND bqd.dept_id = #{deptId}
  29. </if>
  30. </where>
  31. </select>
  32. <select id="queryAllUnlink" resultType="cn.tr.module.smart.web.vo.BizDeptUnlinkQuestionVO">
  33. SELECT
  34. bqg.id as questionGroupId,
  35. bqg.name,
  36. bqg.type,
  37. bqg.interval,
  38. bqg.frequency,
  39. bqg.create_time,
  40. bqg.update_time,
  41. bqg.create_by,
  42. bqg.update_by
  43. FROM
  44. biz_question_group bqg
  45. <where>
  46. <if test="!query.isLink">
  47. <if test="query.deptId != null and query.deptId != '' ">
  48. AND NOT EXISTS ( SELECT 1 FROM biz_question_dept bqd WHERE bqd.question_group_id = bqg.ID AND bqd.dept_id= #{query.deptId} )
  49. </if>
  50. </if>
  51. <if test="query.isLink">
  52. <if test="query.deptId != null and query.deptId != '' ">
  53. AND EXISTS ( SELECT 1 FROM biz_question_dept bqd WHERE bqd.question_group_id = bqg.ID AND bqd.dept_id= #{query.deptId} )
  54. </if>
  55. </if>
  56. <if test="query.condition != null and query.condition != '' ">
  57. AND bqg.name LIKE CONCAT('%',#{query.condition},'%')
  58. </if>
  59. </where>
  60. </select>
  61. <select id="selectQuestionGroupAllList" resultType="cn.tr.module.smart.common.dto.BizQuestionGroupDTO">
  62. SELECT
  63. bqg.id,
  64. bqg.name,
  65. bqg.type,
  66. bqg.interval,
  67. bqg.frequency,
  68. bqg.square_id,
  69. bqg.is_share,
  70. bqg.create_by,
  71. bqg.update_by,
  72. bqg.create_time,
  73. bqg.update_time,
  74. bqg.tenant_id,
  75. st.avatar as tenant_avatar,
  76. st.name as hospital_name,
  77. COALESCE(bq_count.cnt, 0) AS question_count
  78. FROM
  79. biz_question_group bqg
  80. left join sys_tenant st on st.id = bqg.tenant_id
  81. LEFT JOIN (
  82. SELECT group_id, COUNT(1) AS cnt
  83. FROM biz_question
  84. GROUP BY group_id
  85. ) bq_count ON bq_count.group_id = bqg.id
  86. <where>
  87. <if test="query.condition != null and query.condition != ''">
  88. AND bqg.name LIKE CONCAT(CONCAT('%', #{query.condition}), '%')
  89. </if>
  90. <if test="query.type != null and query.type != ''">
  91. AND bqg.type = #{query.type}
  92. </if>
  93. </where>
  94. </select>
  95. </mapper>