<#-- 部门信息表 -->
<#-- 查询所有项目 -->
			

SELECT
	tsd.id,
	tsd.parentdepartid,
	tsd.departname,
	tsd.org_code AS orgCode,
	tsd.org_type AS orgType,
	tsd.status 
FROM
	t_s_depart tsd

where 1=1 

<#if ( projectDepartDto.orgTypeList )?? && projectDepartDto.orgTypeList ?size gt 0>
	and tsd.org_type in(
	<#list projectDepartDto.orgTypeList as item>        
	   '${item}'
	 <#if item_has_next>,</#if>
	 </#list>
	)
<#else >
	and tsd.org_type=null
</#if>	

<#if ( projectDepartDto.departName )?? && projectDepartDto.departName ?length gt 0>
	and tsd.departname like CONCAT('%', :projectDepartDto.departName ,'%') 
</#if>

<#if ( projectDepartDto.userid )?? && projectDepartDto.userid ?length gt 0>
	and		tsd.id in (
				select org.org_id from t_s_user_org  org where org.user_id=:projectDepartDto.userid and org.status=0
			)
</#if>
and tsd.status = '0'