package kr.itn.itnhub.org;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface OrganizationMapper {

    List<Organization> findAll();

    Organization findById(@Param("id") Long id);

    /** 연번+기관명 유니크 키로 단건 조회. 시드가 upsert 직후 방금 반영된 행을 다시 읽을 때 쓴다. */
    Organization findByOrgNoAndOrgName(@Param("orgNo") String orgNo, @Param("orgName") String orgName);

    /** 기관명 단독(정확 일치) 조회. 회원명단 업로드가 신청기관 담당자를 자동 배정할 때 쓴다. */
    Organization findByOrgName(@Param("orgName") String orgName);

    /** 시드 전용. 비어 있는 칸만 채우고 채널ID·기입된 값은 그대로 둔다. */
    int upsertBySeed(Organization org);

    int updateAssignments(@Param("id") Long id,
                          @Param("applicantContactId") Long applicantContactId,
                          @Param("mjContactId") Long mjContactId,
                          @Param("itnContactId") Long itnContactId,
                          @Param("lawyerContactId") Long lawyerContactId,
                          @Param("lawyerAssignedDate") String lawyerAssignedDate);

    int updateChannelIdMj(@Param("id") Long id,
                          @Param("channelId") String channelId);

    int updateChannelIdLaw(@Param("id") Long id,
                           @Param("channelId") String channelId);
}
