package com.bio.bio_backend.domain.base.member.mapper;

import com.bio.bio_backend.domain.base.member.dto.CreateMemberRequestDto;
import com.bio.bio_backend.domain.base.member.dto.CreateMemberResponseDto;
import com.bio.bio_backend.domain.base.member.dto.LoginResponseDto;
import com.bio.bio_backend.domain.base.member.dto.MemberDto;
import com.bio.bio_backend.domain.base.member.dto.MemberSearchCondition;
import com.bio.bio_backend.domain.base.member.dto.GetMembersRequestDto;
import com.bio.bio_backend.domain.base.member.dto.GetMembersPagedRequestDto;
import com.bio.bio_backend.domain.base.member.dto.GetMemberResponseDto;
import com.bio.bio_backend.domain.base.member.entity.Member;
import com.bio.bio_backend.global.annotation.IgnoreBaseEntityMapping;
import com.bio.bio_backend.global.config.GlobalMapperConfig;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import java.util.List;

@Mapper(config = GlobalMapperConfig.class)
public interface MemberMapper {
    
    /**
     * CreateMemberRequestDto를 MemberDto로 변환
     * 기본값 설정: useFlag = true
     */
    @Mapping(target = "oid", ignore = true)
    @Mapping(target = "useFlag", constant = "true")
    @Mapping(target = "refreshToken", ignore = true)
    @Mapping(target = "loginIp", ignore = true)
    @Mapping(target = "lastLoginAt", ignore = true)
    @Mapping(target = "createdAt", ignore = true)
    @Mapping(target = "updatedAt", ignore = true)
    MemberDto toMemberDto(CreateMemberRequestDto requestDto);
    
    /**
     * Member 엔티티를 MemberDto로 변환
     */
    MemberDto toMemberDto(Member member);
    
    /**
     * MemberDto를 Member 엔티티로 변환
     */
    Member toMember(MemberDto memberDto);
    
    /**
     * Member 엔티티 리스트를 MemberDto 리스트로 변환
     */
    List<MemberDto> toMemberDtoList(List<Member> members);
    
    /**
     * MemberDto를 CreateMemberResponseDto로 변환
     */
    CreateMemberResponseDto toCreateMemberResponseDto(MemberDto memberDto);
    
    /**
     * MemberDto의 값으로 기존 Member 엔티티 업데이트 (null이 아닌 필드만)
     */
    @IgnoreBaseEntityMapping
    void updateMemberFromDto(MemberDto memberDto, @org.mapstruct.MappingTarget Member member);
    
    /**
     * MemberDto를 LoginResponseDto로 변환
     */
    LoginResponseDto toLoginResponseDto(MemberDto memberDto);
    
    /**
     * Member 엔티티를 GetMemberResponseDto로 변환 (민감한 정보 제외)
     */
    GetMemberResponseDto toGetMemberResponseDto(Member member);
    
    /**
     * Member 엔티티 리스트를 GetMemberResponseDto 리스트로 변환 (민감한 정보 제외)
     */
    List<GetMemberResponseDto> toGetMemberResponseDtoList(List<Member> members);
    
    /**
     * GetMembersRequestDto를 MemberSearchCondition으로 변환
     */
    MemberSearchCondition toSearchCondition(GetMembersRequestDto request);
    
    /**
     * GetMembersPagedRequestDto를 MemberSearchCondition으로 변환
     */
    MemberSearchCondition toSearchCondition(GetMembersPagedRequestDto request);
}
