Skip to content
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

65 교차로 마커 등록 #105

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0a8fde9
feat: crossroad 새로운 기능 추가
ByungilOh-Fillip Jan 3, 2025
efe8bf1
Update submodule
ByungilOh-Fillip Jan 3, 2025
c050cdc
feat: crossroad 새로운 기능 추가
ByungilOh-Fillip Jan 5, 2025
b7165f8
feat: crossroad 새로운 기능 추가
ByungilOh-Fillip Jan 5, 2025
aa29b1b
submodule commit
ByungilOh-Fillip Jan 5, 2025
484b82f
feat: 소셜로그인 기능 추가
zzuharchive Jan 2, 2025
590e592
feat: securityCofig에 outh2관련 설정 추가
zzuharchive Jan 2, 2025
1b39a98
fix: 소셜DB 중복 추가 오류 수정
zzuharchive Jan 3, 2025
dacbed6
fix: OAuth2UserService에서 저장한 객체 반환하도록 수정
zzuharchive Jan 4, 2025
80edc02
refactor: User 객체 변경 작업
Dongjin0224 Jan 4, 2025
1bdd640
refactor: Session 정보 이용으로 변경
Dongjin0224 Jan 4, 2025
73f2333
fix: import 오류 수정
Dongjin0224 Jan 4, 2025
f5381e4
fix: error code 수정
DongminL Jan 4, 2025
651e3fc
refactor: 경로명의 일관성 높임
DongminL Jan 4, 2025
bde2837
pref: 하나의 쿼리만으로 조회
DongminL Jan 4, 2025
5995120
refactor: 중복되는 코드 하나의 메서드로 축약
DongminL Jan 4, 2025
e45f623
fix: 소셜로그인 인가 버그 해결
zzuharchive Jan 4, 2025
a245107
feat: 관리자 메인페이지 프론트 작업
limseohyeon Jan 5, 2025
a2a8bbc
feat: 로그인-로그아웃-회워가입-프론트 구현
zzuharchive Jan 5, 2025
177c875
test: 회원가입 테스트 코드 수정
zzuharchive Jan 5, 2025
6cffb4d
feat: 관리자 회원 관리프론트 수정
limseohyeon Jan 5, 2025
09a12bc
refactor: 반환 조건 수정
limseohyeon Jan 5, 2025
16bd453
submodule commit
ByungilOh-Fillip Jan 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'

// oAuth2
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-authorization-server'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

// Session
implementation 'org.springframework.session:spring-session-data-redis'

Expand Down
Binary file added keystore.p12
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.programmers.signalbuddy.domain.admin.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.programmers.signalbuddy.domain.admin.dto.AdminMemberResponse;
import org.programmers.signalbuddy.domain.admin.dto.WithdrawalMemberResponse;
import org.programmers.signalbuddy.domain.admin.service.AdminService;
Expand All @@ -13,13 +14,19 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Slf4j
@Controller
@RequiredArgsConstructor
@RequestMapping("/admins")
public class AdminWebController {

private final AdminService adminService;

@GetMapping()
public ModelAndView adminsMain() {
return new ModelAndView("admin/main");
}

@GetMapping("members/list")
public ModelAndView getAllMembers(@PageableDefault(page = 0, size = 10, sort = "email") Pageable pageable, ModelAndView mv) {
Page<AdminMemberResponse> members = adminService.getAllMembers(pageable);
Expand All @@ -32,7 +39,7 @@ public ModelAndView getAllMembers(@PageableDefault(page = 0, size = 10, sort = "
public ModelAndView getMember(@PathVariable Long id, ModelAndView mv) {
final AdminMemberResponse member = adminService.getMember(id);
mv.setViewName("admin/detail");
mv.addObject("member", member);
mv.addObject("m", member);
return mv;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AdminService {
private BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();

public Page<AdminMemberResponse> getAllMembers(Pageable pageable) {
Page<Member> membersPage = memberRepository.findAll(pageable);
Page<Member> membersPage = memberRepository.findAllMembers(pageable);

Page<AdminMemberResponse> adminMemberResponses = membersPage.map(member -> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ public abstract class BaseTimeEntity {

@LastModifiedDate
private LocalDateTime updatedAt;

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.programmers.signalbuddy.domain.bookmark.dto.BookmarkRequest;
import org.programmers.signalbuddy.domain.bookmark.dto.BookmarkResponse;
import org.programmers.signalbuddy.domain.bookmark.service.BookmarkService;
import org.programmers.signalbuddy.global.annotation.CurrentUser;
import org.programmers.signalbuddy.global.dto.CustomUser2Member;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -46,7 +48,7 @@ public ResponseEntity<Page<BookmarkResponse>> getBookmarks(
@PostMapping
@ApiResponse(responseCode = "201", description = "즐겨찾기 등록 성공")
public ResponseEntity<BookmarkResponse> addBookmark(
@RequestBody @Validated BookmarkRequest createRequest, User user) {
@RequestBody @Validated BookmarkRequest createRequest, @CurrentUser CustomUser2Member user) {
log.info("createRequest: {}", createRequest);
final BookmarkResponse created = bookmarkService.createBookmark(createRequest, user);
return ResponseEntity.status(HttpStatus.CREATED).body(created);
Expand All @@ -56,7 +58,7 @@ public ResponseEntity<BookmarkResponse> addBookmark(
@PatchMapping("{id}")
@ApiResponse(responseCode = "200", description = "즐겨찾기 수정 성공")
public ResponseEntity<BookmarkResponse> updateBookmark(
@RequestBody @Validated BookmarkRequest updateRequest, @PathVariable Long id, User user) {
@RequestBody @Validated BookmarkRequest updateRequest, @PathVariable Long id, @CurrentUser CustomUser2Member user) {
log.info("updateRequest: {}", updateRequest);
final BookmarkResponse updated = bookmarkService.updateBookmark(updateRequest, id, user);
return ResponseEntity.ok().body(updated);
Expand All @@ -65,8 +67,7 @@ public ResponseEntity<BookmarkResponse> updateBookmark(
@Operation(summary = "즐겨찾기 삭제", description = "즐겨찾기 삭제 기능")
@DeleteMapping("{id}")
@ApiResponse(responseCode = "200", description = "즐겨찾기 삭제 성공")
public ResponseEntity<Void> deleteBookmark(@PathVariable Long id, User user) {
user.setName("1");
public ResponseEntity<Void> deleteBookmark(@PathVariable Long id, @CurrentUser CustomUser2Member user) {
log.info("delete bookmark id: {}", id);
bookmarkService.deleteBookmark(id, user);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import lombok.RequiredArgsConstructor;
import org.programmers.signalbuddy.domain.bookmark.dto.BookmarkResponse;
import org.programmers.signalbuddy.domain.bookmark.service.BookmarkService;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.programmers.signalbuddy.global.annotation.CurrentUser;
import org.programmers.signalbuddy.global.dto.CustomUser2Member;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
Expand All @@ -20,6 +19,11 @@ public class BookmarkWebController {

private final BookmarkService bookmarkService;

@ModelAttribute("user")
public CustomUser2Member currentUser(@CurrentUser CustomUser2Member user) {
return user;
}

@GetMapping("{id}")
public ModelAndView getBookmark(@PathVariable Long id, ModelAndView mv) {
final BookmarkResponse bookmark = bookmarkService.getBookmark(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public class BookmarkRepositoryCustomImpl implements BookmarkRepositoryCustom {
public Page<BookmarkResponse> findPagedByMember(Pageable pageable, Long memberId) {
final List<BookmarkResponse> responses = queryFactory.select(pageBookmarkDto).from(bookmark)
.join(member)
.on(bookmark.member.eq(member).and(member.memberId.eq(1L))) // TODO : 1L -> memberId
.on(bookmark.member.eq(member).and(member.memberId.eq(memberId)))
.offset(pageable.getOffset()).limit(pageable.getPageSize())
.orderBy(new OrderSpecifier<>(Order.ASC, bookmark.bookmarkId)).fetch();

final Long count = queryFactory.select(bookmark.count()).from(bookmark).join(member)
.on(member.memberId.eq(1L)) // TODO : 1L -> memberId
.on(bookmark.member.eq(member).and(member.memberId.eq(memberId)))
.fetchOne();
return new PageImpl<>(responses, pageable, count != null ? count : 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.programmers.signalbuddy.domain.member.entity.Member;
import org.programmers.signalbuddy.domain.member.exception.MemberErrorCode;
import org.programmers.signalbuddy.domain.member.repository.MemberRepository;
import org.programmers.signalbuddy.global.dto.CustomUser2Member;
import org.programmers.signalbuddy.global.exception.BusinessException;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
Expand All @@ -34,7 +34,7 @@ public Page<BookmarkResponse> findPagedBookmarks(Pageable pageable, Long memberI
return bookmarkRepository.findPagedByMember(pageable, memberId);
}

public BookmarkResponse createBookmark(BookmarkRequest createRequest, User user) {
public BookmarkResponse createBookmark(BookmarkRequest createRequest, CustomUser2Member user) {
final Member member = getMember(user);

final Point point = toPoint(createRequest.getLng(), createRequest.getLat());
Expand All @@ -45,7 +45,8 @@ public BookmarkResponse createBookmark(BookmarkRequest createRequest, User user)
}

@Transactional
public BookmarkResponse updateBookmark(BookmarkRequest updateRequest, Long id, User user) {
public BookmarkResponse updateBookmark(BookmarkRequest updateRequest, Long id,
CustomUser2Member user) {
final Member member = getMember(user);

final Bookmark bookmark = bookmarkRepository.findById(id)
Expand All @@ -58,15 +59,15 @@ public BookmarkResponse updateBookmark(BookmarkRequest updateRequest, Long id, U
}

@Transactional
public void deleteBookmark(Long id, User user) {
public void deleteBookmark(Long id, CustomUser2Member user) {
final Member member = getMember(user);
final Bookmark bookmark = bookmarkRepository.findById(id)
.orElseThrow(() -> new BusinessException(BookmarkErrorCode.NOT_FOUND_BOOKMARK));
bookmarkRepository.delete(bookmark);
}

private Member getMember(User user) {
return memberRepository.findById(Long.parseLong(user.getName())) // TODO : User 수정 필요
private Member getMember(CustomUser2Member user) {
return memberRepository.findById(user.getMemberId())
.orElseThrow(() -> new BusinessException(MemberErrorCode.NOT_FOUND_MEMBER));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package org.programmers.signalbuddy.domain.crossroad.controller;

import org.programmers.signalbuddy.domain.crossroad.dto.CrossroadApiResponse;
import org.programmers.signalbuddy.domain.crossroad.dto.CrossroadStateApiResponse;
import org.programmers.signalbuddy.domain.crossroad.service.CrossroadService;
import jakarta.validation.constraints.Min;
import lombok.RequiredArgsConstructor;
import org.programmers.signalbuddy.domain.crossroad.service.CrossroadService;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Validated
@RestController
Expand All @@ -24,4 +28,28 @@ public ResponseEntity<Void> saveCrossroadDates(@Min(1) @RequestParam("page") int
crossroadService.saveCrossroadDates(page, pageSize);
return ResponseEntity.ok().build();
}


@GetMapping("/marker") // 저장된 DB 데이터를 기반으로 map에 찍을 marker의 데이터를 point로 가져오기
public ResponseEntity<List<CrossroadApiResponse>> pointToMarker(){
List<CrossroadApiResponse> markers = crossroadService.getAllMarkers();
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_JSON)
.body(markers);
}


@GetMapping("/state/{id}") // id를 기반으로 신호등 데이터 상태 검색
public ResponseEntity<List<CrossroadStateApiResponse>> markerToState(@PathVariable("id") Long id) {
HttpHeaders headers = new HttpHeaders();
headers.setCacheControl(CacheControl.noCache().getHeaderValue());

List<CrossroadStateApiResponse> stateRes = crossroadService.checkSignalState(id);

return ResponseEntity.ok()
.headers(headers)
.contentType(MediaType.APPLICATION_JSON)
.body(stateRes);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.programmers.signalbuddy.domain.crossroad.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/")
public class WebController {

@GetMapping
public ModelAndView index(ModelAndView mv) {
mv.setViewName("main");
return mv;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.programmers.signalbuddy.domain.crossroad.dto;

import static org.programmers.signalbuddy.domain.crossroad.service.PointUtil.toPoint;

import org.programmers.signalbuddy.domain.crossroad.entity.Crossroad;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.locationtech.jts.geom.Point;
import org.programmers.signalbuddy.domain.crossroad.service.PointUtil;

@Getter
@Builder
Expand All @@ -28,7 +28,14 @@ public class CrossroadApiResponse {
@JsonProperty("mapCtptIntLot")
private Double lng; // 경도

public Point getPoint() {
return toPoint(this.lat, this.lng);
public Point toPoint() {
return PointUtil.toPoint(this.lat, this.lng);
}

public CrossroadApiResponse(Crossroad crossroad) {
this.crossroadApiId = crossroad.getCrossroadApiId();
this.name = crossroad.getName();
this.lat = crossroad.getCoordinate().getY();
this.lng = crossroad.getCoordinate().getX();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.programmers.signalbuddy.domain.crossroad.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class CrossroadStateApiResponse {

@JsonProperty("itstId")
private String crossroadApiId;

// e,w,s,n,ne,nw,se,sw 8방위
// p : 사람, rs: remain second (남은 시간), sn: state name (상태 이름)

@JsonProperty("ntPdsgRmdrCs")
private int nprs;

@JsonProperty("etPdsgRmdrCs")
private int eprs;

@JsonProperty("stPdsgRmdrCs")
private int sprs;

@JsonProperty("wtPdsgRmdrCs")
private int wprs;

@JsonProperty("nePdsgRmdrCs")
private int neprs;

@JsonProperty("nwPdsgRmdrCs")
private int nwprs;

@JsonProperty("swPdsgRmdrCs")
private int swprs;

@JsonProperty("sePdsgRmdrCs")
private int seprs;

@JsonProperty("ntPdsgStatNm")
private SignalState npsn;

@JsonProperty("etPdsgStatNm")
private SignalState epsn;

@JsonProperty("wtPdsgStatNm")
private SignalState wpsn;

@JsonProperty("stPdsgStatNm")
private SignalState spsn;

@JsonProperty("nePdsgStatNm")
private SignalState nepsn;

@JsonProperty("nwPdsgStatNm")
private SignalState nwpsn;

@JsonProperty("sePdsgStatNm")
private SignalState sepsn;

@JsonProperty("swPdsgStatNm")
private SignalState swpsn;

}
Loading
Loading