Skip to content

Commit

Permalink
Merge pull request #58 from SWM-M3PRO/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
koomin1227 authored Aug 5, 2024
2 parents 92ad16b + ccc8748 commit dff7d1c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
echo "SPRING_PROFILES_ACTIVE=prod" >> .env
echo "X-NCP-APIGW-API-KEY-ID=${{ secrets.NAVER_APIKEYID }}" >> .env
echo "X-NCP-APIGW-API-KEY=${{ secrets.NAVER_APIKEY }}" >> .env
echo "JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }}" >> .env
echo "JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY_PROD }}" >> .env
echo "KAKAO_APP_ID=${{ secrets.KAKAO_APP_ID }}" >> .env
echo "REDIS_HOST=${{ secrets.REDIS_HOST_PROD }}" >> .env
echo "AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY_PROD }}" >> .env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public class BaseTimeEntity {
@LastModifiedDate
private LocalDateTime modifiedAt;

public void updateModifiedAt() {
modifiedAt = LocalDateTime.now();
}
}
12 changes: 10 additions & 2 deletions src/main/java/com/m3pro/groundflip/service/PixelService.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,21 @@ private void occupyPixel(PixelOccupyRequest pixelOccupyRequest) {
Pixel targetPixel = pixelRepository.findByXAndY(pixelOccupyRequest.getX(), pixelOccupyRequest.getY())
.orElseThrow(() -> new AppException(ErrorCode.PIXEL_NOT_FOUND));
updateRankingOnCache(targetPixel, occupyingUserId);
targetPixel.updateUserId(occupyingUserId);
pixelRepository.saveAndFlush(targetPixel);
updatePixelOwner(targetPixel, occupyingUserId);

updatePixelAddress(targetPixel);
eventPublisher.publishEvent(new PixelUserInsertEvent(targetPixel.getId(), occupyingUserId, communityId));
}

private void updatePixelOwner(Pixel targetPixel, Long occupyingUserId) {
if (Objects.equals(targetPixel.getUserId(), occupyingUserId)) {
targetPixel.updateModifiedAt();
} else {
targetPixel.updateUserId(occupyingUserId);
}
pixelRepository.saveAndFlush(targetPixel);
}

/**
* 픽셀의 주소를 업데이트한다..
* @param targetPixel 주소를 얻기 위한 픽셀
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@
<appender-ref ref="ROLLING_FILE"/>
</root>
</springProfile>

<springProfile name="prod">
<root level="INFO">
<appender-ref ref="ROLLING_FILE"/>
</root>
</springProfile>
</configuration>

0 comments on commit dff7d1c

Please sign in to comment.