id
,title,excerpt,content_id,info_id,
base_id,publish_dept_id,knowledge_from,
status,submit_dept_id,create_user_id,
create_time,update_user_id,update_time
select
t1.*
from ks_knowledge t1 left join ks_knowledge_info t2 on t1.info_id = t2.id
left join (select distinct knowledge_id as submitKnowledgeId
from ks_knowledge_submit_record
where submit_user_id = #{userId}) t3
on t3.submitKnowledgeId = t1.id
where 1 = 1
-- 如果为空,是查全部通过的,不分人
and ( status = 2)
-- 如果是1,只查自己的草稿
and ( draft_belong_user_id = #{userId} and status = 1)
and ( status in (10,11,12) and t3.submitKnowledgeId is not null)
and ( status = #{status} and t3.submitKnowledgeId is not null )
and title like concat('%',#{title},'%')
and publish_dept_id = #{publishDeptId}
and base_id = #{baseId}
and submit_dept_id = #{submitDeptId}
and create_time = ]]> #{publishDateBegin}
and create_time #{publishDateEnd}
order by create_time desc