Skip to content

Commit a8877b8

Browse files
Merge pull request #208 from mju-likelion/feature/booth-get-is-event-#207
Feature/#207 부스 전체/상세 조회 시 이벤트 부스 여부 반환하도록 변경
2 parents a1e7ee0 + 6069540 commit a8877b8

File tree

8 files changed

+22
-62
lines changed

8 files changed

+22
-62
lines changed

src/main/java/org/mju_likelion/festival/booth/domain/BoothDetail.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class BoothDetail {
1717
private final String department;
1818
private final String location;
1919
private final String locationImageUrl;
20+
private final Boolean isEventBooth;
2021
private final LocalDateTime createdAt;
2122

2223
public BoothDetail(
@@ -27,6 +28,7 @@ public BoothDetail(
2728
final String location,
2829
final String imageUrl,
2930
final String locationImageUrl,
31+
final Boolean isEventBooth,
3032
final LocalDateTime createdAt) {
3133

3234
this.id = id;
@@ -36,6 +38,7 @@ public BoothDetail(
3638
this.department = department;
3739
this.location = location;
3840
this.locationImageUrl = locationImageUrl;
41+
this.isEventBooth = isEventBooth;
3942
this.createdAt = createdAt;
4043
}
4144

@@ -49,6 +52,7 @@ public String toString() {
4952
", location='" + location + '\'' +
5053
", imageUrl='" + imageUrl + '\'' +
5154
", locationImageUrl='" + locationImageUrl + '\'' +
55+
", isEventBooth=" + isEventBooth + '\'' +
5256
", createdAt=" + createdAt +
5357
'}';
5458
}

src/main/java/org/mju_likelion/festival/booth/domain/SimpleBooth.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class SimpleBooth {
1515
private final String departmentName;
1616
private final String name;
1717
private final String imageUrl;
18+
private final Boolean isEventBooth;
1819

1920
@Override
2021
public String toString() {
@@ -23,6 +24,7 @@ public String toString() {
2324
", departmentName='" + departmentName + '\'' +
2425
", name='" + name + '\'' +
2526
", imageUrl='" + imageUrl + '\'' +
27+
", isEventBooth=" + isEventBooth +
2628
'}';
2729
}
2830
}

src/main/java/org/mju_likelion/festival/booth/domain/repository/BoothQueryRepository.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ private RowMapper<SimpleBooth> simpleBoothRowMapper() {
3636
uuid,
3737
rs.getString("departmentName"),
3838
rs.getString("boothName"),
39-
rs.getString("imageUrl")
39+
rs.getString("imageUrl"),
40+
rs.getBoolean("isEventBooth")
4041
);
4142
};
4243
}
@@ -53,6 +54,7 @@ private RowMapper<BoothDetail> boothDetailRowMapper() {
5354
rs.getString("boothLocation"),
5455
rs.getString("imageUrl"),
5556
rs.getString("locationImageUrl"),
57+
rs.getBoolean("isEventBooth"),
5658
rs.getTimestamp("createdAt").toLocalDateTime()
5759
);
5860
};
@@ -72,7 +74,7 @@ public List<SimpleBooth> findAllSimpleBoothByAffiliationId(final UUID affiliatio
7274

7375
String sql =
7476
"SELECT HEX(b.id) AS boothId, bd.name AS departmentName, b.name AS boothName, "
75-
+ "i.url AS imageUrl "
77+
+ "i.url AS imageUrl, b.is_event_booth AS isEventBooth "
7678
+ "FROM booth b "
7779
+ "INNER JOIN image i ON b.image_id = i.id "
7880
+ "INNER JOIN booth_department bd ON b.department_id = bd.id "
@@ -106,25 +108,6 @@ public boolean isBoothOwner(final UUID boothId, final UUID adminId) {
106108
return jdbcTemplate.queryForObject(sql, params, Integer.class) > 0;
107109
}
108110

109-
/**
110-
* 이벤트 부스인지 확인.
111-
*
112-
* @param boothId 부스 ID
113-
* @return 이벤트 부스 여부
114-
*/
115-
public boolean isEventBooth(final UUID boothId) {
116-
String sql =
117-
"SELECT EXISTS("
118-
+ "SELECT 1 FROM booth b "
119-
+ "WHERE b.id = UNHEX(:boothId) AND b.is_event_booth = TRUE"
120-
+ ") AS isEventBooth";
121-
122-
MapSqlParameterSource params = new MapSqlParameterSource()
123-
.addValue("boothId", uuidToHex(boothId));
124-
125-
return jdbcTemplate.queryForObject(sql, params, Integer.class) > 0;
126-
}
127-
128111
/**
129112
* 부스 상세 정보 조회.
130113
*
@@ -135,7 +118,7 @@ public Optional<BoothDetail> findBoothById(final UUID id) {
135118
String sql =
136119
"SELECT HEX(b.id) AS boothId, b.name AS boothName, b.description AS boothDescription, "
137120
+ "bd.name AS department, b.location AS boothLocation, i.url AS imageUrl, li.url AS locationImageUrl, "
138-
+ "b.created_at AS createdAt "
121+
+ "b.is_event_booth AS isEventBooth, b.created_at AS createdAt "
139122
+ "FROM booth b "
140123
+ "INNER JOIN image i ON b.image_id = i.id "
141124
+ "INNER JOIN image li ON b.location_image_id = li.id "

src/main/java/org/mju_likelion/festival/booth/dto/response/BoothDetailResponse.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class BoothDetailResponse {
2828
private String location;
2929
private String imageUrl;
3030
private String locationImageUrl;
31+
private Boolean isEventBooth;
3132
@JsonSerialize(using = LocalDateTimeSerializer.class)
3233
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
3334
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
@@ -36,7 +37,8 @@ public class BoothDetailResponse {
3637
public static BoothDetailResponse from(final BoothDetail boothDetail) {
3738
return new BoothDetailResponse(boothDetail.getId(), boothDetail.getName(),
3839
boothDetail.getDescription(), boothDetail.getDepartment(), boothDetail.getLocation(),
39-
boothDetail.getImageUrl(), boothDetail.getLocationImageUrl(), boothDetail.getCreatedAt());
40+
boothDetail.getImageUrl(), boothDetail.getLocationImageUrl(),
41+
boothDetail.getIsEventBooth(), boothDetail.getCreatedAt());
4042
}
4143

4244
@Override
@@ -49,6 +51,7 @@ public String toString() {
4951
", location='" + location + '\'' +
5052
", imageUrl='" + imageUrl + '\'' +
5153
", locationImageUrl='" + locationImageUrl + '\'' +
54+
", isEventBooth=" + isEventBooth + '\'' +
5255
", createdAt=" + createdAt +
5356
'}';
5457
}

src/main/java/org/mju_likelion/festival/booth/dto/response/BoothManagingDetailResponse.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414
public class BoothManagingDetailResponse {
1515

1616
private Boolean isOwner;
17-
private Boolean isEventBooth;
1817

19-
public static BoothManagingDetailResponse of(final boolean isOwner, final boolean isEventBooth) {
20-
return new BoothManagingDetailResponse(isOwner, isEventBooth);
18+
public static BoothManagingDetailResponse of(final boolean isOwner) {
19+
return new BoothManagingDetailResponse(isOwner);
2120
}
2221

2322
@Override
2423
public String toString() {
2524
return "BoothOwnershipResponse{" +
2625
"isOwner=" + isOwner +
27-
", isEventBooth=" + isEventBooth +
2826
'}';
2927
}
3028
}

src/main/java/org/mju_likelion/festival/booth/dto/response/SimpleBoothResponse.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public class SimpleBoothResponse {
1919
private String departmentName;
2020
private String name;
2121
private String imageUrl;
22+
private Boolean isEventBooth;
2223

2324
public static SimpleBoothResponse from(final SimpleBooth simpleBooths) {
2425

2526
return new SimpleBoothResponse(
2627
simpleBooths.getId(),
2728
simpleBooths.getDepartmentName(),
2829
simpleBooths.getName(),
29-
simpleBooths.getImageUrl()
30+
simpleBooths.getImageUrl(),
31+
simpleBooths.getIsEventBooth()
3032
);
3133
}
3234

@@ -37,6 +39,7 @@ public String toString() {
3739
", departmentName='" + departmentName + '\'' +
3840
", name='" + name + '\'' +
3941
", imageUrl='" + imageUrl + '\'' +
42+
", isEventBooth=" + isEventBooth +
4043
'}';
4144
}
4245
}

src/main/java/org/mju_likelion/festival/booth/service/BoothQueryService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ public BoothManagingDetailResponse getBoothManagingDetail(final UUID boothId,
7373
validateBoothExistence(boothId);
7474
adminQueryService.validateAdminExistence(boothAdminId);
7575
boolean isBoothOwner = boothQueryRepository.isBoothOwner(boothId, boothAdminId);
76-
boolean isEventBooth = boothQueryRepository.isEventBooth(boothId);
7776

78-
return BoothManagingDetailResponse.of(isBoothOwner, isEventBooth);
77+
return BoothManagingDetailResponse.of(isBoothOwner);
7978
}
8079

8180
public BoothQrResponse getBoothQr(final UUID boothId, final UUID boothAdminId) {

src/test/java/org/mju_likelion/festival/booth/service/BoothQueryServiceTest.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,6 @@ public void testIsNotBoothOwner() {
100100
assertThat(isOwner).isFalse();
101101
}
102102

103-
@DisplayName("이벤트 부스 여부를 확인한다 - 이벤트 부스")
104-
@Test
105-
public void testIsEventBooth() {
106-
// given
107-
Booth booth = boothJpaRepository.findAllByIsEventBooth(true).get(0);
108-
Admin admin = booth.getOwner();
109-
110-
// when
111-
boolean isEventBooth = boothQueryService.getBoothManagingDetail(booth.getId(),
112-
admin.getId())
113-
.getIsEventBooth();
114-
115-
// then
116-
assertThat(isEventBooth).isTrue();
117-
}
118-
119-
@DisplayName("이벤트 부스 여부를 확인한다 - 일반 부스")
120-
@Test
121-
public void testIsNotEventBooth() {
122-
// given
123-
Booth booth = boothJpaRepository.findAllByIsEventBooth(false).get(0);
124-
Admin admin = booth.getOwner();
125-
126-
// when
127-
boolean isEventBooth = boothQueryService.getBoothManagingDetail(booth.getId(),
128-
admin.getId())
129-
.getIsEventBooth();
130-
131-
// then
132-
assertThat(isEventBooth).isFalse();
133-
}
134-
135103
@DisplayName("RedisBoothQrManager 를 사용하여 부스 QR 코드를 생성한다.")
136104
@Test
137105
public void testCreateBoothQrRedisBoothQrManager() {

0 commit comments

Comments
 (0)