Skip to content

Commit

Permalink
Merge branch 'feature/storeDetail' into feature/registerStore
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna-Jin committed Jul 14, 2022
2 parents 3357123 + 6a7ef3d commit 4edaac0
Show file tree
Hide file tree
Showing 60 changed files with 844 additions and 521 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ dependencies {
compileOnly 'org.projectreactor:reactor-spring:1.0.1.RELEASE'
compileOnly 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'org.springframework.boot:spring-boot-starter-reactor-netty:2.7.1'

//tomcat
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
// OAuth2
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.7.0'
// jwt
Expand All @@ -61,6 +62,9 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
//s3 파일 업로드
implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.1'
//swagger
implementation 'io.springfox:springfox-boot-starter:3.0.0'

}
tasks.named('test') {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mpnp.baechelin.bookmark.controller;

import com.mpnp.baechelin.bookmark.dto.BookmarkReqDTO;
import com.mpnp.baechelin.bookmark.dto.BookmarkRequestDto;
import com.mpnp.baechelin.bookmark.service.BookmarkService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -14,8 +14,8 @@ public class BookmarkController {

/** 북마크 생성 폴더 담기 */
@PostMapping("/bookmark")
public void bookmark(@RequestBody BookmarkReqDTO bookmarkReqDTO){
public void bookmark(@RequestBody BookmarkRequestDto bookmarkRequestDto){

bookmarkService.bookmark(bookmarkReqDTO);
bookmarkService.bookmark(bookmarkRequestDto);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mpnp.baechelin.bookmark.controller;


import com.mpnp.baechelin.bookmark.dto.FolderReqDTO;
import com.mpnp.baechelin.bookmark.dto.FolderResDTO;
import com.mpnp.baechelin.bookmark.dto.FolderRequestDto;
import com.mpnp.baechelin.bookmark.dto.FolderResponseDto;
import com.mpnp.baechelin.bookmark.service.FolderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -18,9 +18,9 @@ public class FolderController {

/** 폴더 신규 생성 */
@PostMapping("/folder")
public void folder (@RequestBody FolderReqDTO folderReqDTO){
public void folder (@RequestBody FolderRequestDto folderRequestDto){

folderService.folder(folderReqDTO);
folderService.folder(folderRequestDto);
}

/* 폴더 삭제 -> 삭제 시 안에 담긴 모든 북마크가 삭제됨 */
Expand All @@ -41,7 +41,7 @@ public void folderUpdate (@PathVariable int folderId, @RequestParam String newFo
}

@PutMapping("/folderList/{userId}")
public List<FolderResDTO> folderList (@PathVariable int userId){
public List<FolderResponseDto> folderList (@PathVariable int userId){

return folderService.folderList(userId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mpnp.baechelin.bookmark.domain;

import com.mpnp.baechelin.store.domain.Store;
import com.mpnp.baechelin.user.domain.User;
import com.mpnp.baechelin.util.TimeStamped;
import lombok.*;

Expand All @@ -26,4 +27,8 @@ public class Bookmark extends TimeStamped {
@JoinColumn(name="STORE_ID", nullable = false)
private Store storeId;

}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="USER_ID", nullable = false)
private User userId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;

import com.mpnp.baechelin.user.entity.user.User;
import com.mpnp.baechelin.user.domain.User;
import com.mpnp.baechelin.util.TimeStamped;
import lombok.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BookmarkDTO {
public class BookmarkDto {

private List<Store> storeList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BookmarkReqDTO {
public class BookmarkRequestDto {
private int storeId;
private int folderId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class FolderReqDTO {
public class FolderRequestDto {

private String folderName = "미분류";
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class FolderResDTO {
public class FolderResponseDto {
private int id;
private String folderName;
private List<List<String>> bookmarkList;

public FolderResDTO(Folder folder) {
public FolderResponseDto(Folder folder) {
this.id = folder.getId();
this.folderName = folder.getFolderName();
}

public static FolderResDTO FolderDtoRes(Folder folder) {
public static FolderResponseDto FolderDtoRes(Folder folder) {
/** 북마크의 정보를 담는 작업 */
List<List<String>> bookmarks = new ArrayList<>();
if(folder.getBookmarkList() != null) {
Expand All @@ -33,13 +33,13 @@ public static FolderResDTO FolderDtoRes(Folder folder) {
bookmarks.add(tempBookmarkList);
}
} else if(folder.getBookmarkList() == null) {
return FolderResDTO.builder()
return FolderResponseDto.builder()
.folderName(folder.getFolderName())
.id(folder.getId())
.build();
}

return FolderResDTO.builder()
return FolderResponseDto.builder()
.folderName(folder.getFolderName())
.id(folder.getId())
.bookmarkList(bookmarks)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mpnp.baechelin.bookmark.repository;

import com.mpnp.baechelin.bookmark.domain.Folder;
import com.mpnp.baechelin.user.entity.user.User;
import com.mpnp.baechelin.user.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

import com.mpnp.baechelin.bookmark.domain.Bookmark;
import com.mpnp.baechelin.bookmark.domain.Folder;
import com.mpnp.baechelin.bookmark.dto.BookmarkReqDTO;
import com.mpnp.baechelin.bookmark.dto.BookmarkRequestDto;
import com.mpnp.baechelin.bookmark.repository.BookmarkRepository;
import com.mpnp.baechelin.bookmark.repository.FolderRepository;
import com.mpnp.baechelin.store.domain.Store;
import com.mpnp.baechelin.store.repository.StoreRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class BookmarkService {
Expand All @@ -20,11 +18,11 @@ public class BookmarkService {
private final FolderRepository folderRepository;
private final StoreRepository storeRepository;

public void bookmark(BookmarkReqDTO bookmarkReqDTO) {
public void bookmark(BookmarkRequestDto bookmarkRequestDto) {

Folder folder = folderRepository.findById(bookmarkReqDTO.getFolderId())
Folder folder = folderRepository.findById(bookmarkRequestDto.getFolderId())
.orElseThrow(()-> new IllegalArgumentException("폴더가 존재하지 않습니다"));
Store store = storeRepository.findById(bookmarkReqDTO.getStoreId())
Store store = storeRepository.findById(bookmarkRequestDto.getStoreId())
.orElseThrow(()-> new IllegalArgumentException("가게가 존재하지 않습니다"));

Bookmark bookmark = Bookmark
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.mpnp.baechelin.bookmark.service;

import com.mpnp.baechelin.bookmark.domain.Folder;
import com.mpnp.baechelin.bookmark.dto.FolderReqDTO;
import com.mpnp.baechelin.bookmark.dto.FolderResDTO;
import com.mpnp.baechelin.bookmark.dto.FolderRequestDto;
import com.mpnp.baechelin.bookmark.dto.FolderResponseDto;
import com.mpnp.baechelin.bookmark.repository.FolderRepository;

import com.mpnp.baechelin.user.entity.user.User;
import com.mpnp.baechelin.user.domain.User;
import com.mpnp.baechelin.user.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -23,12 +23,12 @@ public class FolderService {
private final UserRepository userRepository;

@Transactional
public void folder(FolderReqDTO folderReqDTO) {
public void folder(FolderRequestDto folderRequestDto) {

Optional<User> user = userRepository.findById(1);

Folder folder = Folder.builder()
.folderName(folderReqDTO.getFolderName())
.folderName(folderRequestDto.getFolderName())
.userId(user.get())
.build();
folderRepository.save(folder);
Expand All @@ -49,15 +49,15 @@ public void folderUpdate(int folderId, String newFolderName) {
}

@Transactional(readOnly = true)
public List<FolderResDTO> folderList(int userId) {
public List<FolderResponseDto> folderList(int userId) {
Optional<User> user = userRepository.findById(userId);

List<FolderResDTO> folderResDTOList = new ArrayList<>();
List<FolderResponseDto> folderResponseDtoList = new ArrayList<>();

for(Folder obj : user.get().getFolderList()){
folderResDTOList.add(FolderResDTO.FolderDtoRes(obj));
folderResponseDtoList.add(FolderResponseDto.FolderDtoRes(obj));
}

return folderResDTOList;
return folderResponseDtoList;
}
}
33 changes: 33 additions & 0 deletions src/main/java/com/mpnp/baechelin/config/QuerydslConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mpnp.baechelin.config;

import com.querydsl.core.BooleanBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.math.BigDecimal;

import static com.mpnp.baechelin.store.domain.QStore.store;

@Configuration
public class QuerydslConfig {

@PersistenceContext
private EntityManager entityManager;

@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(entityManager);
}

public static BooleanBuilder locationBuilder(BigDecimal latStart, BigDecimal latEnd, BigDecimal lngStart, BigDecimal lngEnd) {
BooleanBuilder builder = new BooleanBuilder();
builder.and(latStart == null ? null : store.latitude.goe(latStart));
builder.and(latEnd == null ? null : store.latitude.loe(latEnd));
builder.and(lngStart == null ? null : store.longitude.goe(lngStart));
builder.and(lngEnd == null ? null : store.longitude.loe(lngEnd));
return builder;
}
}
20 changes: 0 additions & 20 deletions src/main/java/com/mpnp/baechelin/config/QuerydslConfiguration.java

This file was deleted.

39 changes: 39 additions & 0 deletions src/main/java/com/mpnp/baechelin/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mpnp.baechelin.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

private static final String API_NAME = "Baechelin Project API";
private static final String API_VERSION = "0.0.1";
private static final String API_DESCRIPTION = "Baechelin 프로젝트 명세서";

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}

public ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(API_NAME)
.version(API_VERSION)
.description(API_DESCRIPTION)
.build();
}
}
Loading

0 comments on commit 4edaac0

Please sign in to comment.