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

import com.bio.bio_backend.domain.user.member.dto.CreateMemberRequestDto;
import com.bio.bio_backend.domain.user.member.dto.CreateMemberResponseDto;
import com.bio.bio_backend.domain.user.member.dto.MemberDto;
import com.bio.bio_backend.domain.user.member.entity.Member;
import com.bio.bio_backend.domain.user.member.enums.MemberRole;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;

@Mapper(componentModel = "spring")
public interface MemberMapper {
    
    MemberMapper INSTANCE = Mappers.getMapper(MemberMapper.class);
    
    /**
     * CreateMemberRequestDto를 MemberDto로 변환
     * 기본값 설정: role = MemberRole.MEMBER, useFlag = true
     */
    @Mapping(target = "oid", ignore = true)
    @Mapping(target = "role", expression = "java(com.bio.bio_backend.domain.user.member.enums.MemberRole.getDefault())")
    @Mapping(target = "useFlag", constant = "true")
    @Mapping(target = "refreshToken", 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);
}
