-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
M3-117 개인전 픽셀 가져오는 API 구현 완료 #4
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
48596e4
M3-117 Feat : 개인전 픽셀 가져오는 api 구현 완료
qjvk2880 f4844c4
M3-117 Feat : getNearIndividualPixels()의 인자 일부를 선택 가능하게끔 설정
qjvk2880 631c653
M3-117 Style : 개행문자를 LF로 변경
qjvk2880 97c2456
M3-117 Rename : PR 템플릿 파일 이름 변경
qjvk2880 c077787
M3-117 Refactor : getNearIndividualPixels()에 /individual 구분자 추가
qjvk2880 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
32 changes: 31 additions & 1 deletion
32
src/main/java/com/m3pro/groundflip/controller/PixelController.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 +1,31 @@ | ||
package com.m3pro.groundflip.controller;import org.springframework.web.bind.annotation.RestController;import com.m3pro.groundflip.service.PixelService;import lombok.RequiredArgsConstructor;@RestController@RequiredArgsConstructorpublic class PixelController { private final PixelService pixelService;} | ||
package com.m3pro.groundflip.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.m3pro.groundflip.domain.dto.Response; | ||
import com.m3pro.groundflip.domain.dto.pixel.IndividualPixelResponse; | ||
import com.m3pro.groundflip.service.PixelService; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/pixels") | ||
public class PixelController { | ||
private final PixelService pixelService; | ||
|
||
@GetMapping("/individual") | ||
public Response<List<IndividualPixelResponse>> getNearIndividualPixels( | ||
@RequestParam(name = "current-x") int currentX, | ||
@RequestParam(name = "current-y") int currentY, | ||
@RequestParam(name = "x-range", required = false, defaultValue = "20") int xRange, | ||
@RequestParam(name = "y-range", required = false, defaultValue = "10") int yRange) { | ||
return Response.createSuccess(pixelService.getNearIndividualPixels(currentX, currentY, xRange, yRange)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/m3pro/groundflip/domain/dto/pixel/IndividualPixelResponse.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,21 @@ | ||
package com.m3pro.groundflip.domain.dto.pixel; | ||
|
||
import com.m3pro.groundflip.domain.entity.Pixel; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
public class IndividualPixelResponse { | ||
private double latitude; | ||
private double longitude; | ||
private double x; | ||
private double y; | ||
|
||
public static IndividualPixelResponse from(Pixel pixel) { | ||
return new IndividualPixelResponse(pixel.getLatitude(), pixel.getLongitude(), pixel.getX(), pixel.getY()); | ||
} | ||
} |
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
18 changes: 17 additions & 1 deletion
18
src/main/java/com/m3pro/groundflip/repository/PixelRepository.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 +1,17 @@ | ||
package com.m3pro.groundflip.repository;import org.springframework.data.jpa.repository.JpaRepository;import com.m3pro.groundflip.domain.entity.Pixel;public interface PixelRepository extends JpaRepository<Pixel, Long> {} | ||
package com.m3pro.groundflip.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import com.m3pro.groundflip.domain.entity.Pixel; | ||
|
||
public interface PixelRepository extends JpaRepository<Pixel, Long> { | ||
@Query(value = "select pixel from Pixel pixel " | ||
+ "where pixel.x between :currentX - :xRange / 2 and :currentX + :xRange / 2 " | ||
+ "and pixel.y between :currentY - :yRange / 2 and :currentY + :yRange / 2 ") | ||
List<Pixel> findAllNearPixels(@Param("currentX") int currentX, @Param("currentY") int currentY, | ||
@Param("xRange") int xRange, @Param("yRange") int yRange); | ||
} |
24 changes: 23 additions & 1 deletion
24
src/main/java/com/m3pro/groundflip/service/PixelService.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 +1,23 @@ | ||
package com.m3pro.groundflip.service;import org.springframework.stereotype.Service;import lombok.RequiredArgsConstructor;@Service@RequiredArgsConstructorpublic class PixelService {} | ||
package com.m3pro.groundflip.service; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.m3pro.groundflip.domain.dto.pixel.IndividualPixelResponse; | ||
import com.m3pro.groundflip.repository.PixelRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PixelService { | ||
private final PixelRepository pixelRepository; | ||
|
||
public List<IndividualPixelResponse> getNearIndividualPixels(int currentX, int currentY, int xRange, int yRange) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 개인 픽셀과 경쟁 픽셀을 조회 하는 구분이 필요할 것 같아요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생각하지 못했던 구분이였네요.. 추후 동적 쿼리나 컨트롤러 단에 구분자 추가 등으로 적용하겠습니다. |
||
return pixelRepository.findAllNearPixels(currentX, currentY, xRange, yRange) | ||
.stream() | ||
.map(IndividualPixelResponse::from) | ||
.toList(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
개인 픽셀이랑 경쟁 픽셀이랑 구분하기 위해 엔드포인트에 구분자가 필요할 것 같네요..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
적용 완료했습니다!