-
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.
- Loading branch information
Showing
47 changed files
with
430 additions
and
84 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+102 KB
(200%)
Week1/seminar/.gradle/8.2.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Week1/seminar/.gradle/8.2.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+782 Bytes
(100%)
Week1/seminar/.gradle/8.2.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Week1/seminar/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file modified
BIN
+0 Bytes
(100%)
.../seminar/build/classes/java/main/com/server/dosopt/seminar/ServerSeminarApplication.class
Binary file not shown.
Binary file modified
BIN
+28 Bytes
(100%)
...minar/build/classes/java/main/com/server/dosopt/seminar/controller/MemberController.class
Binary file not shown.
Binary file modified
BIN
+31 Bytes
(100%)
Week1/seminar/build/classes/java/main/com/server/dosopt/seminar/domain/Member.class
Binary file not shown.
Binary file removed
BIN
-2.02 KB
...r/build/classes/java/main/com/server/dosopt/seminar/dto/request/MemberCreateRequest.class
Binary file not shown.
Binary file modified
BIN
+819 Bytes
(240%)
.../build/classes/java/main/com/server/dosopt/seminar/dto/response/HealthCheckResponse.class
Binary file not shown.
Binary file modified
BIN
+21 Bytes
(100%)
Week1/seminar/build/classes/java/main/com/server/dosopt/seminar/service/MemberService.class
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-2.08 KB
.../build/tmp/compileJava/compileTransaction/stash-dir/HealthCheckController.class.uniqueId4
Binary file not shown.
Binary file removed
BIN
-549 Bytes
...ar/build/tmp/compileJava/compileTransaction/stash-dir/HealthCheckResponse.class.uniqueId0
Binary file not shown.
Binary file removed
BIN
-2.04 KB
...r/build/tmp/compileJava/compileTransaction/stash-dir/Member$MemberBuilder.class.uniqueId2
Binary file not shown.
Binary file removed
BIN
-1.71 KB
Week1/seminar/build/tmp/compileJava/compileTransaction/stash-dir/Member.class.uniqueId1
Binary file not shown.
Binary file removed
BIN
-372 Bytes
...ar/build/tmp/compileJava/compileTransaction/stash-dir/MemberJpaRepository.class.uniqueId3
Binary file not shown.
Binary file modified
BIN
+25.5 KB
(180%)
Week1/seminar/build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
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
9 changes: 9 additions & 0 deletions
9
Week1/seminar/src/main/java/com/server/dosopt/seminar/config/JpaAuditingConfig.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.server.dosopt.seminar.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@Configuration | ||
@EnableJpaAuditing | ||
public class JpaAuditingConfig { | ||
} |
36 changes: 36 additions & 0 deletions
36
Week1/seminar/src/main/java/com/server/dosopt/seminar/config/SecurityConfig.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,36 @@ | ||
package com.server.dosopt.seminar.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig { | ||
|
||
|
||
@Bean | ||
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
return http.csrf().disable() | ||
.authorizeHttpRequests() | ||
.anyRequest().permitAll() | ||
.and().build(); | ||
} | ||
|
||
@Bean | ||
public WebMvcConfigurer corsConfigurer() { | ||
return new WebMvcConfigurer() { | ||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins("*") | ||
.allowedOriginPatterns("*") | ||
.allowedMethods("*"); | ||
} | ||
}; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
Week1/seminar/src/main/java/com/server/dosopt/seminar/controller/PostController.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,37 @@ | ||
package com.server.dosopt.seminar.controller; | ||
|
||
import com.server.dosopt.seminar.dto.request.post.PostCreateRequest; | ||
import com.server.dosopt.seminar.dto.response.PostGetResponse; | ||
import com.server.dosopt.seminar.service.PostService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/posts") | ||
@RequiredArgsConstructor | ||
public class PostController { | ||
private static final String CUSTOM_AUTH_ID = "X-Auth-Id"; | ||
private final PostService postService; | ||
|
||
@PostMapping | ||
public ResponseEntity<Void> createPost(@RequestHeader(CUSTOM_AUTH_ID) Long memberId, | ||
@RequestBody PostCreateRequest request){ | ||
|
||
URI location = URI.create("/api/post/" + postService.create(request, memberId)); | ||
return ResponseEntity.created(location).build(); | ||
} | ||
|
||
@GetMapping("{postId}") | ||
public ResponseEntity<PostGetResponse> getPostById(@PathVariable Long postId) { | ||
return ResponseEntity.ok(postService.getById(postId)); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<PostGetResponse>> getPosts(@RequestHeader(CUSTOM_AUTH_ID) Long memberId) { | ||
return ResponseEntity.ok(postService.getPosts(memberId)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Week1/seminar/src/main/java/com/server/dosopt/seminar/domain/BaseTimeEntity.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.server.dosopt.seminar.domain; | ||
|
||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseTimeEntity { | ||
|
||
@CreatedDate // 현재시각으로 초기화해줌 | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime updateAt; | ||
} |
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
33 changes: 33 additions & 0 deletions
33
Week1/seminar/src/main/java/com/server/dosopt/seminar/domain/Post.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,33 @@ | ||
package com.server.dosopt.seminar.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Table(name = "post") | ||
public class Post extends BaseTimeEntity{ | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String title; | ||
|
||
@Column(columnDefinition = "TEXT") | ||
private String content; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@Builder | ||
public Post(String title, String content, Member member) { | ||
this.title = title; | ||
this.content = content; | ||
this.member = member; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...inar/dto/request/MemberCreateRequest.java → ...o/request/member/MemberCreateRequest.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
7 changes: 7 additions & 0 deletions
7
...1/seminar/src/main/java/com/server/dosopt/seminar/dto/request/post/PostCreateRequest.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,7 @@ | ||
package com.server.dosopt.seminar.dto.request.post; | ||
|
||
public record PostCreateRequest( | ||
String title, | ||
String content | ||
) { | ||
} |
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
17 changes: 17 additions & 0 deletions
17
Week1/seminar/src/main/java/com/server/dosopt/seminar/dto/response/PostGetResponse.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,17 @@ | ||
package com.server.dosopt.seminar.dto.response; | ||
|
||
import com.server.dosopt.seminar.domain.Post; | ||
|
||
public record PostGetResponse( | ||
Long id, | ||
String title, | ||
String content | ||
) { | ||
public static PostGetResponse of(Post post) { | ||
return new PostGetResponse( | ||
post.getId(), | ||
post.getTitle(), | ||
post.getContent() | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Week1/seminar/src/main/java/com/server/dosopt/seminar/exception/BadRequestException.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,7 @@ | ||
package com.server.dosopt.seminar.exception; | ||
|
||
public class BadRequestException extends RuntimeException{ | ||
public BadRequestException(String message) { | ||
super(message); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Week1/seminar/src/main/java/com/server/dosopt/seminar/exception/BusinessException.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,7 @@ | ||
package com.server.dosopt.seminar.exception; | ||
|
||
public class BusinessException extends RuntimeException{ | ||
public BusinessException(String message) { | ||
super(message); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Week1/seminar/src/main/java/com/server/dosopt/seminar/exception/GlobalExceptionHandler.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.server.dosopt.seminar.exception; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(IllegalArgumentException.class) | ||
public ResponseEntity<Void> handleIllegalArgumentException(final IllegalArgumentException e) { | ||
return ResponseEntity.badRequest().build(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Week1/seminar/src/main/java/com/server/dosopt/seminar/reposiotry/PostJpaRepository.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,13 @@ | ||
package com.server.dosopt.seminar.reposiotry; | ||
|
||
import com.server.dosopt.seminar.domain.Member; | ||
import com.server.dosopt.seminar.domain.Post; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface PostJpaRepository extends JpaRepository<Post,Long> { | ||
|
||
List<Post> findAllByMemberId(Long memberId); | ||
List<Post> findAllByMember(Member member); | ||
} |
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
Oops, something went wrong.