-
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
140 changed files
with
2,443 additions
and
401 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Code Review | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
# Pull Request ? ?? ? ?? | ||
# Pull Request ? ??? ??? ???? ??? ? ? | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
code-review: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: anc95/ChatGPT-CodeReview@main | ||
env: | ||
GITHUB_TOKEN : ${{secrets.BELLMIN_GITHUB_TOKEN}} | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
LANGUAGE: Korean | ||
MODEL: gpt-3.5-turbo |
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,11 +1,15 @@ | ||
package com.whoz_in.domain.device; | ||
|
||
import com.whoz_in.domain.device.model.Device; | ||
import java.util.List; | ||
import com.whoz_in.domain.device.model.DeviceId; | ||
import java.util.Optional; | ||
|
||
public interface DeviceRepository { | ||
void save(Device device); | ||
List<Device> findAll(); | ||
|
||
//해당 mac을 포함하는 device를 찾는 메서드 | ||
Optional<Device> findByMac(String mac); | ||
Optional<Device> findByDeviceId(DeviceId deviceId); | ||
} |
7 changes: 7 additions & 0 deletions
7
modules/domain/src/main/java/com/whoz_in/domain/device/event/DeviceInfoRegistered.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 com.whoz_in.domain.device.event; | ||
|
||
import com.whoz_in.domain.shared.event.DomainEvent; | ||
|
||
public final class DeviceInfoRegistered extends DomainEvent { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...n/src/main/java/com/whoz_in/domain/device/exception/DeviceAlreadyRegisteredException.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,10 @@ | ||
package com.whoz_in.domain.device.exception; | ||
|
||
import com.whoz_in.domain.shared.BusinessException; | ||
|
||
public class DeviceAlreadyRegisteredException extends BusinessException { | ||
public static final DeviceAlreadyRegisteredException EXCEPTION = new DeviceAlreadyRegisteredException(); | ||
private DeviceAlreadyRegisteredException() { | ||
super("3030", "이미 등록된 기기입니다."); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...domain/src/main/java/com/whoz_in/domain/device/exception/InvalidDeviceOwnerException.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,13 @@ | ||
package com.whoz_in.domain.device.exception; | ||
|
||
import com.whoz_in.domain.shared.BusinessException; | ||
|
||
public class InvalidDeviceOwnerException extends BusinessException { | ||
private InvalidDeviceOwnerException(String errorMessage) { | ||
super("3020", errorMessage); | ||
} | ||
|
||
public static InvalidDeviceOwnerException of(String ownerName){ | ||
return new InvalidDeviceOwnerException(String.format("이 기기는 %s 회원의 기기입니다. 해당 회원에게 기기 삭제를 부탁하세요.", ownerName)); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
modules/domain/src/main/java/com/whoz_in/domain/device/exception/NoDeviceException.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,10 @@ | ||
package com.whoz_in.domain.device.exception; | ||
|
||
import com.whoz_in.domain.shared.BusinessException; | ||
|
||
public class NoDeviceException extends BusinessException { | ||
public static final NoDeviceException EXCEPTION = new NoDeviceException(); | ||
private NoDeviceException() { | ||
super("3001", "등록된 기기가 없습니다."); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
modules/domain/src/main/java/com/whoz_in/domain/device/service/DeviceFinderService.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,30 @@ | ||
package com.whoz_in.domain.device.service; | ||
|
||
import com.whoz_in.domain.device.DeviceRepository; | ||
import com.whoz_in.domain.device.exception.DeviceAlreadyRegisteredException; | ||
import com.whoz_in.domain.device.exception.NoDeviceException; | ||
import com.whoz_in.domain.device.model.Device; | ||
import com.whoz_in.domain.device.model.DeviceId; | ||
import com.whoz_in.domain.shared.DomainService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class DeviceFinderService { | ||
private final DeviceRepository deviceRepository; | ||
|
||
public Device find(DeviceId deviceId){ | ||
return deviceRepository.findByDeviceId(deviceId).orElseThrow(()-> NoDeviceException.EXCEPTION); | ||
} | ||
|
||
public void mustNotExist(DeviceId deviceId){ | ||
if (deviceRepository.findByDeviceId(deviceId).isPresent()) | ||
throw DeviceAlreadyRegisteredException.EXCEPTION; | ||
} | ||
|
||
public void mustNotExistByMac(String mac){ | ||
if (deviceRepository.findByMac(mac).isPresent()) | ||
throw DeviceAlreadyRegisteredException.EXCEPTION; | ||
} | ||
|
||
} |
12 changes: 7 additions & 5 deletions
12
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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package com.whoz_in.domain.device.service; | ||
|
||
import com.whoz_in.domain.device.exception.InvalidDeviceOwnerException; | ||
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.member.service.MemberFinderService; | ||
import com.whoz_in.domain.shared.DomainService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class DeviceOwnershipService { | ||
private final MemberRepository memberRepository; | ||
private final MemberFinderService memberFinderService; | ||
|
||
public void validateOwnership(Device device, MemberId memberId){ | ||
//기기가 자신의 것이 맞는지 확인합니다. | ||
public void validateIsMine(Device device, MemberId memberId){ | ||
if (device.isOwnedBy(memberId)) return; | ||
Member deviceOwner = memberRepository.getByMemberId(device.getMemberId()); | ||
throw new IllegalArgumentException("이 기기는 " + deviceOwner.getName() + " 회원의 기기입니다."); | ||
Member deviceOwner = memberFinderService.find(device.getMemberId()); | ||
throw InvalidDeviceOwnerException.of(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
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
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
Oops, something went wrong.