-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from 7th-UMC-Hackathon-TeamV/feat/post
Feat/post
- Loading branch information
Showing
8 changed files
with
210 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package banban.springboot.config; | ||
|
||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
public class WebConfig implements WebMvcConfigurer { | ||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins("https://on-air.netlify.app") | ||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") | ||
.allowedHeaders("*") | ||
.allowCredentials(true) | ||
.maxAge(3600); | ||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/banban/springboot/web/controller/NewsTestController.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,40 @@ | ||
package banban.springboot.web.controller; | ||
|
||
import banban.springboot.apiPayload.ApiResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Tag(name = "뉴스-테스트") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@Validated | ||
@RequestMapping("/api/test") | ||
public class NewsTestController { | ||
|
||
private static LocalDateTime mockCurrentTime; | ||
|
||
@Operation(summary = "테스트용 현재 시간 설정") | ||
@PostMapping("/set-time") | ||
public ApiResponse<String> setTestTime( | ||
@RequestParam @Parameter(example = "2024-01-02T14:00:00", description = "설정할 시간 (yyyy-MM-dd'T'HH:mm:ss 형식)") | ||
String dateTime) { | ||
mockCurrentTime = LocalDateTime.parse(dateTime); | ||
return ApiResponse.onSuccess("현재 시간이 " + dateTime + "으로 설정되었습니다."); | ||
} | ||
|
||
@Operation(summary = "현재 설정된 테스트 시간 조회") | ||
@GetMapping("/current-time") | ||
public ApiResponse<String> getCurrentTestTime() { | ||
return ApiResponse.onSuccess(mockCurrentTime.toString()); | ||
} | ||
|
||
public static LocalDateTime getMockCurrentTime() { | ||
return mockCurrentTime; | ||
} | ||
} |
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