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

Feat : 첫 화면인기 마감임박 보여주기 구현 #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
38f47ac
Feat : Home 화면 Init
Jul 31, 2024
19463b5
feat : DTO 추가
Jul 31, 2024
e1d6f19
feat : 서버 확인
jsilver01 Jul 31, 2024
98aa19c
feat : 서버 확인
jsilver01 Jul 31, 2024
df68a7c
feat : 서버 확인
jsilver01 Jul 31, 2024
a188533
feat : 서버 확인
jsilver01 Jul 31, 2024
453c739
feat : 코드 원상복구
jsilver01 Jul 31, 2024
215b076
feat : application.yml 에 리다이렉트주소 추가
jsilver01 Jul 31, 2024
ce83481
fix : Loginservice 에 리다이렉트주소 오류 발견 후 수정
jsilver01 Jul 31, 2024
a53819c
Feat : Home 화면 Init
Jul 31, 2024
b1ea6c8
feat : DTO 변경 및 레퍼지토리, 서비스 추가
Jul 31, 2024
55db601
feat : DTO 변경 및 레퍼지토리, 서비스 추가
Jul 31, 2024
e0dc668
feat : Service 구현
Aug 1, 2024
f123f1b
feat : 서버 확인
jsilver01 Jul 31, 2024
9dc985b
fix : 어노테이션 수정
jsilver01 Jul 31, 2024
70e8e50
chore : 다시 localhost 로 수정
jsilver01 Jul 31, 2024
21313a4
chore : .gradle/ 파일 무시하도록 gitignore 수정
jsilver01 Jul 31, 2024
04ec476
feat : 캐시 삭제
jsilver01 Jul 31, 2024
4dc9077
feat : exercise 관련 exception 클래스 작성
jsilver01 Jul 31, 2024
1261c08
feat : PostSignupRequest dto 작성
jsilver01 Jul 31, 2024
c5ffe26
feat : PostSignupResponse dto 작성
jsilver01 Jul 31, 2024
e24b31a
feat : MemberController.signUp 작성
jsilver01 Jul 31, 2024
4973c2b
feat : MemberService.signUp 작성
jsilver01 Jul 31, 2024
9d2c6b1
feat : SecurityConfig에 회원가입 uri 추가
jsilver01 Jul 31, 2024
61b0f9c
feat : 트랜잭션 어노테이션 추가
jsilver01 Jul 31, 2024
75ff900
fix : Jwt 관련 수정
jsilver01 Aug 1, 2024
c5d0ada
feat : 서버 확인
jsilver01 Jul 31, 2024
a70c108
fix : final,autowired 수정
Aug 1, 2024
68e4a6f
feat : 서버 확인
jsilver01 Jul 31, 2024
28bd089
feat : 캐시 삭제
jsilver01 Jul 31, 2024
f2e7ac1
feat : 크루등록 dto 작성
jsilver01 Aug 1, 2024
8a09f19
feat : CrewController.createCrew 작성
jsilver01 Aug 1, 2024
9ff3f9a
feat : crew 관련 exception 클래스 작성
jsilver01 Aug 1, 2024
8bc041b
feat : dto에 어노테이션 추가
jsilver01 Aug 1, 2024
44533c1
feat : activityRegion exception 클래스 작성
jsilver01 Aug 1, 2024
c2ef98c
feat : facility exception 클래스 작성
jsilver01 Aug 1, 2024
d91382e
feat : 필요한 레포지토리들 생성
jsilver01 Aug 1, 2024
0d73233
feat : 크루 생성자 추가
jsilver01 Aug 1, 2024
e3b35a3
feat : 크루 만들기 구현
jsilver01 Aug 1, 2024
b63ea0e
feat : 레포지토리 작성
jsilver01 Aug 1, 2024
318963b
feat : 의존성 추가
jsilver01 Aug 1, 2024
6b048b2
feat : 생성자에 status 추가
jsilver01 Aug 1, 2024
0066578
fix : MemberCrew 생성자에 status 추가
jsilver01 Aug 1, 2024
447e475
feat : 크루 등록 구현
jsilver01 Aug 1, 2024
7173dae
fix : 충돌 해결
jsilver01 Aug 1, 2024
81625ec
feat : gender 추가
jsilver01 Jul 23, 2024
386d162
feat : gender 추가
jsilver01 Jul 29, 2024
7f759a8
feat : level enum 클래스 추가
jsilver01 Jul 29, 2024
f013aeb
feat : pr 템플릿 추가
jsilver01 Jul 29, 2024
241e9e4
feat : pr 템플릿 추가
jsilver01 Jul 29, 2024
98f6caa
feat : Jwt Token 관련 클래스 생성
jsilver01 Jul 31, 2024
227a3e0
feat : 서버 확인
jsilver01 Jul 31, 2024
f8eaba4
feat : 코드 원상복구
jsilver01 Jul 31, 2024
fcc1d30
fix : jwtToken 오류 수정
jsilver01 Aug 1, 2024
bba69da
Remove .gradle directory from git tracking
jsilver01 Aug 1, 2024
f3345bd
feat : Service 구현
Aug 1, 2024
e78a10d
feat : 캐시 삭제
jsilver01 Jul 31, 2024
9e3d01a
feat : securityConfig에 헤더에 auth필요없도록 /main 추가
Aug 1, 2024
aa29de6
feat : 캐시 삭제
jsilver01 Jul 31, 2024
a7db1a5
feat : 서버 확인
jsilver01 Jul 31, 2024
bb5e317
feat : 필요한 레포지토리들 생성
jsilver01 Aug 1, 2024
7050dee
fix : 충돌 해결
jsilver01 Aug 1, 2024
49705ff
feat : DTO 추가
Jul 31, 2024
8ad1297
feat : 서버 확인
jsilver01 Jul 31, 2024
7894727
Feat : Home 화면 Init
Jul 31, 2024
442784d
feat : DTO 변경 및 레퍼지토리, 서비스 추가
Jul 31, 2024
9bf2454
feat : DTO 변경 및 레퍼지토리, 서비스 추가
Jul 31, 2024
79f8fbd
feat : Service 구현
Aug 1, 2024
a8b9f6f
feat : 서버 확인
jsilver01 Jul 31, 2024
07f4042
chore : .gradle/ 파일 무시하도록 gitignore 수정
jsilver01 Jul 31, 2024
06d8ec0
feat : 캐시 삭제
jsilver01 Jul 31, 2024
5206f0d
feat : 서버 확인
jsilver01 Jul 31, 2024
515ea25
fix : final,autowired 수정
Aug 1, 2024
6daf05f
feat : 서버 확인
jsilver01 Jul 31, 2024
06ae221
feat : 캐시 삭제
jsilver01 Jul 31, 2024
b7e3fb8
feat : 필요한 레포지토리들 생성
jsilver01 Aug 1, 2024
6948034
fix : 충돌 해결
jsilver01 Aug 1, 2024
d70de4b
Remove .gradle directory from git tracking
jsilver01 Aug 1, 2024
64d88c5
feat : 캐시 삭제
jsilver01 Jul 31, 2024
4c3bd78
feat : securityConfig에 헤더에 auth필요없도록 /main 추가
Aug 1, 2024
69b4c5d
feat : 캐시 삭제
jsilver01 Jul 31, 2024
d877adc
feat : 서버 확인
jsilver01 Jul 31, 2024
2744d8f
feat : 필요한 레포지토리들 생성
jsilver01 Aug 1, 2024
fd5c4e0
fix : 충돌 해결
jsilver01 Aug 1, 2024
36ab7a8
Merge remote-tracking branch 'origin/10-be-첫-화면인기-마감임박-보여주기-구현' into …
Aug 1, 2024
a4c5923
fix : Optional 감싸기 마지막 수정
Aug 1, 2024
af4674f
fix : id 값 추가 및 area_id -> area_name 변경
Aug 1, 2024
24e3886
fix : @Transactional 추가
Aug 1, 2024
497d64b
Merge branch 'develop' into 10-be-첫-화면인기-마감임박-보여주기-구현
jsilver01 Aug 1, 2024
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
Binary file added .gradle/8.9/checksums/checksums.lock
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.Getter;

@Getter
public class ExerciseException extends RuntimeException {
public class ExerciseException extends RuntimeException{

private final ResponseStatus exceptionStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ExerciseExceptionControllerAdvice {
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(ExerciseException.class)
public BaseErrorResponse handle_ExerciseException(ExerciseException e) {
log.error("[handle_ExerciseException", e);
log.error("[handle_ExerciseException]", e);
return new BaseErrorResponse(e.getExceptionStatus(), e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public enum BaseExceptionResponseStatus implements ResponseStatus{
* 6000: member 관련
*/
CANNOT_FOUND_MEMBER(6000, HttpStatus.BAD_REQUEST.value(), "유저를 찾을 수 없습니다."),
ALREADY_EXIST_EMAIL(6001, HttpStatus.BAD_REQUEST.value(), "이미 존재하는 이메일입니다.");
ALREADY_EXIST_EMAIL(6001, HttpStatus.BAD_REQUEST.value(), "이미 존재하는 이메일입니다."),

/**
* 7000 : crew 관련
*/
CANNOT_FOUND_CREW_LIST(7000, HttpStatus.BAD_REQUEST.value(), "크루 리스트를 찾을 수 없습니다.");


private final int code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.csrf(CsrfConfigurer<HttpSecurity>::disable)
.authorizeHttpRequests(requests ->
requests
.requestMatchers("/test", "/auth/kakao/callback", "/user/signup").permitAll() // 이 URL은 모두에게 허용
.requestMatchers("/test", "/auth/kakao/callback", "/user/signup","/main").permitAll() // 이 URL은 모두에게 허용
.anyRequest().authenticated() // 그 외의 모든 요청은 인증 필요
)
.sessionManagement(sessionManagement ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.likelion12.controller;

import com.example.likelion12.common.response.BaseResponse;
import com.example.likelion12.dto.HomeResponse;
import com.example.likelion12.service.HomeService;
import com.example.likelion12.util.JwtProvider;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
public class HomeController {

private final JwtProvider jwtProvider;
private final HomeService homeService;

@GetMapping("/main")
public BaseResponse<HomeResponse> getHomeData(@RequestHeader("Authorization") String authorization){
Long memberId = jwtProvider.extractIdFromHeader(authorization);
return new BaseResponse<>(homeService.getHomeData(memberId));
}
}

16 changes: 16 additions & 0 deletions src/main/java/com/example/likelion12/dto/Crew.java
jsilver01 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.likelion12.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class Crew {
private Long crew_id;
private String crew_name;
private String crew_img;
private String active_area_name;
private Integer total_recruits;
private Integer crew_cost;
private String comment_simple;
}
12 changes: 12 additions & 0 deletions src/main/java/com/example/likelion12/dto/HomeResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.likelion12.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;

@Getter
@AllArgsConstructor
public class HomeResponse {
private List<Socialring> deadline_imminent;
private List<Crew> hot_crew;
}
17 changes: 17 additions & 0 deletions src/main/java/com/example/likelion12/dto/Socialring.java
jsilver01 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.likelion12.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class Socialring {
private Long socialring_id;
private String socialring_name;
private String socialring_img;
private String socialring_date;
private String active_area_name;
private Integer total_recruits;
private Integer socialring_cost;
private String comment_simple;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import com.example.likelion12.domain.Crew;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

@Repository
public interface CrewRepository extends JpaRepository<Crew, Long> {

}
// "크루"가 가지고 있는 "크루_멤버"가 많은 순으로 4개 반환 (홈화면 보여주기용)
@Query("SELECT c FROM Crew c LEFT JOIN c.memberCrewList m GROUP BY c ORDER BY COUNT(m) DESC LIMIT 4")
Optional<List<Crew>> findTop4ByMemberCrewListSize();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.example.likelion12.repository;


import com.example.likelion12.domain.Socialring;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface SocialringRepository extends JpaRepository<Socialring, Long> {
//Optional<Socialring> findBySocialringIdAndStatus(Long socialringId, BaseStatus status);

// 홈화면에 보여줄 4개를 마감기한 입박한 순으로 반환
@Query(value = "SELECT * FROM socialring ORDER BY socialring_date ASC LIMIT 4", nativeQuery = true)
Optional<List<Socialring>> findTop4ByOrderBySocialringDate();

Optional<Socialring> findBySocialringIdAndStatus(Long socialringId, BaseStatus status);
}
76 changes: 76 additions & 0 deletions src/main/java/com/example/likelion12/service/HomeService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.example.likelion12.service;

import com.example.likelion12.common.exception.CrewException;
import com.example.likelion12.domain.Socialring;
import com.example.likelion12.dto.Crew;
import com.example.likelion12.dto.HomeResponse;
import com.example.likelion12.repository.CrewRepository;
import com.example.likelion12.repository.SocialringRepository;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

import static com.example.likelion12.common.response.status.BaseExceptionResponseStatus.CANNOT_FOUND_CREW_LIST;

@Slf4j
@Service
@RequiredArgsConstructor
public class HomeService {

private final CrewRepository crewRepository;
private final SocialringRepository socialringRepository;

@Transactional
public HomeResponse getHomeData(Long memberId) {

List<com.example.likelion12.domain.Crew> topCrews = crewRepository.findTop4ByMemberCrewListSize()
.orElseThrow(()->new CrewException(CANNOT_FOUND_CREW_LIST));
List<Socialring> topSocialrings = socialringRepository.findTop4ByOrderBySocialringDate()
.orElseThrow(()->new CrewException(CANNOT_FOUND_CREW_LIST));

// 소셜 DTO로 변환
List<com.example.likelion12.dto.Socialring> deadline_imminent = topSocialrings.stream()
.map(socialring -> new com.example.likelion12.dto.Socialring(
socialring.getSocialringId(),
socialring.getSocialringName(),
socialring.getSocialringImg(),
formatDate(socialring.getSocialringDate()),
socialring.getActivityRegion().getActivityRegionName(),
socialring.getTotalRecruits(),
socialring.getSocialringCost(),
socialring.getCommentSimple()
))
.collect(Collectors.toList());

// 크루 DTO로 변환
List<Crew> hot_crew = topCrews.stream()
.map(crew -> new Crew(
crew.getCrewId(),
crew.getCrewName(),
crew.getCrewImg(),
crew.getActivityRegion().getActivityRegionName(),
crew.getTotalRecruits(),
crew.getCrewCost(),
crew.getCommentSimple()
))
.collect(Collectors.toList());
// 관심 종목 필터링


return new HomeResponse(deadline_imminent , hot_crew);
}

// 날짜 포맷 변환 메소드
private String formatDate(LocalDateTime date) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return date.format(formatter);
}
}
Loading