Compare commits
	
		
			4 Commits
		
	
	
		
			c50e8d835b
			...
			kmbin92_20
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3033582f8e | |||
| 51a29996f5 | |||
| a8e1a15b1d | |||
| d1bf1dd477 | 
							
								
								
									
										48
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								build.gradle
									
									
									
									
									
								
							@@ -1,9 +1,3 @@
 | 
			
		||||
buildscript {
 | 
			
		||||
	ext {
 | 
			
		||||
		queryDslVersion = "5.0.0"
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
plugins {
 | 
			
		||||
	id 'java'
 | 
			
		||||
	id 'org.springframework.boot' version '3.5.4'
 | 
			
		||||
@@ -30,41 +24,41 @@ repositories {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dependencies {
 | 
			
		||||
	// 개발용 의존성 추가
 | 
			
		||||
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
 | 
			
		||||
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
 | 
			
		||||
	// PostgreSQL JDBC 드라이버
 | 
			
		||||
	// PostgreSQL JDBC
 | 
			
		||||
    runtimeOnly 'org.postgresql:postgresql'
 | 
			
		||||
	implementation 'org.springframework.boot:spring-boot-starter-web'
 | 
			
		||||
	
 | 
			
		||||
	// Spring Security 추가
 | 
			
		||||
	// Spring Securit
 | 
			
		||||
	implementation 'org.springframework.boot:spring-boot-starter-security'
 | 
			
		||||
	
 | 
			
		||||
	// Validation 추가
 | 
			
		||||
	// Validation
 | 
			
		||||
	implementation 'org.springframework.boot:spring-boot-starter-validation'
 | 
			
		||||
	
 | 
			
		||||
	// MapStruct 추가 (안정적인 버전으로 수정)
 | 
			
		||||
	// MapStruct
 | 
			
		||||
	implementation 'org.mapstruct:mapstruct:1.5.5.Final'
 | 
			
		||||
	annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
 | 
			
		||||
	
 | 
			
		||||
	// MyBatis 추가
 | 
			
		||||
	// MyBatis
 | 
			
		||||
	implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
 | 
			
		||||
 | 
			
		||||
	// jwt
 | 
			
		||||
	implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	// lombok
 | 
			
		||||
	compileOnly 'org.projectlombok:lombok'
 | 
			
		||||
	annotationProcessor 'org.projectlombok:lombok'
 | 
			
		||||
	// Lombok과 MapStruct 함께 사용을 위한 바인딩
 | 
			
		||||
	annotationProcessor 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
 | 
			
		||||
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
 | 
			
		||||
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
 | 
			
		||||
 | 
			
		||||
	// querydsl
 | 
			
		||||
	implementation "com.querydsl:querydsl-jpa:${queryDslVersion}:jakarta"
 | 
			
		||||
	annotationProcessor "com.querydsl:querydsl-apt:${queryDslVersion}:jakarta"
 | 
			
		||||
	annotationProcessor "jakarta.annotation:jakarta.annotation-api"
 | 
			
		||||
	annotationProcessor "jakarta.persistence:jakarta.persistence-api"
 | 
			
		||||
	implementation 'io.github.openfeign.querydsl:querydsl-jpa:6.11'
 | 
			
		||||
	annotationProcessor 'io.github.openfeign.querydsl:querydsl-apt:6.11:jpa'
 | 
			
		||||
	annotationProcessor 'jakarta.annotation:jakarta.annotation-api'
 | 
			
		||||
	annotationProcessor 'jakarta.persistence:jakarta.persistence-api'
 | 
			
		||||
 | 
			
		||||
	// p6spy
 | 
			
		||||
	implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0'
 | 
			
		||||
}
 | 
			
		||||
@@ -74,16 +68,10 @@ tasks.named('test') {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// querydsl
 | 
			
		||||
def querydslDir = "$buildDir/generated/querydsl"
 | 
			
		||||
 | 
			
		||||
sourceSets {
 | 
			
		||||
	main.java.srcDirs += [ querydslDir ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
tasks.withType(JavaCompile) {
 | 
			
		||||
	options.annotationProcessorGeneratedSourcesDirectory = file(querydslDir)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
clean.doLast {
 | 
			
		||||
	file(querydslDir).deleteDir()
 | 
			
		||||
def generatedSrcDir = 'build/generated/sources/annotation-processor'
 | 
			
		||||
clean {
 | 
			
		||||
	delete file(generatedSrcDir)
 | 
			
		||||
}
 | 
			
		||||
tasks.withType(JavaCompile).configureEach {
 | 
			
		||||
	options.generatedSourceOutputDirectory = file(generatedSrcDir)
 | 
			
		||||
}
 | 
			
		||||
@@ -11,6 +11,8 @@
 | 
			
		||||
        password varchar(100) not null,
 | 
			
		||||
        user_id varchar(100) not null,
 | 
			
		||||
        refresh_token varchar(200),
 | 
			
		||||
        primary key (oid),
 | 
			
		||||
        constraint uk_member_user_id unique (user_id)
 | 
			
		||||
        primary key (oid)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    create index idx_member_user_id 
 | 
			
		||||
       on st_member (user_id);
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,8 @@ import java.time.LocalDateTime;
 | 
			
		||||
@Builder
 | 
			
		||||
@Table(
 | 
			
		||||
    name = "st_member",
 | 
			
		||||
    uniqueConstraints = {
 | 
			
		||||
        @UniqueConstraint(name = "uk_member_user_id", columnNames = "user_id")
 | 
			
		||||
    indexes = {
 | 
			
		||||
        @Index(name = "idx_member_user_id", columnList = "user_id")
 | 
			
		||||
    }
 | 
			
		||||
)
 | 
			
		||||
public class Member extends BaseEntity {
 | 
			
		||||
@@ -44,14 +44,4 @@ public class Member extends BaseEntity {
 | 
			
		||||
    @Column(name = "last_login_at")
 | 
			
		||||
    private LocalDateTime lastLoginAt;
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 엔티티 저장 후 실행되는 메서드
 | 
			
		||||
     * createdOid와 updatedOid를 자기 자신의 oid로 설정
 | 
			
		||||
     */
 | 
			
		||||
    @PostPersist
 | 
			
		||||
    protected void onPostPersist() {
 | 
			
		||||
        if (this.getCreatedOid() == null) {
 | 
			
		||||
            this.setCreatedOid(this.getOid());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -17,6 +17,8 @@ import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static com.bio.bio_backend.global.utils.OidUtil.generateOid;
 | 
			
		||||
 | 
			
		||||
@Service
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@Slf4j
 | 
			
		||||
@@ -52,6 +54,10 @@ public class MemberServiceImpl implements MemberService {
 | 
			
		||||
                .password(bCryptPasswordEncoder.encode(memberDTO.getPassword()))
 | 
			
		||||
                .role(MemberRole.getDefault())
 | 
			
		||||
                .build();
 | 
			
		||||
 | 
			
		||||
        Long oid = generateOid();
 | 
			
		||||
        member.setOid(oid);
 | 
			
		||||
        member.setCreatedOid(oid);
 | 
			
		||||
        
 | 
			
		||||
        Member savedMember = memberRepository.save(member);
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -6,10 +6,11 @@ import lombok.Setter;
 | 
			
		||||
import org.springframework.data.annotation.CreatedDate;
 | 
			
		||||
import org.springframework.data.annotation.LastModifiedDate;
 | 
			
		||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
 | 
			
		||||
import com.bio.bio_backend.global.utils.OidUtil;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
import static com.bio.bio_backend.global.utils.OidUtil.generateOid;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 모든 엔티티가 상속받는 기본 엔티티 클래스
 | 
			
		||||
 * 공통 필드들을 정의하고 JPA Auditing을 지원합니다.
 | 
			
		||||
@@ -40,14 +41,7 @@ public abstract class BaseEntity {
 | 
			
		||||
    
 | 
			
		||||
    @PrePersist
 | 
			
		||||
    protected void onCreate() {
 | 
			
		||||
        LocalDateTime now = LocalDateTime.now();
 | 
			
		||||
        this.oid = OidUtil.generateOid();
 | 
			
		||||
        this.createdAt = now;
 | 
			
		||||
        this.updatedAt = now;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PreUpdate
 | 
			
		||||
    protected void onUpdate() {
 | 
			
		||||
        this.updatedAt = LocalDateTime.now();
 | 
			
		||||
        if(this.oid == null) this.oid = generateOid();
 | 
			
		||||
        if(this.createdOid != null && this.updatedOid == null) this.updatedOid = this.createdOid;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user