-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] put data in deletedMenu Repository
- Loading branch information
Showing
4 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/org/hankki/hankkiserver/api/menu/service/DeletedMenuUpdater.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,17 @@ | ||
package org.hankki.hankkiserver.api.menu.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.hankki.hankkiserver.domain.menu.model.DeletedMenu; | ||
import org.hankki.hankkiserver.domain.menu.repository.DeletedMenuRepository; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class DeletedMenuUpdater { | ||
|
||
private final DeletedMenuRepository deletedMenuRepository; | ||
|
||
public void save(final DeletedMenu deletedMenu) { | ||
deletedMenuRepository.save(deletedMenu); | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
src/main/java/org/hankki/hankkiserver/domain/menu/model/DeletedMenu.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,49 @@ | ||
package org.hankki.hankkiserver.domain.menu.model; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hankki.hankkiserver.domain.common.BaseCreatedAtEntity; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "deleted_menu") | ||
public class DeletedMenu extends BaseCreatedAtEntity { | ||
|
||
@Id | ||
@Column(name = "deleted_menu_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "name", nullable = false) | ||
private String name; | ||
|
||
@Column(name = "price", nullable = false) | ||
private int price; | ||
|
||
@Column(name = "store_id", nullable = false) | ||
private Long storeId; | ||
|
||
@Builder | ||
private DeletedMenu(final String name, final int price, final Long storeId) { | ||
this.name = name; | ||
this.price = price; | ||
this.storeId = storeId; | ||
} | ||
|
||
public static DeletedMenu create(final String name, final int price, final Long storeId) { | ||
return DeletedMenu.builder() | ||
.name(name) | ||
.price(price) | ||
.storeId(storeId) | ||
.build(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/hankki/hankkiserver/domain/menu/repository/DeletedMenuRepository.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,7 @@ | ||
package org.hankki.hankkiserver.domain.menu.repository; | ||
|
||
import org.hankki.hankkiserver.domain.menu.model.DeletedMenu; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface DeletedMenuRepository extends JpaRepository<DeletedMenu, Long> { | ||
} |