server/src/main/java/com/example/server/dto/MemberRequestDto.java
<filename>server/src/main/java/com/example/server/dto/MemberRequestDto.java<gh_stars>0package com.example.server.dto;

import com.example.server.entity.MemberAuthority;
import com.example.server.entity.MemberEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.crypto.password.PasswordEncoder;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MemberRequestDto {

    private String userId;
    private String password;
    private String name;
    private String location;

    public MemberEntity toMember(PasswordEncoder passwordEncoder) {
        return MemberEntity.builder()
                .userId(userId)
                .password(passwordEncoder.encode(password))
                .name(name)
                .location(location)
                .memberAuthority(MemberAuthority.ROLE_USER)
                .build();
    }

    // 아이디와 비밀번호가 일치하는지 검증하는 로직
    public UsernamePasswordAuthenticationToken toAuthentication() {
        return new UsernamePasswordAuthenticationToken(userId, password);
    }

}
