Skip to content

Commit

Permalink
hotfix: 캠퍼스명 에러:
Browse files Browse the repository at this point in the history
  • Loading branch information
jcw1031 committed Feb 21, 2024
1 parent 41c34dd commit 6e47e56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package ac.knu.likeknu.controller.dto.device.request;

import ac.knu.likeknu.domain.value.Campus;

public record DeviceRegistrationRequest(String deviceId, String userAgent, Campus campus) {
public record DeviceRegistrationRequest(String deviceId, String userAgent, String campus) {
}
9 changes: 9 additions & 0 deletions src/main/java/ac/knu/likeknu/domain/value/Campus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum Campus {

Expand All @@ -17,4 +19,11 @@ public enum Campus {
this.campus = campus;
this.dormitoryAnnouncementId = dormitoryAnnouncementId;
}

public static Campus of(String campusName) {
return Arrays.stream(values())
.filter(campus -> campus.getCampus().equals(campusName))
.findAny()
.orElseThrow();
}
}
3 changes: 2 additions & 1 deletion src/main/java/ac/knu/likeknu/service/DeviceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public void registerDeviceId(DeviceRegistrationRequest deviceRequest) {
.orElseGet(() -> Device.of(deviceRequest));

device.updatePlatform(deviceRequest.userAgent());
device.updateCampus(deviceRequest.campus());
String campus = deviceRequest.campus();
device.updateCampus(Campus.of(campus));
device.visitNow();
if (registeredDevices.add(deviceId)) {
deviceRepository.save(device);
Expand Down

0 comments on commit 6e47e56

Please sign in to comment.