-
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 branch information
Showing
12 changed files
with
187 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package banban.springboot.domain.entity; | ||
|
||
import banban.springboot.domain.enums.NewsCategories; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import org.hibernate.annotations.ColumnDefault; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class News { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 30) | ||
private String headline;; | ||
|
||
@Column(nullable = false, length = 1000) | ||
private String content; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private NewsCategories newsCategories; //긍정,부정 | ||
|
||
@ColumnDefault("0") | ||
@Column(name = "like_count", nullable = false) | ||
private Integer likes; | ||
|
||
@ElementCollection | ||
private List<String> thumbnail_URL; | ||
|
||
@Column(nullable = false) | ||
private boolean isBreakingNews; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime createdAt = LocalDateTime.now(); | ||
|
||
} |
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,4 +1,26 @@ | ||
package banban.springboot.domain.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class User { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 20) | ||
private String userid; | ||
|
||
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL) | ||
private List<News> NewsList = new ArrayList<>(); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/banban/springboot/domain/enums/NewsCategories.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,5 @@ | ||
package banban.springboot.domain.enums; | ||
|
||
public enum NewsCategories { | ||
POSITIVE, NEGATIVE | ||
} |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/banban/springboot/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,14 @@ | ||
package banban.springboot.repository; | ||
|
||
import banban.springboot.domain.entity.News; | ||
import banban.springboot.domain.enums.NewsCategories; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface NewsRepository extends JpaRepository<News,Long> { | ||
List<News> findByIsBreakingNewsTrue(); // 속보 뉴스 조회 | ||
List<News> findByNewsCategories(NewsCategories newsCategories); // 긍정/부정 뉴스 조회 | ||
} |
10 changes: 9 additions & 1 deletion
10
src/main/java/banban/springboot/repository/UserRepository.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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
package banban.springboot.repository; | ||
|
||
public interface UserRepository { | ||
import org.apache.catalina.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface UserRepository extends JpaRepository<User, Long> { | ||
List<User> findByUsername(String userId); | ||
} |
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,12 @@ | ||
package banban.springboot.service; | ||
|
||
import banban.springboot.repository.NewsRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class NewsService { | ||
|
||
@Autowired | ||
private NewsRepository newsRepository; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/banban/springboot/web/dto/request/NewsRequestDTO.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,34 @@ | ||
package banban.springboot.web.dto.request; | ||
|
||
import banban.springboot.domain.enums.NewsCategories; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
public class NewsRequestDTO { | ||
@NotBlank | ||
@Size(max = 30, message = "뉴스 헤드라인은 최대 30자입니다.") | ||
private String headline; | ||
|
||
@NotBlank | ||
@Size(max = 1000, message = "뉴스 본문은 최대 1000자입니다.") | ||
private String content; | ||
|
||
private List<MultipartFile> images; // 사용자가 업로드한 이미지 | ||
|
||
private boolean isBreakingNews; // 속보 여부 | ||
|
||
@NotNull(message = "긍정인지 부정인지 작성해주세요") | ||
private NewsCategories newsCategories; | ||
|
||
private LocalDateTime createdAt = LocalDateTime.now(); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/banban/springboot/web/dto/request/UserRequestDTO.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 |
---|---|---|
@@ -1,4 +1,18 @@ | ||
package banban.springboot.web.dto.request; | ||
|
||
import jakarta.validation.constraints.Max; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
public class UserRequestDTO { | ||
private String id; | ||
@Max(20) | ||
private String userId; | ||
|
||
@Max(20) | ||
private String password; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/banban/springboot/web/dto/response/NewsResponseDTO.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,19 @@ | ||
package banban.springboot.web.dto.response; | ||
|
||
import lombok.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@Builder | ||
@AllArgsConstructor | ||
public class NewsResponseDTO { | ||
private Long id; | ||
private String headline; | ||
private String content; | ||
private List<MultipartFile> images; | ||
private boolean isBreakingNews; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/banban/springboot/web/dto/response/UserResponseDTO.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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
package banban.springboot.web.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class UserResponseDTO { | ||
private String userId; | ||
private String password; | ||
} |