package com.zhongshu.card.server.core.dao.org;

import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
import com.zhongshu.card.client.type.OrganizationRelationType;
import com.zhongshu.card.server.core.dao.org.extend.OrganizationRelationDaoExtend;
import com.zhongshu.card.server.core.domain.org.Organization;
import com.zhongshu.card.server.core.domain.org.OrganizationRelation;

import java.util.List;

/**
 * @author TRX
 * @date 2024/3/21
 */
public interface OrganizationRelationDao extends MongoDao<OrganizationRelation>, OrganizationRelationDaoExtend {

    OrganizationRelation findTopById(String id);

    List<OrganizationRelation> findByMainOrganizationAndRelationType(Organization mainOrganization, OrganizationRelationType relationType);

    void deleteByMainOrganizationAndRelationType(Organization mainOrganization, OrganizationRelationType relationType);

    OrganizationRelation findTopByMainOrganizationAndRelationType(Organization mainOrganization,
            OrganizationRelationType relationType);

    List<OrganizationRelation> findByRelOrganizationAndRelationType(Organization relOrganization, OrganizationRelationType relationType);

    // 统计项目已有的学校
    long countByRelOrganizationAndRelationType(Organization relOrganization, OrganizationRelationType relationType);

    long countByMainOrganizationAndRelationType(Organization mainOrganization, OrganizationRelationType relationType);

    OrganizationRelation findTopByMainOrganizationAndRelOrganizationAndRelationType(
            Organization mainOrganization,
            Organization relOrganization,
            OrganizationRelationType relationType
    );
}
