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.*,
t2.policy_type as policyType,
t2.timeliness as timeliness
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
select t1.id as knowledgeId,
t1.title as title,
t1.status as status,
t2.timeliness as timeliness,
t2.auto_lose_effect as autoLoseEffect,
t2.exec_time_begin as execTimeBegin,
t2.exec_time_end as execTimeEnd
from ks_knowledge t1
left join ks_knowledge_info t2 on t1.info_id = t2.id
where status = 2
and t2.timeliness = 2
and auto_lose_effect = 1