<?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.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapperEx">

	<resultMap id="ProjectSelectResultMap" type="cn.superdesk.uniorder.dto.vo._function.select.SelectOptionOrg">
		<id column="sys_org_id" property="sysOrgId" jdbcType="BIGINT"/>
		<result column="organization_id" property="projectId" jdbcType="BIGINT"/>
		<result column="organization_name" property="projectName" jdbcType="VARCHAR"/>
	</resultMap>

	<select id="getProjectSelect" resultMap="ProjectSelectResultMap">
		SELECT
			id as sys_org_id,
			organization_id,
			organization_name
		from
			sys_organization
		<where>
		<choose>
			<when test="deleted != null and deleted != ''">
				and deleted = #{deleted,jdbcType=TINYINT}
			</when>
			<otherwise>
				and deleted = 0
			</otherwise>
		</choose>
		<if test="projectName != null and projectName != ''">
			and organization_name like CONCAT('%',#{projectName,jdbcType=VARCHAR},'%')
		</if>
		</where>
	</select>

	<select id="getByOutOrgId" resultMap="cn.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapper.BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="cn.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapper.Base_Column_List"/>
		from
			sys_organization
		where
			organization_id = #{id,jdbcType=BIGINT}
	</select>

	<select id="findByOutOrgId" resultMap="cn.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapper.BaseResultMap" parameterType="java.lang.Long">
		select
		<include refid="cn.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapper.Base_Column_List"/>
		from
			sys_organization
		where
			organization_id = #{userId,jdbcType=BIGINT}
	</select>

	<select id="findByOutOrgName" resultMap="cn.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapper.BaseResultMap" parameterType="java.lang.String">
		select
		<include refid="cn.superdesk.uniorder.dao.mapper.organisation.SysOrganizationMapper.Base_Column_List"/>
		from
			sys_organization
		where
			organization_name like CONCAT(CONCAT('%',#{organizationName,jdbcType=VARCHAR}),'%')
	</select>

</mapper>