-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : 생협 운영시간 이름으로 조회 추가 * feat: coopName 추가 * chore : 여백 추가 * chore : 여백 추가 * chore : 테스트 코드 수정 * fix: 대즐 운영시간 표기 오류 수정
- Loading branch information
Showing
15 changed files
with
179 additions
and
52 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
37 changes: 37 additions & 0 deletions
37
src/main/java/in/koreatech/koin/domain/coopshop/model/CoopName.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,37 @@ | ||
package in.koreatech.koin.domain.coopshop.model; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
import in.koreatech.koin.global.domain.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "coop_names") | ||
@NoArgsConstructor(access = PROTECTED) | ||
public class CoopName { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Integer id; | ||
|
||
@NotNull | ||
@Column(name = "name", nullable = false) | ||
private String name; | ||
|
||
@Builder | ||
private CoopName( | ||
String name | ||
) { | ||
this.name = name; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/in/koreatech/koin/domain/coopshop/repository/CoopNameRepository.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,31 @@ | ||
package in.koreatech.koin.domain.coopshop.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.repository.Repository; | ||
|
||
import in.koreatech.koin.domain.coopshop.exception.CoopShopNotFoundException; | ||
import in.koreatech.koin.domain.coopshop.model.CoopName; | ||
import in.koreatech.koin.domain.coopshop.model.CoopShopType; | ||
|
||
public interface CoopNameRepository extends Repository<CoopName, Integer> { | ||
|
||
CoopName save(CoopName coopNames); | ||
|
||
List<CoopName> findAll(); | ||
|
||
Optional<CoopName> findById(Integer id); | ||
|
||
Optional<CoopName> findByName(String coopName); | ||
|
||
default CoopName getById(Integer id) { | ||
return findById(id) | ||
.orElseThrow(() -> CoopShopNotFoundException.withDetail("coopShopId : " + id)); | ||
} | ||
|
||
default CoopName getByName(CoopShopType coopShopType) { | ||
return findByName(coopShopType.getCoopShopName()) | ||
.orElseThrow(() -> CoopShopNotFoundException.withDetail("coopShopType : " + coopShopType)); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
src/main/resources/db/migration/V111__add_table_coop_names.sql
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 @@ | ||
CREATE TABLE `coop_names` | ||
( | ||
`id` INT UNSIGNED AUTO_INCREMENT NOT NULL comment '고유 id' primary key, | ||
`name` VARCHAR(255) NOT NULL comment '생협 운영장 이름' | ||
); | ||
|
||
INSERT INTO `coop_names` (`name`) | ||
VALUES ('학생식당'), | ||
('복지관식당'), | ||
('대즐'), | ||
('서점'), | ||
('세탁소'), | ||
('복사실'), | ||
('복지관 참빛관 편의점'), | ||
('미용실'), | ||
('오락실'), | ||
('우편취급국'), | ||
('안경원'); |
11 changes: 11 additions & 0 deletions
11
src/main/resources/db/migration/V112__delete_column_coop_shop_name.sql
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,11 @@ | ||
ALTER TABLE `coop_shop` | ||
ADD COLUMN `coop_name_id` INT UNSIGNED comment '생협 운영장 고유 id', | ||
ADD CONSTRAINT `coop_name_fk_id` FOREIGN KEY (`coop_name_id`) REFERENCES `coop_names` (`id`) ON DELETE CASCADE; | ||
|
||
UPDATE `coop_shop` AS cs | ||
JOIN `coop_names` AS cn | ||
ON cs.`name` = cn.`name` | ||
SET cs.`coop_name_id` = cn.`id`; | ||
|
||
ALTER TABLE `coop_shop` | ||
DROP COLUMN `name`; |
5 changes: 5 additions & 0 deletions
5
src/main/resources/db/migration/V113__atler_coop_opens_dazzle.sql
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 @@ | ||
UPDATE coop_opens AS co | ||
JOIN coop_shop AS cs ON co.coop_shop_id = cs.id | ||
JOIN coop_names AS cn ON cs.coop_name_id = cn.id | ||
SET co.day_of_week = 'WEEKDAYS' | ||
WHERE cn.name = '대즐' AND co.open_time = '08:30'; |
Oops, something went wrong.