-
Notifications
You must be signed in to change notification settings - Fork 6
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 #140 from prgrms-web-devcourse-final-project/develop
HomeController 추가 Main 반영
- Loading branch information
Showing
15 changed files
with
134 additions
and
26 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
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
54 changes: 43 additions & 11 deletions
54
src/main/java/com/mallangs/domain/image/entity/Image.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,31 +1,63 @@ | ||
package com.mallangs.domain.image.entity; | ||
|
||
import com.mallangs.domain.chat.entity.ChatMessage; | ||
import com.mallangs.domain.article.entity.Article; | ||
import com.mallangs.domain.board.entity.Board; | ||
import com.mallangs.domain.member.entity.Member; | ||
import com.mallangs.domain.pet.entity.Pet; | ||
import com.mallangs.domain.review.entity.Review; | ||
import com.mallangs.global.common.BaseTimeEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "image") | ||
public class Image { | ||
@AllArgsConstructor | ||
@Builder | ||
public class Image extends BaseTimeEntity { | ||
@Id | ||
@Column(nullable = false, unique = true) | ||
private String url; | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long imageId; | ||
|
||
private String originalFileName; | ||
// 이미지가 필요한 도메인: Article, Board, Member, Pet, Review | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "article_id") | ||
private Article article; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "board_id") | ||
private Board board; | ||
|
||
private String contentType; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "pet_id") | ||
private Pet pet; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "review_id") | ||
private Review review; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ImageOrder imageOrder; | ||
|
||
@Column(nullable = false) | ||
private Integer width; | ||
private String originalFileName; | ||
|
||
@Column(nullable = false) | ||
private Integer height; | ||
private String storedFileName; | ||
|
||
@Column(nullable = false) | ||
private int fileSize; | ||
|
||
@Column(nullable = false) | ||
private String s3Url; | ||
|
||
@Column(nullable = false) | ||
private Integer width; | ||
|
||
@Column(nullable = false) | ||
private Integer height; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/mallangs/domain/image/entity/ImageOrder.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 com.mallangs.domain.image.entity; | ||
|
||
public enum ImageOrder { | ||
FIRST, SECOND, THIRD, FOURTH | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/mallangs/domain/image/repository/ImageRepository.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,9 +1,46 @@ | ||
package com.mallangs.domain.image.repository; | ||
|
||
import com.mallangs.domain.article.entity.Article; | ||
import com.mallangs.domain.board.entity.Board; | ||
import com.mallangs.domain.image.entity.Image; | ||
import com.mallangs.domain.member.entity.Member; | ||
import com.mallangs.domain.pet.entity.Pet; | ||
import com.mallangs.domain.review.entity.Review; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface ImageRepository extends JpaRepository<Image, Long> { | ||
|
||
// Article에 연결된 이미지 조회 | ||
List<Image> findByArticle(Article article); | ||
|
||
// Board에 연결된 이미지 조회 | ||
List<Image> findByBoard(Board board); | ||
|
||
// Member에 연결된 이미지 조회 | ||
List<Image> findByMember(Member member); | ||
|
||
// Pet에 연결된 이미지 조회 | ||
List<Image> findByPet(Pet pet); | ||
|
||
// Review에 연결된 이미지 조회 | ||
List<Image> findByReview(Review review); | ||
|
||
// Article에 연결된 이미지 삭제 | ||
void deleteByArticle(Article article); | ||
|
||
// Board에 연결된 이미지 삭제 | ||
void deleteByBoard(Board board); | ||
|
||
// Member에 연결된 이미지 삭제 | ||
void deleteByMember(Member member); | ||
|
||
// Pet에 연결된 이미지 삭제 | ||
void deleteByPet(Pet pet); | ||
|
||
// Review에 연결된 이미지 삭제 | ||
void deleteByReview(Review review); | ||
} |
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
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,18 @@ | ||
package com.mallangs.web; | ||
|
||
import com.mallangs.global.exception.ErrorResponse; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class HomeController { | ||
@GetMapping("/") | ||
public ResponseEntity<ErrorResponse> home() { | ||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.body(ErrorResponse.from(HttpStatus.UNAUTHORIZED, "인증되지 않은 요청입니다.")); | ||
} | ||
} |