Skip to content

Commit

Permalink
Merge pull request #78 from depromeet/feature/#75
Browse files Browse the repository at this point in the history
[feat][#75] 모든 테이블 soft delete 추가 & 테스트 데이터 수정
  • Loading branch information
sejoon00 authored Aug 24, 2024
2 parents 90841e1 + 1059fa2 commit 947a5b2
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/server/bbo_gak/domain/card/entity/Tag.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/com/server/bbo_gak/domain/user/entity/User.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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();
}
}
12 changes: 6 additions & 6 deletions src/test/resources/card-test-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
17 changes: 10 additions & 7 deletions src/test/resources/notification-test-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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); -- 하루 이상 남은 스케줄
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'); -- 하루 이상 남은 스케줄
32 changes: 16 additions & 16 deletions src/test/resources/recruit-test-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 테이블에 데이터 삽입
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/test/resources/season-test-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');



Expand Down

0 comments on commit 947a5b2

Please sign in to comment.