-
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.
Loading status checks…
Merge pull request #47 from Move-Log/develop
Merge develop to main
Showing
21 changed files
with
329 additions
and
90 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
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,38 @@ | ||
package com.movelog.domain.news.domain; | ||
|
||
import com.movelog.domain.common.BaseEntity; | ||
import com.movelog.domain.record.domain.Keyword; | ||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "News") | ||
@NoArgsConstructor | ||
@Getter | ||
public class News extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "news_id", updatable = false) | ||
private Long newsId; | ||
|
||
private String headLine; //뉴스 헤드라인 | ||
|
||
private String newsUrl; //뉴스 URL | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "keyword_id") | ||
private Keyword keyword; | ||
|
||
@Builder | ||
public News(String headLine, String newsUrl, Keyword keyword) { | ||
this.headLine = headLine; | ||
this.newsUrl = newsUrl; | ||
this.keyword = keyword; | ||
} | ||
|
||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/movelog/domain/news/domain/repository/NewsRepository.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.movelog.domain.news.domain.repository; | ||
|
||
import com.movelog.domain.news.domain.News; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface NewsRepository extends JpaRepository<News, Long> { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/movelog/domain/news/dto/request/CreateNewsReq.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,18 @@ | ||
package com.movelog.domain.news.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class CreateNewsReq { | ||
|
||
@Schema( type = "String", example ="5년 만의 첫 도전, 무엇이 그를 움직이게 했나?", description="사용자가 선택한/생성한 헤드라인 정보입니다.") | ||
private String headLine; | ||
|
||
} |
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/movelog/domain/record/exception/KeywordNotFoundException.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,11 @@ | ||
package com.movelog.domain.record.exception; | ||
|
||
|
||
import com.movelog.global.exception.NotFoundException; | ||
|
||
public class KeywordNotFoundException extends NotFoundException { | ||
|
||
public KeywordNotFoundException() { | ||
super("U002", "키워드를 찾을 수 없습니다."); | ||
} | ||
} |
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
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
11 changes: 0 additions & 11 deletions
11
src/main/java/com/movelog/domain/user/exception/UserDuplicateException.java
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
package com.movelog.global.payload; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class ApiResponse { | ||
|
||
@Schema( type = "boolean", example = "true", description="올바르게 로직을 처리했으면 True, 아니면 False를 반환합니다.") | ||
private boolean check; | ||
public class ApiResponse<T> { | ||
|
||
@Schema( type = "object", example = "information", description="restful의 정보를 감싸 표현합니다. object형식으로 표현합니다.") | ||
private Object information; | ||
@Schema(type = "boolean", example = "true", description = "로직 처리 성공 여부를 반환합니다.") | ||
private final boolean check; | ||
|
||
public ApiResponse(){}; | ||
@Schema(type = "object", description = "응답 데이터를 담는 필드입니다.") | ||
private final T information; | ||
|
||
@Builder | ||
public ApiResponse(boolean check, Object information) { | ||
public ApiResponse(boolean check, T information) { | ||
this.check = check; | ||
this.information = information; | ||
} | ||
|
||
// 정적 팩토리 메서드로 명확한 응답 생성 | ||
public static <T> ApiResponse<T> success(T data) { | ||
return new ApiResponse<>(true, data); | ||
} | ||
|
||
public static <T> ApiResponse<T> failure(T errorMessage) { | ||
return new ApiResponse<>(false, errorMessage); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/movelog/global/util/ApiResponseUtil.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,31 @@ | ||
package com.movelog.global.util; | ||
|
||
import com.movelog.global.payload.ApiResponse; | ||
import com.movelog.global.payload.ErrorResponse; | ||
import lombok.experimental.UtilityClass; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.util.List; | ||
@UtilityClass | ||
public class ApiResponseUtil { | ||
|
||
public static <T> ResponseEntity<ApiResponse<T>> success(T data) { | ||
ApiResponse<T> apiResponse = ApiResponse.<T>builder() | ||
.check(true) | ||
.information(data) | ||
.build(); | ||
|
||
return ResponseEntity.ok(apiResponse); | ||
} | ||
|
||
public static <T> ResponseEntity<ApiResponse<List<T>>> success(List<T> data) { | ||
ApiResponse<List<T>> apiResponse = ApiResponse.<List<T>>builder() | ||
.check(true) | ||
.information(data) | ||
.build(); | ||
|
||
return ResponseEntity.ok(apiResponse); | ||
} | ||
|
||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/movelog/global/util/ErrorResponseUtil.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,22 @@ | ||
package com.movelog.global.util; | ||
|
||
import com.movelog.global.payload.ErrorResponse; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
public class ErrorResponseUtil { | ||
|
||
public static ResponseEntity<ErrorResponse> failure( | ||
String errorCode, HttpStatus status, String message, Class<?> clazz) { | ||
ErrorResponse errorResponse = ErrorResponse.builder() | ||
.code(errorCode) | ||
.status(status.value()) | ||
.message(message) | ||
.clazz(clazz.getSimpleName()) | ||
.build(); | ||
|
||
return ResponseEntity.status(status).body(errorResponse); | ||
} | ||
|
||
} | ||
|
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