Skip to content

Commit

Permalink
Feat/#131 (#132)
Browse files Browse the repository at this point in the history
* feat : 해커톤 엔티티 추가

* refactor : core.yml local에서 ddl-auto update로 변경

* refactor : 해커톤 신청 시 대학이름 -> 대학ID를 입력받도록 변경

* refactor : Controller에 response타입 SuccessResponse<Object>로 들어간것 나머지 제거

* refactor : userInfo에 대학id, email추가

* feat : 해커톤 신청 여부 api 추가

* fix : 해커톤 신청 api 리퀘스트 수정
  • Loading branch information
seulgi99 authored Jun 30, 2024
1 parent 664c18e commit f0ac47d
Show file tree
Hide file tree
Showing 27 changed files with 226 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public SuccessResponse<PageResponse<PostInfoResponseDto>> getProjectsOfFreeBoard

@Operation(summary = "선택된 게시글들 삭제")
@DeleteMapping("/posts")
public SuccessResponse<Object> getProjectsOfFreeBoardPosts(
public SuccessResponse getProjectsOfFreeBoardPosts(
@RequestParam("selectedIds") List<Long> selectedIds
) {
adminPostService.deletePosts(selectedIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import javax.validation.Valid;
import likelion.univ.common.response.PageResponse;
import likelion.univ.domain.hackathon.entity.HackathonForm;
import likelion.univ.domain.hackathon.response.HackathonFindResponse;
import likelion.univ.domain.hackathon.response.HackathonFormFindResponse;
import likelion.univ.domain.hackathon.service.HackathonService;
import likelion.univ.hackathon.dto.request.HackathonFormSearchRequest;
import likelion.univ.response.SuccessResponse;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.data.domain.Page;
Expand All @@ -26,11 +27,11 @@ public class HackathonController {

@Operation(summary = "해커톤 신청 조회")
@GetMapping
public PageResponse<HackathonFindResponse> searchHackathons(
public SuccessResponse<PageResponse<HackathonFormFindResponse>> searchHackathons(
@ParameterObject @Valid HackathonFormSearchRequest request,
@ParameterObject Pageable pageable
) {
Page<HackathonForm> result = hackathonService.search(request.toCondition(), pageable);
return PageResponse.of(result.map(HackathonFindResponse::from));
return SuccessResponse.of(PageResponse.of(result.map(HackathonFormFindResponse::from)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public SuccessResponse<IdTokenDto> getIdToken(
"localhost:3000입니다. (나머지 경로는 같습니다.)"
)
@GetMapping("/{loginType}/idToken/local")
public SuccessResponse<Object> getIdTokenForLocal(
public SuccessResponse<IdTokenDto> getIdTokenForLocal(
@RequestParam("code") String code,
@PathVariable("loginType") String loginType
) {
Expand All @@ -53,7 +53,7 @@ public SuccessResponse<Object> getIdTokenForLocal(

@Operation(summary = "로그인", description = "id token과 login type으로 로그인 합니다.")
@PostMapping("/{logintype}/login")
public SuccessResponse<Object> login(
public SuccessResponse<AccountTokenDto> login(
@RequestParam("idtoken") String idToken,
@PathVariable("logintype") String loginType
) {
Expand All @@ -63,7 +63,7 @@ public SuccessResponse<Object> login(

@Operation(summary = "회원가입", description = "id token과 login type으로 회원가입 합니다.")
@PostMapping("/{logintype}/signup")
public SuccessResponse<Object> signUp(
public SuccessResponse<AccountTokenDto> signUp(
@RequestParam("idtoken") String idToken,
@PathVariable("logintype") String loginType,
@RequestBody SignUpRequestDto signUpRequestDto
Expand All @@ -74,14 +74,14 @@ public SuccessResponse<Object> signUp(

@Operation(summary = "유저 정보 조회", description = "간단한 유저정보를 조회합니다.")
@GetMapping("/userInfo")
public SuccessResponse<Object> getUserInfo() {
public SuccessResponse<AccountUserInfoDto> getUserInfo() {
AccountUserInfoDto accountUserInfoDto = clientAuthService.getUserInfo();
return SuccessResponse.of(accountUserInfoDto);
}

@Operation(summary = "토큰 재발급", description = "refresh token으로 access token을 재발급합니다.")
@PostMapping("/refresh")
public SuccessResponse<Object> refreshToken(
public SuccessResponse<AccountTokenDto> refreshToken(
@RequestParam("token") String refreshToken
) {
AccountTokenDto accountTokenDto = clientAuthService.refreshToken(refreshToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package likelion.univ.auth.dto.response;

import likelion.univ.domain.university.entity.University;
import likelion.univ.domain.user.entity.User;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -10,16 +11,20 @@ public class AccountUserInfoDto {

private Long userId;
private String profileImage;
private Long universityId;
private String universityName;
private String role;
private String email;
private String name;

public static AccountUserInfoDto of(User user, String universityName) {
public static AccountUserInfoDto of(User user, University university) {
return AccountUserInfoDto.builder()
.userId(user.getId())
.profileImage(user.getProfile().getProfileImage())
.universityName(universityName)
.universityId(university != null ? university.getId() : null)
.universityName(university != null ? university.getName() : null)
.role(user.getAuthInfo().getRole().toString())
.email(user.getAuthInfo().getEmail())
.name(user.getProfile().getName())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ public class ClientAuthService {
public AccountUserInfoDto getUserInfo() {
Long currentUserId = authenticatedUserUtils.getCurrentUserId();
User user = userRepository.getByIdWithUniversity(currentUserId);
if (user.getUniversityInfo().getUniversity() == null) {
return AccountUserInfoDto.of(user, null);
}
return AccountUserInfoDto.of(user, user.getUniversityInfo().getUniversity().getName());
return AccountUserInfoDto.of(user, user.getUniversityInfo().getUniversity());
}

public AccountTokenDto login(String loginType, String idToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DonationHistoryController {

@Operation(summary = "기부금 게시글 목록 검색", description = "기부금 게시글을 검색합니다. 파라미터로 search를 포함하지 않을 시 전체 조회입니다.")
@GetMapping
public SuccessResponse<Object> searchDonationHistories(
public SuccessResponse<PageResponse<DonationHistoriesSearchResponseDto>> searchDonationHistories(
@RequestParam(value = "sort", required = false, defaultValue = "created_date") String sort,
@RequestParam(value = "search", required = false) String search,
@ParameterObject @PageableDefault(size = 10, page = 0) Pageable pageable
Expand All @@ -39,7 +39,7 @@ public SuccessResponse<Object> searchDonationHistories(

@Operation(summary = "기부금 게시글 상세정보", description = "해당 기부금 게시글의 상세정보를 조회합니다.")
@GetMapping("/{donationHistoryId}")
public SuccessResponse<Object> searchDonationHistories(
public SuccessResponse<DonationHistoriesDetailsResponseDto> searchDonationHistories(
@PathVariable("donationHistoryId") Long donationHistoryId
) {
DonationHistoriesDetailsResponseDto result = clientDonationHistoryService.getDetails(donationHistoryId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FollowController {

@Operation(summary = "팔로우 ", description = "해당 유저를 팔로우 합니다.")
@PostMapping("/{userId}")
public SuccessResponse<Object> follow(
public SuccessResponse follow(
@PathVariable("userId") Long userId
) {
clientFollowService.follow(userId);
Expand All @@ -30,7 +30,7 @@ public SuccessResponse<Object> follow(

@Operation(summary = "팔로우 취소", description = "해당 유저를 팔로우 취소 합니다.")
@DeleteMapping("/{userId}")
public SuccessResponse<Object> deleteFollow(
public SuccessResponse deleteFollow(
@PathVariable("userId") Long userId
) {
clientFollowService.cancelFollow(userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import javax.validation.Valid;
import likelion.univ.domain.hackathon.response.HackathonFindResponse;
import likelion.univ.domain.hackathon.response.HackathonFormFindResponse;
import likelion.univ.domain.hackathon.service.HackathonService;
import likelion.univ.email.sender.EmailSender;
import likelion.univ.hackathon.request.HackathonApplyRequest;
Expand Down Expand Up @@ -40,13 +42,21 @@ public SuccessResponse<Long> apply(
return SuccessResponse.of(projectId);
}

@Operation(summary = "해커톤 신청 조회")
@Operation(summary = "해커톤 신청 내역 조회")
@GetMapping
public SuccessResponse<List<HackathonFindResponse>> findMyHackathonForms() {
Long userId = userUtils.getCurrentUserId();
List<HackathonFindResponse> response = hackathonService.findMyHackathonForms(userId);
return SuccessResponse.of(response);
}

@Operation(summary = "해커톤 신청 상세 조회")
@GetMapping("/{hackathonFormId}")
public SuccessResponse<HackathonFindResponse> find(
public SuccessResponse<HackathonFormFindResponse> find(
@PathVariable("hackathonFormId") Long hackathonFormId
) {
Long userId = userUtils.getCurrentUserId();
HackathonFindResponse response = hackathonService.find(userId, hackathonFormId);
HackathonFormFindResponse response = hackathonService.find(userId, hackathonFormId);
return SuccessResponse.of(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import likelion.univ.domain.hackathon.entity.HackathonPart;
import likelion.univ.domain.hackathon.service.command.HackathonApplyCommand;
Expand All @@ -18,9 +19,9 @@ public record HackathonApplyRequest(
@Schema(description = "신청자 이메일", example = "likelion@likelion.com")
String email,

@NotBlank
@Schema(description = "신청자 학교 이름", example = "멋사대학교")
String universityName,
@NotNull
@Schema(description = "신청자 학교 ID", example = "2")
Long universityId,

@NotBlank
@Schema(description = "신청자 전공", example = "멋쟁이과")
Expand All @@ -31,7 +32,7 @@ public record HackathonApplyRequest(
String phone,

@NotEmpty
@Schema(description = "해커톤 파트들", example = "PM,BACKEND")
@Schema(description = "해커톤 파트들", implementation = HackathonPart.class)
Set<HackathonPart> hackathonParts,

@NotBlank
Expand All @@ -51,7 +52,7 @@ public HackathonApplyCommand toCommand(Long userId) {
userId,
name,
email,
universityName,
universityId,
major,
phone,
hackathonParts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ImageController {

@Operation(summary = "project 이미지용입니다.")
@GetMapping("/project")
public SuccessResponse<Object> getProjectPresignedUrl(
public SuccessResponse<ImageUrlResponseDto> getProjectPresignedUrl(
@RequestParam("fileNameExtension") String fileNameExtension
) {
ImageUrlResponseDto imageUrlResponseDto = clientImageService.createProjectImagePresignedUrl(
Expand All @@ -33,7 +33,7 @@ public SuccessResponse<Object> getProjectPresignedUrl(

@Operation(summary = "user 프로필 이미지용입니다.")
@GetMapping("/user/{userId}")
public SuccessResponse<Object> getUserPresignedUrl(
public SuccessResponse<ImageUrlResponseDto> getUserPresignedUrl(
@PathVariable("userId") Long userId,
@RequestParam("fileNameExtension") String fileNameExtension
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class UniversityController {

@Operation(summary = "대학교 조회", description = "대학교를 조회합니다.")
@GetMapping
public SuccessResponse<Object> getAllUniv() {
public SuccessResponse<List<UnivResponseDto>> getAllUniv() {
List<UnivResponseDto> univList = universityQueryService.getUniv();
return SuccessResponse.of(univList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class UserController {

@Operation(summary = "유저페이지 프로필 조회", description = "해당 유저의 프로필 정보를 조회합니다.")
@GetMapping("/{userId}/profile")
public SuccessResponse<Object> getProfile(
public SuccessResponse<ProfileDetailsDto> getProfile(
@PathVariable("userId") Long userId
) {
ProfileDetailsDto profileDetailsDto = userQueryService.getProfile(userId);
Expand All @@ -45,7 +45,7 @@ public SuccessResponse<Object> getProfile(

@Operation(summary = "유저페이지 프로필 수정", description = "해당 유저의 프로필 정보를 수정합니다.")
@PatchMapping("/{userId}/profile")
public SuccessResponse<Object> editProfile(
public SuccessResponse editProfile(
@PathVariable("userId") Long userId,
@RequestBody ProfileEditRequestDto profileEditRequestDto
) {
Expand All @@ -55,7 +55,7 @@ public SuccessResponse<Object> editProfile(

@Operation(summary = "팔로잉 목록 조회", description = "해당 유저의 팔로잉 목록을 조회합니다.")
@GetMapping("/{userId}/following")
public SuccessResponse<Object> getFollowingList(
public SuccessResponse<SliceResponse<FollowUserInfoDto>> getFollowingList(
@PathVariable("userId") Long userId,
@ParameterObject @PageableDefault(size = 4, page = 0) Pageable pageable
) {
Expand All @@ -65,7 +65,7 @@ public SuccessResponse<Object> getFollowingList(

@Operation(summary = "팔로워 목록 조회", description = "해당 유저의 팔로워 목록을 조회합니다.")
@GetMapping("/{userId}/follower")
public SuccessResponse<Object> getFollowerList(
public SuccessResponse<SliceResponse<FollowUserInfoDto>> getFollowerList(
@PathVariable("userId") Long userId,
@ParameterObject @PageableDefault(size = 4, page = 0) Pageable pageable
) {
Expand All @@ -75,7 +75,7 @@ public SuccessResponse<Object> getFollowerList(

@Operation(summary = "해당 유저가 쓴 게시글 조회", description = "해당 유저가 작성한 게시글을 조회합니다.")
@GetMapping("/{userId}/posts")
public SuccessResponse<Object> getPostsWrittenByUser(
public SuccessResponse<PageResponse<UserPagePostsDto>> getPostsWrittenByUser(
@PathVariable("userId") Long userId,
@ParameterObject @PageableDefault(size = 6, page = 1) Pageable pageable
) {
Expand All @@ -85,7 +85,7 @@ public SuccessResponse<Object> getPostsWrittenByUser(

@Operation(summary = "해당 유저가 좋아요 누른 게시글 조회", description = "해당 유저가 좋아요를 누른 게시글을 조회합니다. 파라미터로 search를 포함하지 않을 시 전체 조회입니다.")
@GetMapping("/{userId}/posts/like")
public SuccessResponse<Object> getPostsLikedByUser(
public SuccessResponse<PageResponse<UserPagePostsDto>> getPostsLikedByUser(
@PathVariable("userId") Long userId,
@RequestParam(value = "sort", required = false, defaultValue = "created_date") String sort,
@RequestParam(value = "search", required = false) String search,
Expand All @@ -99,7 +99,7 @@ public SuccessResponse<Object> getPostsLikedByUser(

@Operation(summary = "해당 유저가 댓글 쓴 게시글 조회", description = "해당 유저가 댓글을 작성한 게시글을 조회합니다.")
@GetMapping("/{userId}/posts/comment")
public SuccessResponse<Object> getPostsCommentedByUser(
public SuccessResponse<PageResponse<UserPagePostsDto>> getPostsCommentedByUser(
@PathVariable("userId") Long userId,
@ParameterObject @PageableDefault(size = 6, page = 0) Pageable pageable
) {
Expand All @@ -111,7 +111,7 @@ public SuccessResponse<Object> getPostsCommentedByUser(

@Operation(summary = "유저 검색 (Simple Data) (project page)", description = "이름으로 유저를 검색합니다. (프로젝트 페이지 모달)")
@GetMapping("/search")
public SuccessResponse<Object> searchUser(
public SuccessResponse<SliceResponse<UserSearchResultDto>> searchUser(
@RequestParam(value = "name", required = false) String name,
@ParameterObject @PageableDefault(size = 4, page = 0) Pageable pageable
) {
Expand All @@ -121,7 +121,7 @@ public SuccessResponse<Object> searchUser(

@Operation(summary = "내가 참여한 프로젝트 조회", description = "참여한 프로젝트를 조회합니다.")
@GetMapping("/{userId}/projects")
public SuccessResponse<Object> getMyProjects(
public SuccessResponse<PageResponse<UserPageProjectsDto>> getMyProjects(
@PathVariable("userId") Long userId,
@ParameterObject @PageableDefault(size = 6, page = 0) Pageable pageable
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package likelion.univ.common.entity;

import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.AbstractAggregateRoot;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseTimeEntity {
public abstract class BaseTimeEntity extends AbstractAggregateRoot<BaseTimeEntity> {

@Column(updatable = false)
@CreatedDate
private LocalDateTime createdDate;

@Column
@LastModifiedDate
private LocalDateTime modifiedDate;
}
}
Loading

0 comments on commit f0ac47d

Please sign in to comment.