-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat:Member, AuthorityCode 생성
- Loading branch information
Showing
13 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.addLombokGeneratedAnnotation = true |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/integrated/techhub/common/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.integrated.techhub.common.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
public class RedisConfig { | ||
|
||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.port}") | ||
private int port; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
return new LettuceConnectionFactory(host, port); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/integrated/techhub/member/domain/AuthorityCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.integrated.techhub.member.domain; | ||
|
||
import lombok.Getter; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@RedisHash(value = "authority_code", timeToLive = 180) | ||
public class AuthorityCode { | ||
|
||
@Id | ||
private String email; | ||
|
||
private Integer value; | ||
|
||
public AuthorityCode(String email, Integer value) { | ||
this.email = email; | ||
this.value = value; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/integrated/techhub/member/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.integrated.techhub.member.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static jakarta.persistence.EnumType.STRING; | ||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class Member { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
@Column(length = 32, nullable = false, unique = true) | ||
private String email; | ||
|
||
@Column(length = 128, nullable = false) | ||
private String password; | ||
|
||
@Column(length = 4, nullable = false) | ||
private String nickname; | ||
|
||
@Column(length = 6, nullable = false) | ||
private String name; | ||
|
||
@Column(length = 128) | ||
private String bio; | ||
|
||
@Column | ||
@Enumerated(value = STRING) | ||
private Position position; | ||
|
||
public Member(String email, String password, String nickname, String name, String bio, Position position) { | ||
this.email = email; | ||
this.password = password; | ||
this.nickname = nickname; | ||
this.name = name; | ||
this.bio = bio; | ||
this.position = position; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/integrated/techhub/member/domain/Position.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.integrated.techhub.member.domain; | ||
|
||
public enum Position { | ||
|
||
BE, | ||
FE, | ||
AOS | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/integrated/techhub/member/domain/repository/AuthorityCodeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.integrated.techhub.member.domain.repository; | ||
|
||
import com.integrated.techhub.member.domain.AuthorityCode; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface AuthorityCodeRepository extends CrudRepository<AuthorityCode, String> { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/integrated/techhub/member/domain/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.integrated.techhub.member.domain.repository; | ||
|
||
import com.integrated.techhub.member.domain.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# redis | ||
spring: | ||
data: | ||
redis: | ||
host: localhost | ||
port: ${REDIS_OUT_BOUND_PORT} | ||
|
||
--- | ||
# application | ||
spring: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/java/com/integrated/techhub/member/domain/AuthorityCodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.integrated.techhub.member.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class AuthorityCodeTest { | ||
|
||
@Test | ||
void 생성자를_생성할수_있다() { | ||
assertDoesNotThrow(() -> new AuthorityCode("[email protected]", 987654)); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/com/integrated/techhub/member/domain/MemberTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.integrated.techhub.member.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
class MemberTest { | ||
|
||
@Test | ||
void 생성자를_생성할수_있다() { | ||
assertDoesNotThrow(() -> new Member("[email protected]", "moomin12", "무민", | ||
"홍길동", "반갑습니다", Position.BE)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters