-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
1,081 additions
and
603 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
modules/domain/src/main/java/com/whoz_in/domain/device/DeviceRepository.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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package com.whoz_in.domain.device; | ||
|
||
import com.whoz_in.domain.device.model.Device; | ||
import java.util.Optional; | ||
|
||
public interface DeviceRepository { | ||
void save(Device device); | ||
|
||
//해당 mac을 포함하는 device를 찾는 메서드 | ||
Optional<Device> findByMac(String mac); | ||
} |
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
20 changes: 20 additions & 0 deletions
20
modules/domain/src/main/java/com/whoz_in/domain/device/service/DeviceOwnershipService.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,20 @@ | ||
package com.whoz_in.domain.device.service; | ||
|
||
import com.whoz_in.domain.device.model.Device; | ||
import com.whoz_in.domain.member.MemberRepository; | ||
import com.whoz_in.domain.member.model.Member; | ||
import com.whoz_in.domain.member.model.MemberId; | ||
import com.whoz_in.domain.shared.DomainService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class DeviceOwnershipService { | ||
private final MemberRepository memberRepository; | ||
|
||
public void validateOwnership(Device device, MemberId memberId){ | ||
if (device.isOwnedBy(memberId)) return; | ||
Member deviceOwner = memberRepository.getByMemberId(device.getMemberId()); | ||
throw new IllegalArgumentException("이 기기는 " + deviceOwner.getName() + " 회원의 기기입니다."); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
modules/domain/src/main/java/com/whoz_in/domain/member/service/MemberFinderService.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 com.whoz_in.domain.member.service; | ||
|
||
import com.whoz_in.domain.member.MemberRepository; | ||
import com.whoz_in.domain.member.exception.NoMemberException; | ||
import com.whoz_in.domain.member.model.MemberId; | ||
import com.whoz_in.domain.shared.DomainService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class MemberFinderService { | ||
private final MemberRepository memberRepository; | ||
public void mustExist(MemberId memberId) { | ||
if (!memberRepository.existsByMemberId(memberId)) | ||
throw new NoMemberException(); | ||
} | ||
} |
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
6 changes: 5 additions & 1 deletion
6
modules/domain/src/main/java/com/whoz_in/domain/network_log/ManagedLogRepository.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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package com.whoz_in.domain.network_log; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Collection; | ||
import java.util.Optional; | ||
|
||
public interface ManagedLogRepository { | ||
void save(ManagedLog log); | ||
void saveAll(Collection<ManagedLog> logs); | ||
Optional<ManagedLog> findLatestByIp(String ip); | ||
Optional<ManagedLog> findLatestByRoomAndIpAfter(String room, String ip, LocalDateTime time); | ||
default ManagedLog getLatestByRoomAndIpAfter(String room, String ip, LocalDateTime time){ | ||
return findLatestByRoomAndIpAfter(room, ip, time).orElseThrow(() -> new IllegalArgumentException("로그가 없습니다")); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
modules/domain/src/main/java/com/whoz_in/domain/network_log/MonitorLogRepository.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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
package com.whoz_in.domain.network_log; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Collection; | ||
|
||
public interface MonitorLogRepository { | ||
void save(MonitorLog log); | ||
void saveAll(Collection<MonitorLog> logs); | ||
boolean existsAfter(String mac, LocalDateTime time); | ||
default void mustExistAfter(String mac, LocalDateTime time){ | ||
if (!existsAfter(mac, time)) | ||
throw new IllegalArgumentException("monitor log가 없습니다"); | ||
} | ||
} |
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
6 changes: 5 additions & 1 deletion
6
...ucture/domain-jpa/src/main/java/com/whoz_in/domain_jpa/device/DeviceEntityRepository.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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
package com.whoz_in.domain_jpa.device; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface DeviceEntityRepository extends JpaRepository<DeviceEntity, Long> { | ||
|
||
@Query("SELECT d FROM DeviceEntity d JOIN d.deviceInfoEntity di WHERE di.mac = :mac") | ||
Optional<DeviceEntity> findByMac(@Param("mac") String mac); | ||
} |
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
2 changes: 2 additions & 0 deletions
2
...e/domain-jpa/src/main/java/com/whoz_in/domain_jpa/monitor/MonitorLogEntityRepository.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.whoz_in.domain_jpa.monitor; | ||
|
||
import java.time.LocalDateTime; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MonitorLogEntityRepository extends JpaRepository<MonitorLogEntity, String> { | ||
boolean existsByMacAndUpdatedAtAfter(String mac, LocalDateTime time); | ||
} |
Oops, something went wrong.