| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.tr.module.smart.common.repository.BizQuestionGroupRepository">
- <select id="selectQuestionAndDeptList"
- resultType="cn.tr.module.smart.app.controller.vo.AppQuestionAndDeptListVO">
- SELECT
- bqg.id AS questionGroupId,
- bqg.name,
- bqd.dept_id as deptId
- FROM
- biz_question_group bqg
- JOIN biz_question_dept bqd ON bqg.ID = bqd.question_group_id
- </select>
- <select id="selectQuestionAndDeptList"
- resultType="cn.tr.module.smart.app.controller.vo.AppQuestionAndDeptListVO">
- SELECT
- bqg.id AS questionGroupId,
- bqg.name,
- bqd.dept_id as deptId
- FROM
- biz_question_group bqg
- JOIN biz_question_dept bqd ON bqg.ID = bqd.question_group_id
- <where>
- and bqg.type ='AFTER'
- <if test="deptId != null">
- AND bqd.dept_id = #{deptId}
- </if>
- </where>
- </select>
- <select id="queryAllUnlink" resultType="cn.tr.module.smart.web.vo.BizDeptUnlinkQuestionVO">
- SELECT
- bqg.id as questionGroupId,
- bqg.name,
- bqg.type,
- bqg.interval,
- bqg.frequency,
- bqg.create_time,
- bqg.update_time,
- bqg.create_by,
- bqg.update_by
- FROM
- biz_question_group bqg
- <where>
- <if test="!query.isLink">
- <if test="query.deptId != null and query.deptId != '' ">
- AND NOT EXISTS ( SELECT 1 FROM biz_question_dept bqd WHERE bqd.question_group_id = bqg.ID AND bqd.dept_id= #{query.deptId} )
- </if>
- </if>
- <if test="query.isLink">
- <if test="query.deptId != null and query.deptId != '' ">
- AND EXISTS ( SELECT 1 FROM biz_question_dept bqd WHERE bqd.question_group_id = bqg.ID AND bqd.dept_id= #{query.deptId} )
- </if>
- </if>
- <if test="query.condition != null and query.condition != '' ">
- AND bqg.name LIKE CONCAT('%',#{query.condition},'%')
- </if>
- </where>
- </select>
- <select id="selectQuestionGroupAllList" resultType="cn.tr.module.smart.common.dto.BizQuestionGroupDTO">
- SELECT
- bqg.id,
- bqg.name,
- bqg.type,
- bqg.interval,
- bqg.frequency,
- bqg.square_id,
- bqg.is_share,
- bqg.create_by,
- bqg.update_by,
- bqg.create_time,
- bqg.update_time,
- bqg.tenant_id,
- st.avatar as tenant_avatar,
- st.name as hospital_name,
- COALESCE(bq_count.cnt, 0) AS question_count
- FROM
- biz_question_group bqg
- left join sys_tenant st on st.id = bqg.tenant_id
- LEFT JOIN (
- SELECT group_id, COUNT(1) AS cnt
- FROM biz_question
- GROUP BY group_id
- ) bq_count ON bq_count.group_id = bqg.id
- <where>
- <if test="query.condition != null and query.condition != ''">
- AND bqg.name LIKE CONCAT(CONCAT('%', #{query.condition}), '%')
- </if>
- <if test="query.type != null and query.type != ''">
- AND bqg.type = #{query.type}
- </if>
- </where>
- </select>
- </mapper>
|