Skip to content

Commit

Permalink
Merge branch 'main' into feature/users
Browse files Browse the repository at this point in the history
  • Loading branch information
ksj000625 authored Dec 8, 2024
2 parents 687e53b + 74a822c commit e9829e9
Show file tree
Hide file tree
Showing 37 changed files with 838 additions and 75 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dev_deply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
-e KAKAO_PROVIDER_TOKEN_URI=${{secrets.KAKAO_PROVIDER_TOKEN_URI}} \
-e KAKAO_PROVIDER_USER_INFO_URI=${{secrets.KAKAO_PROVIDER_USER_INFO_URI}} \
-e PORTONE_API_SECRET=${{secrets.PORTONE_API_SECRET}} \
-e WEBHOOK_URL=${{secrets.WEBHOOK_URL}} \
${{ secrets.DOCKERHUB_USERNAME }}/bill-api:latest
sudo docker rm $(sudo docker ps --filter 'status=exited' -a -q)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import site.billbill.apiserver.api.auth.dto.request.*;
import site.billbill.apiserver.api.auth.dto.response.NicknameResponse;
import site.billbill.apiserver.api.auth.service.AuthService;
import site.billbill.apiserver.api.auth.service.OAuthService;
import site.billbill.apiserver.api.users.service.UserService;
import site.billbill.apiserver.common.response.BaseResponse;
import site.billbill.apiserver.common.utils.jwt.dto.JwtDto;

Expand All @@ -30,6 +32,7 @@ public class AuthController {

private final AuthService authService;
private final OAuthService oAuthService;
private final UserService userService;

@Operation(summary = "회원 가입(일반)", description = "일반 회원 가입 API")
@ResponseStatus(HttpStatus.CREATED)
Expand Down Expand Up @@ -64,4 +67,14 @@ public BaseResponse<JwtDto> kakaoCallback(@RequestParam("code") String code) {
public BaseResponse<JwtDto> identity(@RequestBody IdentityVerificationRequest request) {
return null;
}

@Operation(summary = "닉네임 중복검사", description = "닉네임 중복검사")
@ResponseStatus(HttpStatus.OK)
@GetMapping("/nickname")
public BaseResponse<NicknameResponse> getNicknameValidity(@RequestParam String nickname) {
return new BaseResponse<>(NicknameResponse.builder()
.valid(authService.getNicknameValidity(nickname))
.build());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package site.billbill.apiserver.api.auth.dto.response;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class NicknameResponse {
private boolean valid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface AuthService {
JwtDto reissue(String refreshToken);

boolean identifyUser(IdentityRequest request);

boolean getNicknameValidity(String nickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public boolean identifyUser(IdentityRequest request) {
return false;
}

@Override
public boolean getNicknameValidity(String nickname) {
return !userRepository.existsByNickname(nickname);
}

/**
* Method that if user is withdrawn
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@
import org.jboss.logging.MDC;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;
import site.billbill.apiserver.api.borrowPosts.dto.request.PostsRequest;
import site.billbill.apiserver.api.borrowPosts.dto.response.PostsResponse;
import site.billbill.apiserver.api.borrowPosts.service.PostsService;
import site.billbill.apiserver.common.response.BaseResponse;
import site.billbill.apiserver.common.utils.jwt.JWTUtil;

import java.util.List;

@Slf4j
@RestController
@Tag(name = "borrowPosts", description = "대여 게시물 관련")
@RequestMapping("/api/v1/posts/borrowPosts")
@RequiredArgsConstructor
public class PostsController {
private final PostsService postsService;
@Operation(summary = "게시물 생성", description = "게시물 생성 API")
@PostMapping("")
public BaseResponse<PostsResponse.UploadResponse> uploadPostsController(@RequestBody @Valid PostsRequest.UploadRequest request){

Expand All @@ -46,17 +50,79 @@ public BaseResponse<PostsResponse.ViewAllResultResponse> getPostsController(
@Parameter(name = "order", description = "정렬 방향 (asc: 오름차순, desc: 내림차순)", example = "desc", in = ParameterIn.QUERY, required = false)
@RequestParam(value ="order",required = false,defaultValue = "desc") String order,
@Parameter(name = "sortBy", description = "정렬 기준 (예: price, createdAt, likeCount)", example = "createdAt", in = ParameterIn.QUERY, required = true)
@RequestParam(value="sortBy",required = true,defaultValue = "accuracy") String sortBy){
@RequestParam(value="sortBy",required = true,defaultValue = "accuracy") String sortBy
){


Sort.Direction direction = "asc".equalsIgnoreCase(order) ? Sort.Direction.ASC : Sort.Direction.DESC;
return new BaseResponse<>(postsService.ViewAllPostService(category,page,direction,sortBy));
}
@Operation(summary = "게시물 검색", description = "게시물 검색 API")
@GetMapping("/search")
public BaseResponse<PostsResponse.ViewAllResultResponse> getSearchPostsController(
@Parameter(name = "category", description = "카테고리 필터 (예: entire, camp, sports,tools )", example = "entire", in = ParameterIn.QUERY, required = false)
@RequestParam(value ="category",required = false,defaultValue = "entire") String category,
@Parameter(name = "page", description = "페이지 번호 (1부터 시작)", example = "1", in = ParameterIn.QUERY, required = false)
@RequestParam(value ="page",required = false,defaultValue = "1") int page,
@Parameter(name = "order", description = "정렬 방향 (asc: 오름차순, desc: 내림차순)", example = "desc", in = ParameterIn.QUERY, required = false)
@RequestParam(value ="order",required = false,defaultValue = "desc") String order,
@Parameter(name = "sortBy", description = "정렬 기준 (예: price, createdAt, likeCount)", example = "createdAt", in = ParameterIn.QUERY, required = true)
@RequestParam(value="sortBy",required = true,defaultValue = "accuracy") String sortBy,
@Parameter(name="keyword",description = "검색 키워드(예: 6인용+텐트)",in = ParameterIn.QUERY, required = true)
@RequestParam(value = "keyword",required = true) String keyword){

String userId = "";
if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
}
Sort.Direction direction = "asc".equalsIgnoreCase(order) ? Sort.Direction.ASC : Sort.Direction.DESC;
return new BaseResponse<>(postsService.ViewSearchPostService(userId,category, page, direction, sortBy,keyword,false));
}
@Operation(summary = "게시물 조회", description = "게시물 상세 조회")
@GetMapping("/{postId}")
public BaseResponse<PostsResponse.ViewPostResponse> getPostController(@PathVariable(value = "postId",required = true)String postId){
String userId = "";
if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
}
return new BaseResponse<>(postsService.ViewPostService(postId,userId));
}
@Operation(summary = "게시물 삭제", description = "게시물 삭제")
@DeleteMapping("/{postId}")
public BaseResponse<String> deletePostController(@PathVariable(value = "postId",required = true)String postId){

String userId = "";
if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
}
return new BaseResponse<>(postsService.deletePostService(postId,userId));
}
// @Operation(summary = "저장한 검색어 불러오기", description = "저장한 검색어 불러오기")
// @GetMapping("/searchHist")
// public BaseResponse<PostsResponse.saveSearchListResponse> getSearchHistController(){
// String userId = "";
// if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
// userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
// }
// return new BaseResponse<>(postsService.findSearchService(userId));
// }

return new BaseResponse<>(postsService.ViewPostService(postId));
@Operation(summary = "추천 검색어 불러오기", description = "추천 검색어 주기")
@GetMapping("/recommend")
public BaseResponse<List<String>> getRecommendController(){
return new BaseResponse<>(postsService.findRecommandService());
}
@Operation(summary = "게시물 수정", description = "게시물 수정")
@PatchMapping("/{postId}")
public BaseResponse<String> updatePostController(@PathVariable(value="postId",required = true)String postId,
@RequestBody @Valid PostsRequest.UploadRequest request){
String userId = "";
if(MDC.get(JWTUtil.MDC_USER_ID) != null) {
userId= MDC.get(JWTUtil.MDC_USER_ID).toString();
}
return new BaseResponse<>(postsService.UpdatePostService(postId,userId,request));
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import site.billbill.apiserver.api.borrowPosts.dto.request.PostsRequest;
import site.billbill.apiserver.api.borrowPosts.dto.response.PostsResponse;
import site.billbill.apiserver.model.post.ItemsBorrowJpaEntity;
import site.billbill.apiserver.model.post.ItemsBorrowStatusJpaEntity;
import site.billbill.apiserver.model.post.ItemsJpaEntity;
import site.billbill.apiserver.model.post.*;
import site.billbill.apiserver.model.user.UserJpaEntity;
import site.billbill.apiserver.model.user.UserSearchHistJpaEntity;
import site.billbill.apiserver.repository.borrowPosts.SearchKeywordStatRepository;

import java.time.format.DateTimeFormatter;
import java.util.List;
Expand All @@ -20,7 +20,7 @@ public static PostsResponse.UploadResponse toUploadResponse(String id){
postId(id).
build();
}
public static ItemsJpaEntity toItem(String postId,PostsRequest.UploadRequest request, UserJpaEntity user){
public static ItemsJpaEntity toItem(String postId, PostsRequest.UploadRequest request, UserJpaEntity user, ItemsCategoryJpaEntity category){
return ItemsJpaEntity.builder()
.id(postId)
.title(request.getTitle())
Expand All @@ -29,6 +29,7 @@ public static ItemsJpaEntity toItem(String postId,PostsRequest.UploadRequest req
.owner(user)
.viewCount(0)
.images(request.getImages())
.category(category)
.itemStatus(request.getItemStatus()).build();
}
public static ItemsBorrowJpaEntity toItemBorrow(ItemsJpaEntity item, PostsRequest.UploadRequest request){
Expand All @@ -50,6 +51,7 @@ public static ItemsBorrowStatusJpaEntity toItemBorrowStatus(ItemsJpaEntity item,
public static PostsResponse.Post toPost(ItemsJpaEntity item,ItemsBorrowJpaEntity borrowItem){
return PostsResponse.Post.builder()
.postId(item.getId())
.title(item.getTitle())
.image(Optional.ofNullable(item.getImages())
.filter(images -> !images.isEmpty())
.map(images -> images.get(0))
Expand All @@ -64,7 +66,7 @@ public static PostsResponse.Post toPost(ItemsJpaEntity item,ItemsBorrowJpaEntity
public static PostsResponse.ViewAllResultResponse toViewAllList(List<PostsResponse.Post> posts){
return PostsResponse.ViewAllResultResponse.builder().result(posts).build();
}
public static PostsResponse.ViewPostResponse toViewPost(ItemsJpaEntity item, ItemsBorrowJpaEntity borrowItem, List<PostsResponse.NoRentalPeriodResponse> noRental, String status){
public static PostsResponse.ViewPostResponse toViewPost(ItemsJpaEntity item, ItemsBorrowJpaEntity borrowItem, List<PostsResponse.NoRentalPeriodResponse> noRental, String status,UserJpaEntity user){
return PostsResponse.ViewPostResponse.builder()
.postId(item.getId())
.title(item.getTitle())
Expand All @@ -77,6 +79,8 @@ public static PostsResponse.ViewPostResponse toViewPost(ItemsJpaEntity item, Ite
.itemStatus(status)
.categoryId(item.getCategory().getId())
.categoryName(item.getCategory().getName())
.userId(user.getUserId())
.userName(user.getNickname())
.build();
}
public static PostsResponse.NoRentalPeriodResponse toNoRentalPeriod(ItemsBorrowStatusJpaEntity borrowStatus){
Expand All @@ -85,5 +89,26 @@ public static PostsResponse.NoRentalPeriodResponse toNoRentalPeriod(ItemsBorrowS
.endDate(borrowStatus.getEndDate().format(DATE_FORMATTER))
.build();
}
public static UserSearchHistJpaEntity toUserSearch(UserJpaEntity user,String keyword){
return UserSearchHistJpaEntity.builder()
.keyword(keyword)
.user(user).build();
}
public static SearchKeywordStatsJpaEntity toSearchKeywordStats(String keyword){
return SearchKeywordStatsJpaEntity.builder()
.keyword(keyword)
.searchCount(1).build();
}
public static PostsResponse.saveSearch toUserSearchHist(UserSearchHistJpaEntity userSeachHistory){
return PostsResponse.saveSearch.builder().id(userSeachHistory.getSearchId())
.keyword(userSeachHistory.getKeyword()).build();
}
public static PostsResponse.saveSearchListResponse toUserSearhList(List<PostsResponse.saveSearch> savedSearches){
return PostsResponse.saveSearchListResponse.builder().results(savedSearches).build();
}
public static String toRecommandSearch(SearchKeywordStatsJpaEntity searchKeywordStats){
return searchKeywordStats.getKeyword();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public static class UploadRequest {
private String content;
@Schema(description = "이미지", example = "[\"이미지링크\",\"이미지링크\"]")
private List<String> images;

@Schema(description = "카테고리", example = "camp, sports, tools")
private String category;
private List<NoRentalPeriod> noRental;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class ViewAllResultResponse{
public static class Post{
private String postId;
private String image;
private String title;
private int price;
private String userId;
private String userName;
Expand All @@ -47,8 +48,24 @@ public static class ViewPostResponse{
private List<NoRentalPeriodResponse> noRentalPeriod;
private String categoryId;
private String categoryName;
private String userId;
private String userName;

}
@Getter
@Setter
@Builder
public static class saveSearchListResponse{
private List<saveSearch> results;
}
@Getter
@Setter
@Builder
public static class saveSearch{
private Long id;
private String keyword;
}

@Getter
@Setter
@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@
import site.billbill.apiserver.api.borrowPosts.dto.request.PostsRequest;
import site.billbill.apiserver.api.borrowPosts.dto.response.PostsResponse;

import java.util.List;

public interface PostsService {
PostsResponse.UploadResponse uploadPostService(PostsRequest.UploadRequest request,String userId);

PostsResponse.ViewAllResultResponse ViewAllPostService(String category, int page, Sort.Direction direction, String orderType);

PostsResponse.ViewPostResponse ViewPostService(String postId);
PostsResponse.ViewPostResponse ViewPostService(String postId,String userId);

String deletePostService(String postId,String userId);

String UpdatePostService(String postId,String userId,PostsRequest.UploadRequest request);

PostsResponse.ViewAllResultResponse ViewSearchPostService(String userId,String category, int page, Sort.Direction direction, String orderType,String keyword,boolean state);

PostsResponse.saveSearchListResponse findSearchService(String userId);

List<String> findRecommandService();

}
Loading

0 comments on commit e9829e9

Please sign in to comment.