diff --git a/src/main/java/com/server/bbo_gak/domain/card/entity/CardCopyInfo.java b/src/main/java/com/server/bbo_gak/domain/card/entity/CardCopyInfo.java index 4d7af8f..d08b72e 100644 --- a/src/main/java/com/server/bbo_gak/domain/card/entity/CardCopyInfo.java +++ b/src/main/java/com/server/bbo_gak/domain/card/entity/CardCopyInfo.java @@ -13,9 +13,13 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE card_copy_info SET deleted = true WHERE card_copy_info_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class CardCopyInfo extends BaseEntity { diff --git a/src/main/java/com/server/bbo_gak/domain/card/entity/CardImage.java b/src/main/java/com/server/bbo_gak/domain/card/entity/CardImage.java index 1eb6f3a..c15a4b2 100644 --- a/src/main/java/com/server/bbo_gak/domain/card/entity/CardImage.java +++ b/src/main/java/com/server/bbo_gak/domain/card/entity/CardImage.java @@ -1,5 +1,6 @@ package com.server.bbo_gak.domain.card.entity; +import com.server.bbo_gak.global.common.BaseEntity; import com.server.bbo_gak.global.constant.FileExtension; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -15,11 +16,15 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE card_image SET deleted = true WHERE card_image_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class CardImage { +public class CardImage extends BaseEntity { private final String TYPE = "card_content"; @Id diff --git a/src/main/java/com/server/bbo_gak/domain/card/entity/CardMemo.java b/src/main/java/com/server/bbo_gak/domain/card/entity/CardMemo.java index 895a263..4657921 100644 --- a/src/main/java/com/server/bbo_gak/domain/card/entity/CardMemo.java +++ b/src/main/java/com/server/bbo_gak/domain/card/entity/CardMemo.java @@ -12,9 +12,13 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE card_memo SET deleted = true WHERE card_memo_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class CardMemo extends BaseEntity { diff --git a/src/main/java/com/server/bbo_gak/domain/card/entity/CardTag.java b/src/main/java/com/server/bbo_gak/domain/card/entity/CardTag.java index e7112ab..bdb8041 100644 --- a/src/main/java/com/server/bbo_gak/domain/card/entity/CardTag.java +++ b/src/main/java/com/server/bbo_gak/domain/card/entity/CardTag.java @@ -12,9 +12,13 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE card_tag SET deleted = true WHERE card_tag_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class CardTag extends BaseEntity { diff --git a/src/main/java/com/server/bbo_gak/domain/card/entity/CardType.java b/src/main/java/com/server/bbo_gak/domain/card/entity/CardType.java index 8fd7bfb..9503672 100644 --- a/src/main/java/com/server/bbo_gak/domain/card/entity/CardType.java +++ b/src/main/java/com/server/bbo_gak/domain/card/entity/CardType.java @@ -14,9 +14,13 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE card_type SET deleted = true WHERE card_type_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class CardType extends BaseEntity { diff --git a/src/main/java/com/server/bbo_gak/domain/card/entity/Tag.java b/src/main/java/com/server/bbo_gak/domain/card/entity/Tag.java index 97e4917..4c2046e 100644 --- a/src/main/java/com/server/bbo_gak/domain/card/entity/Tag.java +++ b/src/main/java/com/server/bbo_gak/domain/card/entity/Tag.java @@ -1,5 +1,6 @@ package com.server.bbo_gak.domain.card.entity; +import com.server.bbo_gak.global.common.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -10,11 +11,15 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE tag SET deleted = true WHERE tag_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Tag { +public class Tag extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/server/bbo_gak/domain/notification/entity/Notification.java b/src/main/java/com/server/bbo_gak/domain/notification/entity/Notification.java index 9cfaf72..7c8cc0e 100644 --- a/src/main/java/com/server/bbo_gak/domain/notification/entity/Notification.java +++ b/src/main/java/com/server/bbo_gak/domain/notification/entity/Notification.java @@ -18,9 +18,13 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE notification SET deleted = true WHERE notification_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Notification extends BaseEntity { diff --git a/src/main/java/com/server/bbo_gak/domain/recruit/entity/RecruitSchedule.java b/src/main/java/com/server/bbo_gak/domain/recruit/entity/RecruitSchedule.java index e88c96c..f0f3b2d 100644 --- a/src/main/java/com/server/bbo_gak/domain/recruit/entity/RecruitSchedule.java +++ b/src/main/java/com/server/bbo_gak/domain/recruit/entity/RecruitSchedule.java @@ -1,5 +1,6 @@ package com.server.bbo_gak.domain.recruit.entity; +import com.server.bbo_gak.global.common.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -15,11 +16,15 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE recruit_schedule SET deleted = true WHERE recruit_schedule_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class RecruitSchedule { +public class RecruitSchedule extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/server/bbo_gak/domain/recruit/entity/Season.java b/src/main/java/com/server/bbo_gak/domain/recruit/entity/Season.java index 67b5f59..616a082 100644 --- a/src/main/java/com/server/bbo_gak/domain/recruit/entity/Season.java +++ b/src/main/java/com/server/bbo_gak/domain/recruit/entity/Season.java @@ -1,6 +1,7 @@ package com.server.bbo_gak.domain.recruit.entity; import com.server.bbo_gak.domain.user.entity.User; +import com.server.bbo_gak.global.common.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -13,12 +14,16 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity @Table(name = "recruit_season") +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE recruit_season SET deleted = true WHERE recruit_season_id = ?") @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Season { +public class Season extends BaseEntity { String name; @Id diff --git a/src/main/java/com/server/bbo_gak/domain/user/entity/User.java b/src/main/java/com/server/bbo_gak/domain/user/entity/User.java index a9ab7f4..7f50ab4 100644 --- a/src/main/java/com/server/bbo_gak/domain/user/entity/User.java +++ b/src/main/java/com/server/bbo_gak/domain/user/entity/User.java @@ -1,16 +1,28 @@ package com.server.bbo_gak.domain.user.entity; import com.server.bbo_gak.global.common.BaseEntity; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Getter @Entity @SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@SQLRestriction("deleted = false") +@SQLDelete(sql = "UPDATE users SET deleted = true WHERE user_id = ?") @Table(name = "users") public class User extends BaseEntity { @@ -28,8 +40,8 @@ public class User extends BaseEntity { // User 생성 팩토리 메서드 public static User from(OauthInfo oauthInfo) { return User.builder() - .role(UserRole.USER) - .oauthInfo(oauthInfo) - .build(); + .role(UserRole.USER) + .oauthInfo(oauthInfo) + .build(); } } diff --git a/src/test/resources/card-test-data.sql b/src/test/resources/card-test-data.sql index ceebc64..1a1cd1a 100644 --- a/src/test/resources/card-test-data.sql +++ b/src/test/resources/card-test-data.sql @@ -31,12 +31,12 @@ INSERT INTO card (deleted, copy_flag, access_time, card_id, created_at, update_a VALUES (false, true, '2024-07-24 21:22:04.000000', 6, '2024-07-24 21:22:07.000000', '2024-07-24 21:22:08.000000', 1, 'test_contents', 'test_title', 1); -INSERT INTO tag (tag_id, name, tag_type) -VALUES (1, '스프링', 'CAPABILITY'); -INSERT INTO tag (tag_id, name, tag_type) -VALUES (2, '리액트', 'CAPABILITY'); -INSERT INTO tag (tag_id, name, tag_type) -VALUES (3, '봉사활동', 'PERSONALITY'); +INSERT INTO tag (tag_id, name, tag_type, deleted, update_at, created_at) +VALUES (1, '스프링', 'CAPABILITY', false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'); +INSERT INTO tag (tag_id, name, tag_type, deleted, update_at, created_at) +VALUES (2, '리액트', 'CAPABILITY', false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'); +INSERT INTO tag (tag_id, name, tag_type, deleted, update_at, created_at) +VALUES (3, '봉사활동', 'PERSONALITY', false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'); INSERT INTO card_type (card_type_id, card_type_value, card_id, deleted, update_at, created_at) VALUES (1, 'EXPERIENCE', 1, false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'); diff --git a/src/test/resources/notification-test-data.sql b/src/test/resources/notification-test-data.sql index 712e37a..3f50a07 100644 --- a/src/test/resources/notification-test-data.sql +++ b/src/test/resources/notification-test-data.sql @@ -4,10 +4,10 @@ VALUES (false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000', 1, 'A 'USER'); -- 다음으로 recruit_season 테이블에 데이터를 삽입합니다. -INSERT INTO recruit_season (recruit_season_id, name, user_id) -VALUES (1, '2024 상반기', 1); -INSERT INTO recruit_season (recruit_season_id, name, user_id) -VALUES (2, '2024 하반기', 1); +INSERT INTO recruit_season (recruit_season_id, name, user_id, deleted, update_at, created_at) +VALUES (1, '2024 상반기', 1, false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'); +INSERT INTO recruit_season (recruit_season_id, name, user_id, deleted, update_at, created_at) +VALUES (2, '2024 하반기', 1, false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'); INSERT INTO recruit (recruit_id, title, site_url, recruit_status, recruit_season_id, user_id, created_at, update_at, deleted) @@ -17,6 +17,9 @@ VALUES (1, 'Title for one day left', 'http://example.com/1', 'DOCUMENT_PASSED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, false); -- RecruitSchedule 테이블에 데이터 삽입 -INSERT INTO recruit_schedule (recruit_schedule_id, recruit_id, recruit_schedule_stage, dead_line) -VALUES (1, 1, 'FIRST_INTERVIEW', CURRENT_DATE + 1), -- 하루 남은 스케줄 - (2, 2, 'CLOSING_DOCUMENT', CURRENT_DATE + 2); -- 하루 이상 남은 스케줄 \ No newline at end of file +INSERT INTO recruit_schedule (recruit_schedule_id, recruit_id, recruit_schedule_stage, dead_line, deleted, created_at, + update_at) +VALUES (1, 1, 'FIRST_INTERVIEW', CURRENT_DATE + 1, false, '2024-07-24 21:27:20.000000', + '2024-07-24 21:27:21.000000'), -- 하루 남은 스케줄 + (2, 2, 'CLOSING_DOCUMENT', CURRENT_DATE + 2, false, '2024-07-24 21:27:20.000000', + '2024-07-24 21:27:21.000000'); -- 하루 이상 남은 스케줄 \ No newline at end of file diff --git a/src/test/resources/recruit-test-data.sql b/src/test/resources/recruit-test-data.sql index cf59d92..8f4176b 100644 --- a/src/test/resources/recruit-test-data.sql +++ b/src/test/resources/recruit-test-data.sql @@ -8,13 +8,13 @@ VALUES (false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000', 1, 'A ; -- Season 테이블에 데이터 삽입 -INSERT INTO recruit_season (recruit_season_id, name, user_id) -VALUES (1, '2024 상반기', 1), - (2, '2024 하반기', 1), - (3, '2024 상반기', 2), - (4, '2024 하반기', 2), - (5, '2024 상반기', 3), - (6, '2024 하반기', 3) +INSERT INTO recruit_season (recruit_season_id, name, user_id, deleted, update_at, created_at) +VALUES (1, '2024 상반기', 1, false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000'), + (2, '2024 하반기', 1, false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000'), + (3, '2024 상반기', 2, false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000'), + (4, '2024 하반기', 2, false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000'), + (5, '2024 상반기', 3, false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000'), + (6, '2024 하반기', 3, false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000') ; -- Recruit 테이블에 데이터 삽입 @@ -37,15 +37,15 @@ VALUES (1, 'Title for one day left', 'http://example.com/1', 'DOCUMENT_PASSED', ; -- RecruitSchedule 테이블에 데이터 삽입 -INSERT INTO recruit_schedule (recruit_schedule_id, recruit_id, recruit_schedule_stage, dead_line) -VALUES (1, 1, 'FIRST_INTERVIEW', '2024-12-31'), - (2, 4, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 3, CURRENT_TIMESTAMP)), - (3, 5, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 1, CURRENT_TIMESTAMP)), - (4, 6, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 2, CURRENT_TIMESTAMP)), - (5, 6, 'SECOND_INTERVIEW', TIMESTAMPADD(DAY, 3, CURRENT_TIMESTAMP)), - (6, 7, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP)), - (7, 7, 'SECOND_INTERVIEW', TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP)), - (8, 7, 'FINAL_INTERVIEW', TIMESTAMPADD(DAY, 1, CURRENT_TIMESTAMP)) +INSERT INTO recruit_schedule (recruit_schedule_id, recruit_id, recruit_schedule_stage, dead_line, deleted, update_at, created_at) +VALUES (1, 1, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 3, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (2, 4, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 3, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (3, 5, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 1, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (4, 6, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, 2, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (5, 6, 'SECOND_INTERVIEW', TIMESTAMPADD(DAY, 3, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (6, 7, 'FIRST_INTERVIEW', TIMESTAMPADD(DAY, -2, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (7, 7, 'SECOND_INTERVIEW', TIMESTAMPADD(DAY, -1, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (8, 7, 'FINAL_INTERVIEW', TIMESTAMPADD(DAY, 1, CURRENT_TIMESTAMP), false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000') ; INSERT INTO card (deleted, copy_flag, access_time, card_id, created_at, update_at, user_id, content, title, recruit_id) diff --git a/src/test/resources/season-test-data.sql b/src/test/resources/season-test-data.sql index db5cf8c..4c99857 100644 --- a/src/test/resources/season-test-data.sql +++ b/src/test/resources/season-test-data.sql @@ -4,10 +4,10 @@ VALUES (false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000', 1, 'A (false, '2024-07-24 21:27:20.000000', '2024-07-24 21:27:21.000000', 2, 'AuthTestUser', 'email', 'test', 'test', 'test123', 'USER'); -INSERT INTO recruit_season (recruit_season_id, name, user_id) -VALUES (1, '2024 상반기', 2), - (2, '2024 하반기', 2), - (3, '2025 상반기', 2); +INSERT INTO recruit_season (recruit_season_id, name, user_id, deleted, update_at, created_at) +VALUES (1, '2024 상반기', 2, false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (2, '2024 하반기', 2, false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000'), + (3, '2025 상반기', 2, false, '2024-07-24 21:26:28.000000', '2024-07-24 21:26:28.000000');