Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

@Configuration
public class SwaggerConfig {
@Value("${server.url}")
private String serverUrl;
@Value("${swagger.server.url}")
private String swaggerServerUrl;

@Bean
public OpenAPI openAPI() {
String jwt = "JWT";
Expand All @@ -28,8 +29,11 @@ public OpenAPI openAPI() {
);

ArrayList<Server> servers = new ArrayList<>();
servers.add(new Server().url("https://"+serverUrl).description("AdoongE Server"));
servers.add(new Server().url("http://localhost:8080").description("Local Server"));
if(swaggerServerUrl.contains("localhost")){
servers.add(new Server().url(swaggerServerUrl).description("Local Server"));
}else{
servers.add(new Server().url("https://"+swaggerServerUrl).description("AdoongE Server"));
Comment on lines +32 to +35
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a substring check to detect localhost URLs is brittle; consider relying on an explicit environment/profile flag or parsing the URL scheme so you can handle various formats and avoid accidental mismatches.

Suggested change
if(swaggerServerUrl.contains("localhost")){
servers.add(new Server().url(swaggerServerUrl).description("Local Server"));
}else{
servers.add(new Server().url("https://"+swaggerServerUrl).description("AdoongE Server"));
try {
java.net.URI uri = new java.net.URI(swaggerServerUrl);
String host = uri.getHost();
if ("localhost".equals(host) || "127.0.0.1".equals(host) || "[::1]".equals(host)) {
servers.add(new Server().url(swaggerServerUrl).description("Local Server"));
} else {
servers.add(new Server().url("https://" + swaggerServerUrl).description("AdoongE Server"));
}
} catch (java.net.URISyntaxException e) {
throw new IllegalArgumentException("Invalid URL format for swaggerServerUrl: " + swaggerServerUrl, e);

Copilot uses AI. Check for mistakes.
}

return new OpenAPI()
.components(new Components())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
public record SeedRequest(
@NotNull SeedType seedType,
String seedName, // ์—†์œผ๋ฉด null
String[] boardCategories,
String[] categoryName, // ์—†์œผ๋ฉด null
Long thumbnailImage, // ์—†์œผ๋ฉด null
String seedLink, // link๋งŒ ํ•ด๋‹น, ๋‚˜๋จธ์ง€ null
@NotNull @Size(min = 2, message = "ํƒœ๊ทธ๋Š” 2๊ฐœ ์ด์ƒ ์„ ํƒํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.") String[] tags,
@NotNull @Size(min = 2, message = "ํƒœ๊ทธ๋Š” 2๊ฐœ ์ด์ƒ ์„ ํƒํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.") String[] tagName,
LocalDate dDay, // ์—†์œผ๋ฉด null
String seedDetail // ์—†์œผ๋ฉด null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
public record SeedUpdateRequest(
@NotNull SeedType seedType,
String seedName, // ์—†์œผ๋ฉด null
@NotNull String[] boardCategories,
@NotNull String[] categoryName, // ์—†์œผ๋ฉด null
Long thumbnailImage, // ์—†์œผ๋ฉด null
String seedLink, // link๋งŒ ํ•ด๋‹น, ๋‚˜๋จธ์ง€ null
@NotNull @Size(min = 2, message = "ํƒœ๊ทธ๋Š” ์ตœ์†Œ 2๊ฐœ ์ด์ƒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.") String[] tags,
@NotNull @Size(min = 2, message = "ํƒœ๊ทธ๋Š” ์ตœ์†Œ 2๊ฐœ ์ด์ƒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.") String[] tagName,
LocalDate dDay, // ์—†์œผ๋ฉด null
String seedDetail // ์—†์œผ๋ฉด null
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
package com.adoonge.seedzip.seed.dto.response;

import com.adoonge.seedzip.seed.domain.SeedType;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

import lombok.Builder;

public class SeedResponse {

@Builder
public record PageInfo(int page, int size, int totalPages, long totalElements, boolean isLast) {}

@Builder
public record SeedInfo(Long seedId, String seedName, List<Long> categoryId, List<String> categoryName,
SeedType seedType, String thumbnailImage, LocalDateTime updatedDt,
List<Long> tagId, List<String> tagName, int dDay, Boolean isSaved) {}

@Builder
public record GetAllSeeds(String nickname, List<SeedInfo> seedInfoList, PageInfo pageInfo) {}

@Builder
public record SeedInfoSimple(Long seedId, String seedName){}

@Builder
public record SeedDetail(Long seedId,
SeedType seedType,
String seedName,
String seedLink,
List<String> fileLinks,
List<String> titles,
Long thumbnailImage,
List<String> categoryNames,
List<String> tagNames,
LocalDate dDay,
String seedDetail){}

@Builder
public record SeedInfoWithSeedDetail(
Long seedId, String seedName, List<Long> categoryId, List<String> categoryName,
SeedType seedType, String thumbnailImage, LocalDateTime updatedDt,
List<Long> tagId, List<String> tagName, int dDay, String seedDetail, Boolean isSaved
){}

@Builder
public record GetFilteredSeeds(String nickname, List<SeedInfoWithSeedDetail> seedInfoList, PageInfo pageInfo){}
@Builder
public record PageInfo(int page, int size, int totalPages, long totalElements, boolean isLast) {
}

@Builder
public record SeedInfo(Long seedId, String seedName, List<Long> categoryId, List<String> categoryName,
SeedType seedType, String thumbnailImage, LocalDateTime updatedDt,
List<Long> tagId, List<String> tagName, int dDay, Boolean isSaved) {
}

@Builder
public record GetAllSeeds(String nickname, List<SeedInfo> seedInfoList, PageInfo pageInfo) {
}

@Builder
public record SeedInfoSimple(Long seedId, String seedName) {
}

@Builder
public record SeedDetail(Long seedId,
SeedType seedType,
String seedName,
String seedLink,
List<String> fileLinks,
List<String> titles,
Long thumbnailImage,
List<String> categoryName,
List<String> tagName,
LocalDate dDay,
String seedDetail) {
}

@Builder
public record SeedInfoWithSeedDetail(
Long seedId, String seedName, List<Long> categoryId, List<String> categoryName,
SeedType seedType, String thumbnailImage, LocalDateTime updatedDt,
List<Long> tagId, List<String> tagName, int dDay, String seedDetail, Boolean isSaved) {
}

@Builder
public record GetFilteredSeeds(String nickname, List<SeedInfoWithSeedDetail> seedInfoList, PageInfo pageInfo) {
}
}
14 changes: 7 additions & 7 deletions src/main/java/com/adoonge/seedzip/seed/service/SeedService.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ public SeedResponse.SeedInfoSimple uploadSeed(SeedRequest seedRequest, Member me
Seed seed = saveSeed(seedRequest, member);

// ํƒœ๊ทธ ๋ฐ ์นดํ…Œ๊ณ ๋ฆฌ ์ €์žฅ
saveSeedTags(seedRequest.tags(), member, seed);
if(seedRequest.boardCategories() == null) {
saveSeedTags(seedRequest.tagName(), member, seed);
if(seedRequest.categoryName() == null) {
saveSeedDefaultCategory(member, seed);
} else {
saveSeedCategories(seedRequest.boardCategories(), member, seed);
saveSeedCategories(seedRequest.categoryName(), member, seed);
}

if (seedRequest.seedType() == SeedType.LINK) {
Expand Down Expand Up @@ -215,8 +215,8 @@ public SeedResponse.SeedDetail getSeedDetail(Long seedId) {
.fileLinks(fileLinks)
.titles(titles)
.thumbnailImage(thumbnailImage)
.categoryNames(categoryNames)
.tagNames(tagNames)
.categoryName(categoryNames)
.tagName(tagNames)
.dDay(seed.getDDay())
.seedDetail(seed.getSeedDetail())
.build();
Expand Down Expand Up @@ -374,11 +374,11 @@ public SeedResponse.SeedInfoSimple updateSeed(SeedUpdateRequest request,

// ํƒœ๊ทธ
seedTagRepository.deleteAllBySeedId(seedId);
saveSeedTags(request.tags(), member, seed);
saveSeedTags(request.tagName(), member, seed);

// ์นดํ…Œ๊ณ ๋ฆฌ
categorySeedRepository.deleteAllBySeedId(seedId);
saveSeedCategories(request.boardCategories(), member, seed);
saveSeedCategories(request.categoryName(), member, seed);

if (seed.getSeedType().equals(SeedType.LINK)) {
File file = fileRepository.findBySeed(seed).orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/v2/simplification")
//@RestController
//@RequestMapping("/api/v2/simplification")
@RequiredArgsConstructor
@Tag(name = "SimplificationController V2", description = "์ œ๋ชฉ, ์š”์•ฝ, ํƒœ๊ทธ ๊ฐ„๋žตํ™” ๊ด€๋ จ API V2")
//@Tag(name = "SimplificationController V2", description = "์ œ๋ชฉ, ์š”์•ฝ, ํƒœ๊ทธ ๊ฐ„๋žตํ™” ๊ด€๋ จ API V2")
public class SimplificationControllerV2 {

private final SimplificationService simplificationService;
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ springdoc:
show-login-endpoint: true
swagger-ui:
path: /swagger-ui.html
groups-order: desc
tags_sorter: alpha
operations_sorter: method # delete - get - patch - post - put ์ •๋ ฌ
api-docs:
path: /v1/api-docs

swagger:
server:
url: ${SWAGGER_URL}

kakao:
api:
key: ${KAKAO_API_KEY}
Expand Down