<?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.com.tenlion.systembase.dao.organization.IOrganizationDao">

    <resultMap id="organizationDTO" type="cn.com.tenlion.systembase.pojo.dtos.organization.OrganizationDTO">
        <result column="organization_id" property="organizationId"/>
        <result column="organization_name" property="organizationName"/>
        <result column="organization_type_id" property="organizationTypeId"/>
        <result column="organization_type_name" property="organizationTypeName"/>
        <result column="organization_status" property="organizationStatus"/>
        <result column="organization_summary" property="organizationSummary"/>
        <result column="business_reg_no" property="businessRegNo"/>
        <result column="business_license" property="businessLicense"/>
        <result column="business_license_start_date" property="businessLicenseStartDate"/>
        <result column="business_license_end_date" property="businessLicenseEndDate"/>
        <result column="registration_no" property="registrationNo"/>
        <result column="registration_authority_no" property="registrationAuthorityNo"/>
        <result column="legal_person_name" property="legalPersonName"/>
        <result column="residence" property="residence"/>
        <result column="approval_date" property="approvalDate"/>
        <result column="master_name" property="masterName"/>
        <result column="master_phone" property="masterPhone"/>
        <result column="master_id_card_code" property="masterIdCardCode"/>
        <result column="master_id_card_code_name" property="masterIdCardCodeName"/>
        <result column="master_id_card" property="masterIdCard"/>
        <result column="master_id_card_front" property="masterIdCardFront"/>
        <result column="master_id_card_back" property="masterIdCardBack"/>
        <result column="office_address" property="officeAddress"/>
        <result column="security_person_name" property="securityPersonName"/>
        <result column="security_person_phone" property="securityPersonPhone"/>
        <result column="degree_of_concern_id" property="degreeOfConcernId"/>
        <result column="degree_of_concern_name" property="degreeOfConcernName"/>
        <result column="can_establish_party_org" property="canEstablishPartyOrg"/>
        <result column="has_party_org" property="hasPartyOrg"/>
        <result column="party_org_total_person" property="partyOrgTotalPerson"/>
        <result column="has_labour_union" property="hasLabourUnion"/>
        <result column="labour_union_total_person" property="labourUnionTotalPerson"/>
        <result column="has_communist_youth_league" property="hasCommunistYouthLeague"/>
        <result column="communist_youth_league_total_person" property="communistYouthLeagueTotalPerson"/>
        <result column="has_women_federation" property="hasWomenFederation"/>
        <result column="women_total_person" property="womenTotalPerson"/>
        <result column="source_of_funds" property="sourceOfFunds"/>
        <result column="has_overseas_background" property="hasOverseasBackground"/>
        <result column="organization_lng" property="organizationLng"/>
        <result column="organization_lat" property="organizationLat"/>
        <result column="area_code" property="areaCode"/>
        <result column="area_name" property="areaName"/>
        <result column="grid_code" property="gridCode"/>
        <result column="grid_name" property="gridName"/>
        <result column="remarks" property="remarks"/>
        <result column="facade_photos" property="facadePhotos"/>
        <result column="workplace_photos" property="workplacePhotos"/>
        <result column="gmt_create" property="gmtCreate"/>
    </resultMap>

    <resultMap id="organizationBO" type="cn.com.tenlion.systembase.pojo.bos.organization.OrganizationBO">
        <result column="organization_id" property="organizationId"/>
        <result column="organization_name" property="organizationName"/>
        <result column="organization_type_id" property="organizationTypeId"/>
        <result column="organization_type_name" property="organizationTypeName"/>
        <result column="organization_status" property="organizationStatus"/>
        <result column="organization_summary" property="organizationSummary"/>
        <result column="business_reg_no" property="businessRegNo"/>
        <result column="business_license" property="businessLicense"/>
        <result column="business_license_start_date" property="businessLicenseStartDate"/>
        <result column="business_license_end_date" property="businessLicenseEndDate"/>
        <result column="registration_no" property="registrationNo"/>
        <result column="registration_authority_no" property="registrationAuthorityNo"/>
        <result column="legal_person_name" property="legalPersonName"/>
        <result column="residence" property="residence"/>
        <result column="approval_date" property="approvalDate"/>
        <result column="master_name" property="masterName"/>
        <result column="master_phone" property="masterPhone"/>
        <result column="master_id_card_code" property="masterIdCardCode"/>
        <result column="master_id_card_code_name" property="masterIdCardCodeName"/>
        <result column="master_id_card" property="masterIdCard"/>
        <result column="master_id_card_front" property="masterIdCardFront"/>
        <result column="master_id_card_back" property="masterIdCardBack"/>
        <result column="office_address" property="officeAddress"/>
        <result column="security_person_name" property="securityPersonName"/>
        <result column="security_person_phone" property="securityPersonPhone"/>
        <result column="degree_of_concern_id" property="degreeOfConcernId"/>
        <result column="degree_of_concern_name" property="degreeOfConcernName"/>
        <result column="can_establish_party_org" property="canEstablishPartyOrg"/>
        <result column="has_party_org" property="hasPartyOrg"/>
        <result column="party_org_total_person" property="partyOrgTotalPerson"/>
        <result column="has_labour_union" property="hasLabourUnion"/>
        <result column="labour_union_total_person" property="labourUnionTotalPerson"/>
        <result column="has_communist_youth_league" property="hasCommunistYouthLeague"/>
        <result column="communist_youth_league_total_person" property="communistYouthLeagueTotalPerson"/>
        <result column="has_women_federation" property="hasWomenFederation"/>
        <result column="women_total_person" property="womenTotalPerson"/>
        <result column="source_of_funds" property="sourceOfFunds"/>
        <result column="has_overseas_background" property="hasOverseasBackground"/>
        <result column="organization_lng" property="organizationLng"/>
        <result column="organization_lat" property="organizationLat"/>
        <result column="area_code" property="areaCode"/>
        <result column="area_name" property="areaName"/>
        <result column="grid_code" property="gridCode"/>
        <result column="grid_name" property="gridName"/>
        <result column="remarks" property="remarks"/>
        <result column="facade_photos" property="facadePhotos"/>
        <result column="workplace_photos" property="workplacePhotos"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="creator" property="creator"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="modifier" property="modifier"/>
        <result column="is_delete" property="isDelete"/>
    </resultMap>

    <resultMap id="organizationPO" type="cn.com.tenlion.systembase.pojo.pos.organization.OrganizationPO">
        <result column="organization_id" property="organizationId"/>
        <result column="organization_name" property="organizationName"/>
        <result column="organization_type_id" property="organizationTypeId"/>
        <result column="organization_type_name" property="organizationTypeName"/>
        <result column="organization_status" property="organizationStatus"/>
        <result column="organization_summary" property="organizationSummary"/>
        <result column="business_reg_no" property="businessRegNo"/>
        <result column="business_license" property="businessLicense"/>
        <result column="business_license_start_date" property="businessLicenseStartDate"/>
        <result column="business_license_end_date" property="businessLicenseEndDate"/>
        <result column="registration_no" property="registrationNo"/>
        <result column="registration_authority_no" property="registrationAuthorityNo"/>
        <result column="legal_person_name" property="legalPersonName"/>
        <result column="residence" property="residence"/>
        <result column="approval_date" property="approvalDate"/>
        <result column="master_name" property="masterName"/>
        <result column="master_phone" property="masterPhone"/>
        <result column="master_id_card_code" property="masterIdCardCode"/>
        <result column="master_id_card_code_name" property="masterIdCardCodeName"/>
        <result column="master_id_card" property="masterIdCard"/>
        <result column="master_id_card_front" property="masterIdCardFront"/>
        <result column="master_id_card_back" property="masterIdCardBack"/>
        <result column="office_address" property="officeAddress"/>
        <result column="security_person_name" property="securityPersonName"/>
        <result column="security_person_phone" property="securityPersonPhone"/>
        <result column="degree_of_concern_id" property="degreeOfConcernId"/>
        <result column="degree_of_concern_name" property="degreeOfConcernName"/>
        <result column="can_establish_party_org" property="canEstablishPartyOrg"/>
        <result column="has_party_org" property="hasPartyOrg"/>
        <result column="party_org_total_person" property="partyOrgTotalPerson"/>
        <result column="has_labour_union" property="hasLabourUnion"/>
        <result column="labour_union_total_person" property="labourUnionTotalPerson"/>
        <result column="has_communist_youth_league" property="hasCommunistYouthLeague"/>
        <result column="communist_youth_league_total_person" property="communistYouthLeagueTotalPerson"/>
        <result column="has_women_federation" property="hasWomenFederation"/>
        <result column="women_total_person" property="womenTotalPerson"/>
        <result column="source_of_funds" property="sourceOfFunds"/>
        <result column="has_overseas_background" property="hasOverseasBackground"/>
        <result column="organization_lng" property="organizationLng"/>
        <result column="organization_lat" property="organizationLat"/>
        <result column="area_code" property="areaCode"/>
        <result column="area_name" property="areaName"/>
        <result column="grid_code" property="gridCode"/>
        <result column="grid_name" property="gridName"/>
        <result column="remarks" property="remarks"/>
        <result column="facade_photos" property="facadePhotos"/>
        <result column="workplace_photos" property="workplacePhotos"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="creator" property="creator"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="modifier" property="modifier"/>
        <result column="is_delete" property="isDelete"/>
    </resultMap>

    <!-- 建表 -->
    <update id="createTable">
        CREATE TABLE IF NOT EXISTS `org_organization` (
            `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
            `organization_id` char(36) DEFAULT NULL COMMENT '主键',
            `organization_name` varchar(255) DEFAULT NULL COMMENT '组织名称',
            `organization_type_id` char(36) DEFAULT NULL COMMENT '组织类型ID',
            `organization_type_name` varchar(255) DEFAULT NULL COMMENT '组织类型名称',
            `organization_status` int(1) DEFAULT NULL COMMENT '组织状态',
            `organization_summary` text COMMENT '组织简介',
            `business_reg_no` varchar(255) DEFAULT NULL COMMENT '统一社会信用代码',
            `business_license` varchar(255) DEFAULT NULL COMMENT '营业执照',
            `business_license_start_date` varchar(10) DEFAULT NULL COMMENT '营业执照开始时间',
            `business_license_end_date` varchar(10) DEFAULT NULL COMMENT '营业执照结束时间',
            `registration_no` varchar(255) DEFAULT NULL COMMENT '登记证号',
            `registration_authority_no` varchar(255) DEFAULT NULL COMMENT '登记管理机关代码',
            `legal_person_name` varchar(255) DEFAULT NULL COMMENT '法人姓名',
            `residence` varchar(255) DEFAULT NULL COMMENT '住所',
            `approval_date` varchar(10) DEFAULT NULL COMMENT '批准日期',
            `master_name` varchar(255) DEFAULT NULL COMMENT '负责人姓名',
            `master_phone` varchar(255) DEFAULT NULL COMMENT '负责人联系方式',
            `master_id_card_code` char(36) DEFAULT NULL COMMENT '负责人证件代码',
            `master_id_card_code_name` varchar(255) DEFAULT NULL COMMENT '负责人证件代码名称',
            `master_id_card` varchar(255) DEFAULT NULL COMMENT '负责人证件号码',
            `master_id_card_front` varchar(255) DEFAULT NULL COMMENT '负责人证件正面',
            `master_id_card_back` varchar(255) DEFAULT NULL COMMENT '负责人证件背面',
            `office_address` varchar(255) DEFAULT NULL COMMENT '办公地址',
            `security_person_name` varchar(255) DEFAULT NULL COMMENT '治保负责人姓名',
            `security_person_phone` varchar(255) DEFAULT NULL COMMENT '治保负责人联系方式',
            `degree_of_concern_id` char(36) DEFAULT NULL COMMENT '关注度ID',
            `degree_of_concern_name` varchar(255) DEFAULT NULL COMMENT '关注度名称',
            `can_establish_party_org` int(1) DEFAULT '0' COMMENT '是否具备建立中共党组织条件',
            `has_party_org` int(1) DEFAULT '0' COMMENT '是否有党组织',
            `party_org_total_person` int(11) DEFAULT NULL COMMENT '中共党员数量',
            `has_labour_union` int(1) DEFAULT '0' COMMENT '是否有工会',
            `labour_union_total_person` int(11) DEFAULT NULL COMMENT '工会会员数量',
            `has_communist_youth_league` int(1) DEFAULT '0' COMMENT '是否有共青团',
            `communist_youth_league_total_person` int(11) DEFAULT NULL COMMENT '共青团团员数量',
            `has_women_federation` int(1) DEFAULT '0' COMMENT '是否有妇联',
            `women_total_person` int(11) DEFAULT NULL COMMENT '妇女数量',
            `source_of_funds` varchar(255) DEFAULT NULL COMMENT '资金来源',
            `has_overseas_background` int(1) DEFAULT '0' COMMENT '是否有境外背景',
            `organization_lng` varchar(255) DEFAULT NULL COMMENT '组织经度',
            `organization_lat` varchar(255) DEFAULT NULL COMMENT '组织维度',
            `area_code` varchar(255) DEFAULT NULL COMMENT '地区编码',
            `area_name` varchar(255) DEFAULT NULL COMMENT '地区名称',
            `grid_code` varchar(255) DEFAULT NULL COMMENT '网格编码',
            `grid_name` varchar(255) DEFAULT NULL COMMENT '网格名称',
            `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
            `facade_photos` varchar(255) DEFAULT NULL COMMENT '门面照片',
            `workplace_photos` varchar(255) DEFAULT NULL COMMENT '工作场所照片',
            `gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
            `creator` char(36) DEFAULT NULL COMMENT '创建人',
            `gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
            `modifier` char(36) DEFAULT NULL COMMENT '修改人',
            `is_delete` int(1) DEFAULT '0' COMMENT '是否删除',
            PRIMARY KEY (`id`),
            UNIQUE KEY `organization_id` (`organization_id`),
            UNIQUE KEY `bussiness_reg_no` (`business_reg_no`),
            KEY `area_code` (`area_code`),
            KEY `grid_code` (`grid_code`)
        ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='社会组织';
    </update>

    <!-- 新增社会组织 -->
    <insert id="save" parameterType="map">
        INSERT INTO org_organization(
            organization_id,
            organization_name,
            organization_type_id,
            organization_type_name,
            organization_status,
            organization_summary,
            business_reg_no,
            business_license,
            business_license_start_date,
            business_license_end_date,
            registration_no,
            registration_authority_no,
            legal_person_name,
            residence,
            approval_date,
            master_name,
            master_phone,
            master_id_card_code,
            master_id_card_code_name,
            master_id_card,
            master_id_card_front,
            master_id_card_back,
            office_address,
            security_person_name,
            security_person_phone,
            degree_of_concern_id,
            degree_of_concern_name,
            can_establish_party_org,
            has_party_org,
            party_org_total_person,
            has_labour_union,
            labour_union_total_person,
            has_communist_youth_league,
            communist_youth_league_total_person,
            has_women_federation,
            women_total_person,
            source_of_funds,
            has_overseas_background,
            organization_lng,
            organization_lat,
            area_code,
            area_name,
            grid_code,
            grid_name,
            remarks,
            facade_photos,
            workplace_photos,
            gmt_create,
            creator,
            gmt_modified,
            modifier,
            is_delete
        ) VALUES(
            #{organizationId},
            #{organizationName},
            #{organizationTypeId},
            #{organizationTypeName},
            #{organizationStatus},
            #{organizationSummary},
            #{businessRegNo},
            #{businessLicense},
            #{businessLicenseStartDate},
            #{businessLicenseEndDate},
            #{registrationNo},
            #{registrationAuthorityNo},
            #{legalPersonName},
            #{residence},
            #{approvalDate},
            #{masterName},
            #{masterPhone},
            #{masterIdCardCode},
            #{masterIdCardCodeName},
            #{masterIdCard},
            #{masterIdCardFront},
            #{masterIdCardBack},
            #{officeAddress},
            #{securityPersonName},
            #{securityPersonPhone},
            #{degreeOfConcernId},
            #{degreeOfConcernName},
            #{canEstablishPartyOrg},
            #{hasPartyOrg},
            #{partyOrgTotalPerson},
            #{hasLabourUnion},
            #{labourUnionTotalPerson},
            #{hasCommunistYouthLeague},
            #{communistYouthLeagueTotalPerson},
            #{hasWomenFederation},
            #{womenTotalPerson},
            #{sourceOfFunds},
            #{hasOverseasBackground},
            #{organizationLng},
            #{organizationLat},
            #{areaCode},
            #{areaName},
            #{gridCode},
            #{gridName},
            #{remarks},
            #{facadePhotos},
            #{workplacePhotos},
            #{gmtCreate},
            #{creator},
            #{gmtModified},
            #{modifier},
            #{isDelete}
        )
    </insert>

    <!-- 删除社会组织 -->
    <update id="remove" parameterType="map">
        UPDATE
            org_organization
        SET
            gmt_modified = #{gmtModified},
            modifier = #{modifier},
            is_delete = 1
        WHERE
            organization_id IN
        <foreach collection="organizationIds" index="index" open="(" separator="," close=")">
            #{organizationIds[${index}]}
        </foreach>
    </update>

    <!-- 删除社会组织（物理） -->
    <update id="delete" parameterType="map">
        DELETE FROM
            org_organization
        WHERE
            organization_id IN
        <foreach collection="organizationIds" index="index" open="(" separator="," close=")">
            #{organizationIds[${index}]}
        </foreach>
    </update>

    <!-- 修改社会组织 -->
    <update id="update" parameterType="map">
        UPDATE
            org_organization
        SET
        <if test="organizationName != null and organizationName != ''">
            organization_name = #{organizationName},
        </if>
        <if test="organizationTypeId != null">
            organization_type_id = #{organizationTypeId},
        </if>
        <if test="organizationTypeName != null">
            organization_type_name = #{organizationTypeName},
        </if>
        <if test="organizationStatus != null">
            organization_status = #{organizationStatus},
        </if>
        <if test="organizationSummary != null">
            organization_summary = #{organizationSummary},
        </if>
        <if test="businessRegNo != null">
            business_reg_no = #{businessRegNo},
        </if>
        <if test="businessLicense != null">
            business_license = #{businessLicense},
        </if>
        <if test="businessLicenseStartDate != null">
            business_license_start_date = #{businessLicenseStartDate},
        </if>
        <if test="businessLicenseEndDate != null">
            business_license_end_date = #{businessLicenseEndDate},
        </if>
        <if test="registrationNo != null">
            registration_no = #{registrationNo},
        </if>
        <if test="registrationAuthorityNo != null">
            registration_authority_no = #{registrationAuthorityNo},
        </if>
        <if test="legalPersonName != null">
            legal_person_name = #{legalPersonName},
        </if>
        <if test="residence != null">
            residence = #{residence},
        </if>
        <if test="approvalDate != null">
            approval_date = #{approvalDate},
        </if>
        <if test="masterName != null">
            master_name = #{masterName},
        </if>
        <if test="masterPhone != null">
            master_phone = #{masterPhone},
        </if>
        <if test="masterIdCardCode != null">
            master_id_card_code = #{masterIdCardCode},
        </if>
        <if test="masterIdCardCodeName != null">
            master_id_card_code_name = #{masterIdCardCodeName},
        </if>
        <if test="masterIdCard != null">
            master_id_card = #{masterIdCard},
        </if>
        <if test="masterIdCardFront != null">
            master_id_card_front = #{masterIdCardFront},
        </if>
        <if test="masterIdCardBack != null">
            master_id_card_back = #{masterIdCardBack},
        </if>
        <if test="officeAddress != null">
            office_address = #{officeAddress},
        </if>
        <if test="securityPersonName != null">
            security_person_name = #{securityPersonName},
        </if>
        <if test="securityPersonPhone != null">
            security_person_phone = #{securityPersonPhone},
        </if>
        <if test="degreeOfConcernId != null">
            degree_of_concern_id = #{degreeOfConcernId},
        </if>
        <if test="degreeOfConcernName != null">
            degree_of_concern_name = #{degreeOfConcernName},
        </if>
        <if test="canEstablishPartyOrg != null">
            can_establish_party_org = #{canEstablishPartyOrg},
        </if>
        <if test="hasPartyOrg != null">
            has_party_org = #{hasPartyOrg},
        </if>
        <if test="partyOrgTotalPerson != null">
            party_org_total_person = #{partyOrgTotalPerson},
        </if>
        <if test="hasLabourUnion != null">
            has_labour_union = #{hasLabourUnion},
        </if>
        <if test="labourUnionTotalPerson != null">
            labour_union_total_person = #{labourUnionTotalPerson},
        </if>
        <if test="hasCommunistYouthLeague != null">
            has_communist_youth_league = #{hasCommunistYouthLeague},
        </if>
        <if test="communistYouthLeagueTotalPerson != null">
            communist_youth_league_total_person = #{communistYouthLeagueTotalPerson},
        </if>
        <if test="hasWomenFederation != null">
            has_women_federation = #{hasWomenFederation},
        </if>
        <if test="womenTotalPerson != null">
            women_total_person = #{womenTotalPerson},
        </if>
        <if test="sourceOfFunds != null">
            source_of_funds = #{sourceOfFunds},
        </if>
        <if test="hasOverseasBackground != null">
            has_overseas_background = #{hasOverseasBackground},
        </if>
        <if test="organizationLng != null">
            organization_lng = #{organizationLng},
        </if>
        <if test="organizationLat != null">
            organization_lat = #{organizationLat},
        </if>
        <if test="areaCode != null">
            area_code = #{areaCode},
        </if>
        <if test="areaName != null">
            area_name = #{areaName},
        </if>
        <if test="gridCode != null">
            grid_code = #{gridCode},
        </if>
        <if test="gridName != null">
            grid_name = #{gridName},
        </if>
        <if test="remarks != null">
            remarks = #{remarks},
        </if>
        <if test="facadePhotos != null">
            facade_photos = #{facadePhotos},
        </if>
        <if test="workplacePhotos != null">
            workplace_photos = #{workplacePhotos},
        </if>
            gmt_modified = #{gmtModified},
            modifier = #{modifier}
        WHERE
            organization_id = #{organizationId}
    </update>

    <!-- 社会组织详情 -->
    <select id="get" parameterType="map" resultMap="organizationDTO">
        SELECT
            t1.organization_name,
            t1.organization_type_id,
            t1.organization_type_name,
            t1.organization_status,
            t1.organization_summary,
            t1.business_reg_no,
            t1.business_license,
            t1.business_license_start_date,
            t1.business_license_end_date,
            t1.registration_no,
            t1.registration_authority_no,
            t1.legal_person_name,
            t1.residence,
            t1.approval_date,
            t1.master_name,
            t1.master_phone,
            t1.master_id_card_code,
            t1.master_id_card_code_name,
            t1.master_id_card,
            t1.master_id_card_front,
            t1.master_id_card_back,
            t1.office_address,
            t1.security_person_name,
            t1.security_person_phone,
            t1.degree_of_concern_id,
            t1.degree_of_concern_name,
            t1.can_establish_party_org,
            t1.has_party_org,
            t1.party_org_total_person,
            t1.has_labour_union,
            t1.labour_union_total_person,
            t1.has_communist_youth_league,
            t1.communist_youth_league_total_person,
            t1.has_women_federation,
            t1.women_total_person,
            t1.source_of_funds,
            t1.has_overseas_background,
            t1.organization_lng,
            t1.organization_lat,
            t1.area_code,
            t1.area_name,
            t1.grid_code,
            t1.grid_name,
            t1.remarks,
            t1.facade_photos,
            t1.workplace_photos,
            t1.organization_id
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
            <if test="organizationId != null and organizationId != ''">
        AND
            t1.organization_id = #{organizationId}
            </if>
    </select>

    <!-- 社会组织详情 -->
    <select id="getBO" parameterType="map" resultMap="organizationBO">
        SELECT
            t1.organization_id,
            t1.organization_name,
            t1.organization_type_id,
            t1.organization_type_name,
            t1.organization_status,
            t1.organization_summary,
            t1.business_reg_no,
            t1.business_license,
            t1.business_license_start_date,
            t1.business_license_end_date,
            t1.registration_no,
            t1.registration_authority_no,
            t1.legal_person_name,
            t1.residence,
            t1.approval_date,
            t1.master_name,
            t1.master_phone,
            t1.master_id_card_code,
            t1.master_id_card_code_name,
            t1.master_id_card,
            t1.master_id_card_front,
            t1.master_id_card_back,
            t1.office_address,
            t1.security_person_name,
            t1.security_person_phone,
            t1.degree_of_concern_id,
            t1.degree_of_concern_name,
            t1.can_establish_party_org,
            t1.has_party_org,
            t1.party_org_total_person,
            t1.has_labour_union,
            t1.labour_union_total_person,
            t1.has_communist_youth_league,
            t1.communist_youth_league_total_person,
            t1.has_women_federation,
            t1.women_total_person,
            t1.source_of_funds,
            t1.has_overseas_background,
            t1.organization_lng,
            t1.organization_lat,
            t1.area_code,
            t1.area_name,
            t1.grid_code,
            t1.grid_name,
            t1.remarks,
            t1.facade_photos,
            t1.workplace_photos,
            t1.gmt_create,
            t1.creator,
            t1.gmt_modified,
            t1.modifier,
            t1.is_delete
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
            <if test="organizationId != null and organizationId != ''">
        AND
            t1.organization_id = #{organizationId}
            </if>
    </select>

    <!-- 社会组织详情 -->
    <select id="getPO" parameterType="map" resultMap="organizationPO">
        SELECT
            t1.organization_id,
            t1.organization_name,
            t1.organization_type_id,
            t1.organization_type_name,
            t1.organization_status,
            t1.organization_summary,
            t1.business_reg_no,
            t1.business_license,
            t1.business_license_start_date,
            t1.business_license_end_date,
            t1.registration_no,
            t1.registration_authority_no,
            t1.legal_person_name,
            t1.residence,
            t1.approval_date,
            t1.master_name,
            t1.master_phone,
            t1.master_id_card_code,
            t1.master_id_card_code_name,
            t1.master_id_card,
            t1.master_id_card_front,
            t1.master_id_card_back,
            t1.office_address,
            t1.security_person_name,
            t1.security_person_phone,
            t1.degree_of_concern_id,
            t1.degree_of_concern_name,
            t1.can_establish_party_org,
            t1.has_party_org,
            t1.party_org_total_person,
            t1.has_labour_union,
            t1.labour_union_total_person,
            t1.has_communist_youth_league,
            t1.communist_youth_league_total_person,
            t1.has_women_federation,
            t1.women_total_person,
            t1.source_of_funds,
            t1.has_overseas_background,
            t1.organization_lng,
            t1.organization_lat,
            t1.area_code,
            t1.area_name,
            t1.grid_code,
            t1.grid_name,
            t1.remarks,
            t1.facade_photos,
            t1.workplace_photos,
            t1.gmt_create,
            t1.creator,
            t1.gmt_modified,
            t1.modifier,
            t1.is_delete
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
        <if test="organizationId != null and organizationId != ''">
        AND
            t1.organization_id = #{organizationId}
        </if>
        <if test="businessRegNo != null and businessRegNo != ''">
        AND
            t1.business_reg_no = #{businessRegNo}
        </if>
    </select>

    <!-- 社会组织列表 -->
    <select id="list" parameterType="map" resultMap="organizationDTO">
        SELECT
            t1.organization_id,
            t1.organization_name,
            t1.organization_type_id,
            t1.organization_type_name,
            t1.organization_status,
            t1.organization_summary,
            t1.business_reg_no,
            t1.business_license,
            t1.business_license_start_date,
            t1.business_license_end_date,
            t1.registration_no,
            t1.registration_authority_no,
            t1.legal_person_name,
            t1.residence,
            t1.approval_date,
            t1.master_name,
            t1.master_phone,
            t1.master_id_card_code,
            t1.master_id_card_code_name,
            t1.master_id_card,
            t1.master_id_card_front,
            t1.master_id_card_back,
            t1.office_address,
            t1.security_person_name,
            t1.security_person_phone,
            t1.degree_of_concern_id,
            t1.degree_of_concern_name,
            t1.can_establish_party_org,
            t1.has_party_org,
            t1.party_org_total_person,
            t1.has_labour_union,
            t1.labour_union_total_person,
            t1.has_communist_youth_league,
            t1.communist_youth_league_total_person,
            t1.has_women_federation,
            t1.women_total_person,
            t1.source_of_funds,
            t1.has_overseas_background,
            t1.organization_lng,
            t1.organization_lat,
            t1.area_code,
            t1.area_name,
            t1.grid_code,
            t1.grid_name,
            t1.remarks,
            t1.facade_photos,
            t1.workplace_photos,
            t1.gmt_create,
            1
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
        <if test="keywords != null and keywords != ''">
        AND (
            <!-- 这里添加其他条件 -->
            t1.id LIKE CONCAT('%', #{keywords}, '%')
        )
        </if>
        <if test="startTime != null and startTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND
            LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
        </if>
        <if test="areaCode != null and areaCode != ''">
        AND
            t1.area_code = #{areaCode}
        </if>
        <if test="gridCode != null and gridCode != ''">
        AND
            t1.grid_code = #{gridCode}
        </if>
        <if test="organizationIds != null and organizationIds.size > 0">
        AND
            t1.organization_id IN
            <foreach collection="organizationIds" index="index" open="(" separator="," close=")">
                #{organizationIds[${index}]}
            </foreach>
        </if>
    </select>

    <!-- 社会组织列表 -->
    <select id="listBO" parameterType="map" resultMap="organizationBO">
        SELECT
            t1.organization_id,
            t1.organization_name,
            t1.organization_type_id,
            t1.organization_type_name,
            t1.organization_status,
            t1.organization_summary,
            t1.business_reg_no,
            t1.business_license,
            t1.business_license_start_date,
            t1.business_license_end_date,
            t1.registration_no,
            t1.registration_authority_no,
            t1.legal_person_name,
            t1.residence,
            t1.approval_date,
            t1.master_name,
            t1.master_phone,
            t1.master_id_card_code,
            t1.master_id_card_code_name,
            t1.master_id_card,
            t1.master_id_card_front,
            t1.master_id_card_back,
            t1.office_address,
            t1.security_person_name,
            t1.security_person_phone,
            t1.degree_of_concern_id,
            t1.degree_of_concern_name,
            t1.can_establish_party_org,
            t1.has_party_org,
            t1.party_org_total_person,
            t1.has_labour_union,
            t1.labour_union_total_person,
            t1.has_communist_youth_league,
            t1.communist_youth_league_total_person,
            t1.has_women_federation,
            t1.women_total_person,
            t1.source_of_funds,
            t1.has_overseas_background,
            t1.organization_lng,
            t1.organization_lat,
            t1.area_code,
            t1.area_name,
            t1.grid_code,
            t1.grid_name,
            t1.remarks,
            t1.facade_photos,
            t1.workplace_photos,
            t1.gmt_create,
            t1.creator,
            t1.gmt_modified,
            t1.modifier,
            t1.is_delete
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
        <if test="keywords != null and keywords != ''">
        AND (
            <!-- 这里添加其他条件 -->
            t1.id LIKE CONCAT('%', #{keywords}, '%')
        )
        </if>
        <if test="startTime != null and startTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
        </if>
        <if test="organizationIds != null and organizationIds.size > 0">
        AND
            t1.organization_id IN
            <foreach collection="organizationIds" index="index" open="(" separator="," close=")">
                #{organizationIds[${index}]}
            </foreach>
        </if>
    </select>

    <!-- 社会组织列表 -->
    <select id="listPO" parameterType="map" resultMap="organizationPO">
        SELECT
            t1.organization_id,
            t1.organization_name,
            t1.organization_type_id,
            t1.organization_type_name,
            t1.organization_status,
            t1.organization_summary,
            t1.business_reg_no,
            t1.business_license,
            t1.business_license_start_date,
            t1.business_license_end_date,
            t1.registration_no,
            t1.registration_authority_no,
            t1.legal_person_name,
            t1.residence,
            t1.approval_date,
            t1.master_name,
            t1.master_phone,
            t1.master_id_card_code,
            t1.master_id_card_code_name,
            t1.master_id_card,
            t1.master_id_card_front,
            t1.master_id_card_back,
            t1.office_address,
            t1.security_person_name,
            t1.security_person_phone,
            t1.degree_of_concern_id,
            t1.degree_of_concern_name,
            t1.can_establish_party_org,
            t1.has_party_org,
            t1.party_org_total_person,
            t1.has_labour_union,
            t1.labour_union_total_person,
            t1.has_communist_youth_league,
            t1.communist_youth_league_total_person,
            t1.has_women_federation,
            t1.women_total_person,
            t1.source_of_funds,
            t1.has_overseas_background,
            t1.organization_lng,
            t1.organization_lat,
            t1.area_code,
            t1.area_name,
            t1.grid_code,
            t1.grid_name,
            t1.remarks,
            t1.facade_photos,
            t1.workplace_photos,
            t1.gmt_create,
            t1.creator,
            t1.gmt_modified,
            t1.modifier,
            t1.is_delete
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
        <if test="keywords != null and keywords != ''">
        AND (
            <!-- 这里添加其他条件 -->
            t1.id LIKE CONCAT('%', #{keywords}, '%')
        )
        </if>
        <if test="startTime != null and startTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
        </if>
        <if test="organizationIds != null and organizationIds.size > 0">
        AND
            t1.organization_id IN
            <foreach collection="organizationIds" index="index" open="(" separator="," close=")">
                #{organizationIds[${index}]}
            </foreach>
        </if>
    </select>

    <!-- 社会组织统计  -->
    <select id="count" parameterType="map" resultType="Integer">
        SELECT
            COUNT(*)
        FROM
            org_organization t1
        WHERE
            t1.is_delete = 0
    </select>

</mapper>