通知公告报错,原因是分页查询外部表字段不能有子查询,子查询需要在内部

<select id="queryReceiveNoticeByPage_col">
			t.NOTICE_CONTENT,
            t.CREATE_USER,
			t.TYPE_NAME, 
            t.NOTICE_ID,
            t.NOTICE_TITLE,
            t.CREATE_DEPT,
            TO_CHAR(t.CREATETIME,'YYYY-MM-DD HH24:MI:SS') CREATETIME,
            TO_CHAR(t.ENDTIME,'YYYY-MM-DD HH24:MI:SS') ENDTIME,
            FUN_TR_USER(t.CREATE_USER,'ID_NAME') CREATE_USERNAME,
            FUN_TR_DEPT(t.CREATE_DEPT) CREATE_DEPTNAME,
	    错误写法: (select (case when count(notice_id)=0 then 'false' else 'true' end) from tbl_oa_notice_read where notice_id=n.NOTICE_ID and user_id=#{currentUser}) ISREAD           	
	   正确写法:t.ISREAD
	
</select>


<select id="queryReceiveNoticeByPage" resultMap="noticeMap" parameterType="map">
		select  distinct n.notice_id ,
				  n.notice_title,
				  n.notice_content,
				  n.endtime,
				  n.createtime,
				  n.create_user,
				  n.create_dept,
				  nt.type_name,
				 (select (case when count(notice_id)=0 then 'false' else 'true' end) from tbl_oa_notice_read where notice_id=n.NOTICE_ID and user_id=#{currentUser}) ISREAD
		  from tbl_oa_notice n
		  join tbl_oa_notice_type nt on n.notice_type=nt.type_id and nt.status='0'
		  <where>
		  	 n.create_dept = #{currentDeptTop}
		 		and n.notice_id in (select tg.notice_id
		                         from tbl_oa_notice_target tg
		                        where tg.target_id = #{currentUser}
		                          and tg.target_type = 'USER' AND tg.status = 0
		                        union all 
		                        select tg.notice_id
		                         from tbl_oa_notice_target tg
		                        where tg.target_id in (
		                        select dd.dept_id from tbl_base_dept dd WHERE dd.STATUS = '0' and ID_PATH like CONCAT(CONCAT('%,',#{currentDept}),',%')
		                          <!-- select dd.dept_id from tbl_base_dept dd start with dd.dept_id = #{currentDept} connect by prior dd.dept_parent_id = dd.dept_id  -->
		                        )
		                          and tg.target_type = 'DEPT' AND tg.status = 0
		                    )
		      and n.endtime >fun_base_sysdate()          
		      <if test="read!=null and read=='true'.toString()">
		        AND NOTICE_ID IN (select notice_id from tbl_oa_notice_read where user_id=#{currentUser})
		      </if>
		      <if test="read!=null and read=='false'.toString()">
		        AND NOTICE_ID NOT IN (select notice_id from tbl_oa_notice_read where user_id=#{currentUser})
		      </if>
		      <if test="noticeId!=null and noticeId!=''.toString()">
		      	AND NOTICE_ID = #{noticeId}
		      </if>
		      <if test="noticeTitle!=null and noticeTitle!=''.toString()">
		      	AND n.notice_title like CONCAT(CONCAT('%', #{noticeTitle}), '%')
		      </if>
		      <if test="endTimeStart!=null and endTimeStart!=''.toString()">
		      	AND n.endtime >=to_Date(#{endTimeStart},'YYYY-MM-DD HH24:MI:SS')
		      </if>
		      <if test="endTimeEnd!=null and endTimeEnd!=''.toString()">
		      	AND n.endtime <=to_Date(#{endTimeEnd},'YYYY-MM-DD HH24:MI:SS')
		      </if>
		      <if test="noticeType!=null and noticeType!=''.toString()">
		      	AND n.notice_type =#{noticeType}
		      </if>
		  </where>
		ORDER BY N.createtime DESC
</select>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值