From f17a386e872de3fb798f04e617a7ef2e493f9d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=84=B1=ED=97=8C?= <79990740+lukehongg@users.noreply.github.com> Date: Wed, 1 Feb 2023 01:42:56 +0900 Subject: [PATCH] Version 1 (#35) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * temp * init * init * init (#2) * Temp2 (#3) * initial setting * initial setting * Temp2 (#4) * initial setting * initial setting * entity 일부 생성 * Init e (#5) * initE * initE * Table setting * Feat/#6 (#7) * initial setting * initial setting * entity 일부 생성 * 로그인 api 구현중 * Init e (#8) * initE * initE * Table setting * ,, * #7 (#9) * 로그인 API 구현 (#11) * Feat/#10 (#12) * 로그인 API 구현 * 로그인 API 완성 * Feat/#13 (#14) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * Feat/#7 (#15) * #7 * history API * Feat/#13 (#16) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * Feat/#13 (#18) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * [#19] (#20) * Feat/#13 (#22) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * . * [#23] (#24) * Feat/crossorigin (#25) * . * crossorigin * Feat/#13 (#26) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * Feat/#13 (#27) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * Feat/merge (#28) * . * merge * merged * Feat/merge2 (#29) * . * merge2 * Feat/merge3 (#30) * . * merge3 * Feat/#13 (#31) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * 잔디 심기 구현 * Feat/#13 (#32) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * 잔디 심기 구현 * 잔디 심기 구현완료 * store API 수정 * Feat/#13 (#33) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * 잔디 심기 구현 * 잔디 심기 구현완료 * 처음 유저 기본값 설정 * final (#34) --------- Co-authored-by: shinel98 <75024473+shinel98@users.noreply.github.com> --- .DS_Store | Bin 0 -> 6148 bytes build.gradle | 8 + .../greenpoint/server/ServerApplication.java | 13 +- .../admin/controller/AdminController.java | 14 ++ .../greenpoint/server/admin/model/Admin.java | 34 +++++ .../admin/repository/AdminRepository.java | 8 + .../server/admin/service/AdminService.java | 7 + .../auth/controller/UserController.java | 82 ++++++++++ .../server/auth/model/KakaoProfile.java | 19 +++ .../server/auth/model/OauthToken.java | 1 + .../auth/repository/UserRepository.java | 11 ++ .../server/auth/response/AccountResponse.java | 16 ++ .../server/auth/response/LoginResponse.java | 18 +++ .../server/auth/service/UserService.java | 118 +++++++++++++++ .../greenpoint/server/common/BaseEntity.java | 37 +++++ .../controller/CustomerController.java | 37 +++++ .../server/customer/model/Customer.java | 98 ++++++++++++ .../repository/CustomerRepository.java | 21 +++ .../customer/service/CustomerService.java | 36 +++++ .../exception/CustomerNotFoundException.java | 10 ++ .../server/exception/GlobalException.java | 19 +++ .../history/controller/HistoryController.java | 65 ++++++++ .../server/history/model/History.java | 53 +++++++ .../history/model/HistoryCntResponse.java | 23 +++ .../server/history/model/HistoryRequest.java | 18 +++ .../server/history/model/HistoryResponse.java | 41 +++++ .../history/repository/HistoryRepository.java | 30 ++++ .../history/service/HistoryService.java | 143 ++++++++++++++++++ .../level/controller/LevelController.java | 26 ++++ .../greenpoint/server/level/model/Level.java | 35 +++++ .../server/level/model/LevelRequest.java | 15 ++ .../server/level/model/LevelResponse.java | 15 ++ .../level/repository/LevelRepository.java | 11 ++ .../server/level/service/LevelService.java | 25 +++ .../menu/controller/MenuController.java | 47 ++++++ .../greenpoint/server/menu/model/Menu.java | 48 ++++++ .../server/menu/model/MenuRequest.java | 15 ++ .../menu/repository/MenuRepository.java | 14 ++ .../server/menu/service/MenuService.java | 42 +++++ .../point/controller/PointController.java | 52 +++++++ .../greenpoint/server/point/model/Point.java | 43 ++++++ .../server/point/model/PointRequest.java | 15 ++ .../point/repository/PointRepository.java | 18 +++ .../server/point/service/PointService.java | 61 ++++++++ .../store/controller/StoreController.java | 50 ++++++ .../greenpoint/server/store/model/Store.java | 78 ++++++++++ .../store/model/StoreClientResponse.java | 39 +++++ .../server/store/model/StoreRequest.java | 19 +++ .../store/repository/StoreRepository.java | 15 ++ .../server/store/service/StoreService.java | 73 +++++++++ .../controller/StoreLevelController.java | 13 ++ .../server/storeLevel/model/StoreLevel.java | 29 ++++ .../repository/StoreLevelRepository.java | 11 ++ .../storeLevel/service/StoreLevelService.java | 21 +++ src/main/resources/application.properties | 5 +- 55 files changed, 1813 insertions(+), 2 deletions(-) create mode 100644 .DS_Store create mode 100644 src/main/java/com/greenpoint/server/admin/controller/AdminController.java create mode 100644 src/main/java/com/greenpoint/server/admin/model/Admin.java create mode 100644 src/main/java/com/greenpoint/server/admin/repository/AdminRepository.java create mode 100644 src/main/java/com/greenpoint/server/admin/service/AdminService.java create mode 100644 src/main/java/com/greenpoint/server/auth/controller/UserController.java create mode 100644 src/main/java/com/greenpoint/server/auth/model/KakaoProfile.java create mode 100644 src/main/java/com/greenpoint/server/auth/model/OauthToken.java create mode 100644 src/main/java/com/greenpoint/server/auth/repository/UserRepository.java create mode 100644 src/main/java/com/greenpoint/server/auth/response/AccountResponse.java create mode 100644 src/main/java/com/greenpoint/server/auth/response/LoginResponse.java create mode 100644 src/main/java/com/greenpoint/server/auth/service/UserService.java create mode 100644 src/main/java/com/greenpoint/server/common/BaseEntity.java create mode 100644 src/main/java/com/greenpoint/server/customer/controller/CustomerController.java create mode 100644 src/main/java/com/greenpoint/server/customer/model/Customer.java create mode 100644 src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java create mode 100644 src/main/java/com/greenpoint/server/customer/service/CustomerService.java create mode 100644 src/main/java/com/greenpoint/server/exception/CustomerNotFoundException.java create mode 100644 src/main/java/com/greenpoint/server/exception/GlobalException.java create mode 100644 src/main/java/com/greenpoint/server/history/controller/HistoryController.java create mode 100644 src/main/java/com/greenpoint/server/history/model/History.java create mode 100644 src/main/java/com/greenpoint/server/history/model/HistoryCntResponse.java create mode 100644 src/main/java/com/greenpoint/server/history/model/HistoryRequest.java create mode 100644 src/main/java/com/greenpoint/server/history/model/HistoryResponse.java create mode 100644 src/main/java/com/greenpoint/server/history/repository/HistoryRepository.java create mode 100644 src/main/java/com/greenpoint/server/history/service/HistoryService.java create mode 100644 src/main/java/com/greenpoint/server/level/controller/LevelController.java create mode 100644 src/main/java/com/greenpoint/server/level/model/Level.java create mode 100644 src/main/java/com/greenpoint/server/level/model/LevelRequest.java create mode 100644 src/main/java/com/greenpoint/server/level/model/LevelResponse.java create mode 100644 src/main/java/com/greenpoint/server/level/repository/LevelRepository.java create mode 100644 src/main/java/com/greenpoint/server/level/service/LevelService.java create mode 100644 src/main/java/com/greenpoint/server/menu/controller/MenuController.java create mode 100644 src/main/java/com/greenpoint/server/menu/model/Menu.java create mode 100644 src/main/java/com/greenpoint/server/menu/model/MenuRequest.java create mode 100644 src/main/java/com/greenpoint/server/menu/repository/MenuRepository.java create mode 100644 src/main/java/com/greenpoint/server/menu/service/MenuService.java create mode 100644 src/main/java/com/greenpoint/server/point/controller/PointController.java create mode 100644 src/main/java/com/greenpoint/server/point/model/Point.java create mode 100644 src/main/java/com/greenpoint/server/point/model/PointRequest.java create mode 100644 src/main/java/com/greenpoint/server/point/repository/PointRepository.java create mode 100644 src/main/java/com/greenpoint/server/point/service/PointService.java create mode 100644 src/main/java/com/greenpoint/server/store/controller/StoreController.java create mode 100644 src/main/java/com/greenpoint/server/store/model/Store.java create mode 100644 src/main/java/com/greenpoint/server/store/model/StoreClientResponse.java create mode 100644 src/main/java/com/greenpoint/server/store/model/StoreRequest.java create mode 100644 src/main/java/com/greenpoint/server/store/repository/StoreRepository.java create mode 100644 src/main/java/com/greenpoint/server/store/service/StoreService.java create mode 100644 src/main/java/com/greenpoint/server/storeLevel/controller/StoreLevelController.java create mode 100644 src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java create mode 100644 src/main/java/com/greenpoint/server/storeLevel/repository/StoreLevelRepository.java create mode 100644 src/main/java/com/greenpoint/server/storeLevel/service/StoreLevelService.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e2bd63d68f55618736874a94d3ff2a65f5ce5ca2 GIT binary patch literal 6148 zcmeHK%Sr=55UkcH0WUdvoL}${mXLfwen8`j2nzuv_dVsi{4}c{mt_&-!HcPeo|@_D znqlg&y$!(D$Nm9W0a(%tBN>UoYD6m&%^$37`QyooO^>kj(Ed>3I7(a zc*hfZZoK^Z;Pb9mmK2ZzQa}nwfs0e1iuCgC;$E%?O93hHlLG#IXmrP}a7>I(2Zv|@ zhzo|pIFDX}*gQb&3dcl7XqHrBQmtAHOFHAN^18w?G3l_lndj8aRvn7P?Toibhjob> zrGONeDsY|4mDm3*{hR)OO43RSNP&N)fGsw=&6-cD+B$oj*V;yZq { +} diff --git a/src/main/java/com/greenpoint/server/admin/service/AdminService.java b/src/main/java/com/greenpoint/server/admin/service/AdminService.java new file mode 100644 index 0000000..4711ccb --- /dev/null +++ b/src/main/java/com/greenpoint/server/admin/service/AdminService.java @@ -0,0 +1,7 @@ +package com.greenpoint.server.admin.service; + +import org.springframework.stereotype.Service; + +@Service +public class AdminService { +} diff --git a/src/main/java/com/greenpoint/server/auth/controller/UserController.java b/src/main/java/com/greenpoint/server/auth/controller/UserController.java new file mode 100644 index 0000000..4eb2830 --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/controller/UserController.java @@ -0,0 +1,82 @@ +package com.greenpoint.server.auth.controller; + +import com.greenpoint.server.auth.response.AccountResponse; +import com.greenpoint.server.auth.response.LoginResponse; +import com.greenpoint.server.auth.service.UserService; +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.customer.repository.CustomerRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class UserController { + @Autowired + private UserService userService; + + @GetMapping("/login") + public ResponseEntity getLogin(@RequestParam("code") String code) { + + boolean isRegistered; + Object[] obArr = new Object[2]; + Customer userInfo = new Customer(); + obArr = userService.saveUser(code); + System.out.println("obArr = " + obArr); + userInfo = (Customer) obArr[0]; + isRegistered = (boolean) obArr[1]; + LoginResponse loginResponse = new LoginResponse(userInfo.getKakaoId(), userInfo.getKakaoToken(), userInfo.getNickname(), userInfo.getImage(), isRegistered); + return ResponseEntity.ok(loginResponse); + } + + @PostMapping("/makeAccount") + public ResponseEntity makeAccount(@RequestBody HashMap param) { + Boolean result; + System.out.println("param = " + param); + result = userService.getUserInfoByForm(param); + if(result == false) { + AccountResponse accountResponse = new AccountResponse(false); + return ResponseEntity.ok(accountResponse); + } + AccountResponse accountResponse = new AccountResponse(true); + return ResponseEntity.ok(accountResponse); + } + + @Transactional + @DeleteMapping("/deleteMember") + public String deleteAccount(@RequestParam("id") Long id){ + String resultCode = ""; + int result = userService.memberDelete(id); + if(result == 0){ + resultCode = "회원 탈퇴 실패"; + + } else { +// session.removeAttribute("sessionId"); + resultCode = "회원 탈퇴 성공"; + } + return resultCode; + } + +} + diff --git a/src/main/java/com/greenpoint/server/auth/model/KakaoProfile.java b/src/main/java/com/greenpoint/server/auth/model/KakaoProfile.java new file mode 100644 index 0000000..1f87c88 --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/model/KakaoProfile.java @@ -0,0 +1,19 @@ +package com.greenpoint.server.auth.model; + +import lombok.Data; + +@Data +public class KakaoProfile { + private Long id; + private Properties properties; + + + + @Data + public class Properties { + public String nickname; + public String profile_image; // 이미지 경로 필드1 + } + + +} diff --git a/src/main/java/com/greenpoint/server/auth/model/OauthToken.java b/src/main/java/com/greenpoint/server/auth/model/OauthToken.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/model/OauthToken.java @@ -0,0 +1 @@ + diff --git a/src/main/java/com/greenpoint/server/auth/repository/UserRepository.java b/src/main/java/com/greenpoint/server/auth/repository/UserRepository.java new file mode 100644 index 0000000..27d5d18 --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/repository/UserRepository.java @@ -0,0 +1,11 @@ +// +//package com.greenpoint.server.auth.repository; +// +//import com.greenpoint.server.customer.model.Customer; +//import org.springframework.data.jpa.repository.JpaRepository; +// +//public interface UserRepository extends JpaRepository { +// +// +//} + diff --git a/src/main/java/com/greenpoint/server/auth/response/AccountResponse.java b/src/main/java/com/greenpoint/server/auth/response/AccountResponse.java new file mode 100644 index 0000000..5df35d2 --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/response/AccountResponse.java @@ -0,0 +1,16 @@ +package com.greenpoint.server.auth.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class AccountResponse { +// private String nickname; +// private String contact; + private boolean isRegistered; +} diff --git a/src/main/java/com/greenpoint/server/auth/response/LoginResponse.java b/src/main/java/com/greenpoint/server/auth/response/LoginResponse.java new file mode 100644 index 0000000..484bdd8 --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/response/LoginResponse.java @@ -0,0 +1,18 @@ +package com.greenpoint.server.auth.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class LoginResponse { + private Long kakaoId; + private String token; + private String nickname; + private String image; + private boolean isRegistered; +} diff --git a/src/main/java/com/greenpoint/server/auth/service/UserService.java b/src/main/java/com/greenpoint/server/auth/service/UserService.java new file mode 100644 index 0000000..571c8bc --- /dev/null +++ b/src/main/java/com/greenpoint/server/auth/service/UserService.java @@ -0,0 +1,118 @@ +package com.greenpoint.server.auth.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.greenpoint.server.auth.model.KakaoProfile; +import com.greenpoint.server.auth.model.KakaoProfile; +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.customer.repository.CustomerRepository; +import com.greenpoint.server.level.service.LevelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.sql.SQLOutput; + +import javax.servlet.http.HttpSession; +import java.sql.SQLOutput; +import java.util.HashMap; + +@Service +public class UserService { + @Autowired + private CustomerRepository customerRepository; + @Autowired + private LevelService levelService; + public Object[] saveUser(String token) { + + Object[] obArr = new Object[2]; + String name = null; + String imageUrl = null; + Long id = null; + + String userInfo = getUserInfoByAccessToken(token); + ObjectMapper objectMapper = new ObjectMapper(); + try { + JsonNode jsonNode = objectMapper.readTree(userInfo); + System.out.println(jsonNode); + id = Long.valueOf(String.valueOf(jsonNode.get("id"))); + System.out.println("id = " + id); + name = String.valueOf(jsonNode.get("kakao_account").get("profile").get("nickname")); + imageUrl = String.valueOf(jsonNode.get("kakao_account").get("profile").get("profile_image_url")); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + System.out.println("userInfo" + userInfo); + + Customer user; + + user = customerRepository.findByKakaoId(id); + System.out.println("user = " + user); + if(user == null) { + Customer newUser = Customer.from(id, token, name.substring(1, name.length() - 1), imageUrl.substring(1, imageUrl.length() - 1)); + obArr[0] = newUser; + obArr[1] = false; + customerRepository.save(newUser); + return obArr; + } + + obArr[0] = user; + obArr[1] = true; + return obArr; + } + + + public String getUserInfoByAccessToken(String accessToken) { + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", "Bearer " + accessToken); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + + LinkedMultiValueMap params = new LinkedMultiValueMap<>(); + + HttpEntity> request = new HttpEntity<>(params, headers); + + String url = "https://kapi.kakao.com/v2/user/me"; + + return restTemplate.postForObject(url, request, String.class); + } + public Boolean getUserInfoByForm(HashMap param) { + Customer user; + + Long id = Long.valueOf(param.get("id")); + System.out.println("id = " + id); + try{ + user = customerRepository.findByKakaoId(id); + user.setContact(param.get("contact")); + user.setNickname(param.get("nickname")); + user.setLatitude(Double.valueOf(param.get("latitude"))); + user.setLongitude(Double.valueOf(param.get("longitude"))); + user.setPoint(0); + user.setTotalPoint(0); + user.setLevel(levelService.findByGrade(1)); +// user = Customer.from(param.get("nickname"), param.get("contact")); + user = customerRepository.save(user); + if(user == null){ + return false; + } + } + catch(Exception e){ + System.out.println("토큰이 다름!"); + return false; + } + + return true; + } + + + public int memberDelete(Long id) { + int result = customerRepository.deleteByKakaoId(id); + return result; + } + +} diff --git a/src/main/java/com/greenpoint/server/common/BaseEntity.java b/src/main/java/com/greenpoint/server/common/BaseEntity.java new file mode 100644 index 0000000..800c768 --- /dev/null +++ b/src/main/java/com/greenpoint/server/common/BaseEntity.java @@ -0,0 +1,37 @@ +package com.greenpoint.server.common; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.*; +import javax.persistence.MappedSuperclass; +import java.time.LocalDateTime; + + +@EntityListeners(AuditingEntityListener.class) +@MappedSuperclass +@NoArgsConstructor +@Getter +public abstract class BaseEntity { + + @CreatedDate + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") + @Column(updatable = false) + private LocalDateTime created_at; + + @LastModifiedDate + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") + private LocalDateTime updated_at; + + private boolean deleted = Boolean.FALSE; + + public void deleteContent(){deleted = true;} + + +} diff --git a/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java b/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java new file mode 100644 index 0000000..07c5239 --- /dev/null +++ b/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java @@ -0,0 +1,37 @@ +package com.greenpoint.server.customer.controller; + +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.customer.service.CustomerService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class CustomerController { + + @Autowired + private CustomerService customerService; + @GetMapping("/readCustomer") + public ResponseEntity readCustomer(@RequestParam("id") Long id) { + + Customer customer; + customer = customerService.findByKakaoId(id); + return ResponseEntity.ok(customer); + + } + @GetMapping("/readCustomerByNum") + public ResponseEntity readCustomerByNum(@RequestParam("contact") String contact) { + Customer customer; + customer = customerService.findByContact(contact); + return ResponseEntity.ok(customer); + } +} diff --git a/src/main/java/com/greenpoint/server/customer/model/Customer.java b/src/main/java/com/greenpoint/server/customer/model/Customer.java new file mode 100644 index 0000000..80cfed2 --- /dev/null +++ b/src/main/java/com/greenpoint/server/customer/model/Customer.java @@ -0,0 +1,98 @@ +package com.greenpoint.server.customer.model; + + +import com.greenpoint.server.common.BaseEntity; +import com.greenpoint.server.level.model.Level; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.*; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +//@SQLDelete(sql = "UPDATE customer SET deleted = true Where id = ?") +public class Customer extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(unique = true) + private Long kakaoId; + + @Column(unique = true) + private String kakaoToken; + + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) + private Level level; + + private String contact; + private String image; + private String nickname; + private double latitude; + private double longitude; + private int point; + private int totalPoint; + + public void insertUserToken(String token){ + this.kakaoToken = token; + } + + + public int addpoint(int savedPoint) { + this.point = this.point + savedPoint; + this.totalPoint = this.totalPoint + savedPoint; + int grade; + if(this.totalPoint >= 1000000) grade = 3; + else if(this.totalPoint >= 100000) grade = 2; + else grade = 1; + return grade; + } + + public void usepoint(int usedPoint) { + this.point = this.point - usedPoint; + } + + public void insertUser(String token, String nickname, String image) { + this.kakaoToken = token; + this.nickname = nickname; + this.image = image; + } + public void insertUser(String token) { + this.kakaoToken = token; + } + + public static Customer from (String token, String nickname, String image) { + return Customer.builder() + .kakaoToken(token) + .nickname(nickname) + .image(image) + .build(); + } + public static Customer from (Long id, String token, String nickname, String image) { + return Customer.builder() + .kakaoId(id) + .kakaoToken(token) + .nickname(nickname) + .image(image) + .build(); + } + public static Customer from (String nickname , String contact) { + return Customer.builder() + .nickname(nickname) + .contact(contact) + .build(); + } + + + public void upgrade(Level level) { + this.level = level; + } +} diff --git a/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java b/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java new file mode 100644 index 0000000..34fee24 --- /dev/null +++ b/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java @@ -0,0 +1,21 @@ +package com.greenpoint.server.customer.repository; + + +import com.greenpoint.server.customer.model.Customer; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +public interface CustomerRepository extends JpaRepository { + public Customer findByKakaoToken(String kakaoToken); + +// @Query("delete from Customer as c where c.kakaoId= :kakao_id") + public int deleteByKakaoId(Long kakaoId); + +// @Query("select m from Customer as m where m.kakaoToken = :kakaoToken") +// public Customer findByToken(String kakaoToken); + +// @Query("select m from Customer as m where m.contact = :contact") + public Customer findByContact(String contact); + + public Customer findByKakaoId(Long id); +} diff --git a/src/main/java/com/greenpoint/server/customer/service/CustomerService.java b/src/main/java/com/greenpoint/server/customer/service/CustomerService.java new file mode 100644 index 0000000..6f9071c --- /dev/null +++ b/src/main/java/com/greenpoint/server/customer/service/CustomerService.java @@ -0,0 +1,36 @@ +package com.greenpoint.server.customer.service; + +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.customer.repository.CustomerRepository; +import com.greenpoint.server.exception.CustomerNotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class CustomerService { + + + @Autowired + private CustomerRepository customerRepository; + + @Transactional + public Customer findById(Long id) { +// Customer ret = customerRepository.findById(id).orElseThrow(CustomerNotFoundException::new); + Customer ret = customerRepository.findById(id).get(); + return ret; + } + + @Transactional + public Customer findByKakaoId(Long kakaoId) { + Customer customer = customerRepository.findByKakaoId(kakaoId); + return customer; + } + + @Transactional + public Customer findByContact(String contact) { + Customer customer = customerRepository.findByContact(contact); + return customer; + } + +} diff --git a/src/main/java/com/greenpoint/server/exception/CustomerNotFoundException.java b/src/main/java/com/greenpoint/server/exception/CustomerNotFoundException.java new file mode 100644 index 0000000..ff81bb2 --- /dev/null +++ b/src/main/java/com/greenpoint/server/exception/CustomerNotFoundException.java @@ -0,0 +1,10 @@ +package com.greenpoint.server.exception; + +import org.springframework.http.HttpStatus; + +public class CustomerNotFoundException extends GlobalException { + public CustomerNotFoundException() { + super("존재하지 않는 유저입니다.", HttpStatus.BAD_REQUEST); + } +} + diff --git a/src/main/java/com/greenpoint/server/exception/GlobalException.java b/src/main/java/com/greenpoint/server/exception/GlobalException.java new file mode 100644 index 0000000..592995d --- /dev/null +++ b/src/main/java/com/greenpoint/server/exception/GlobalException.java @@ -0,0 +1,19 @@ +package com.greenpoint.server.exception; + + +import lombok.NoArgsConstructor; +import org.springframework.http.HttpStatus; + +public class GlobalException extends RuntimeException { + + private final HttpStatus httpStatus; + + + public GlobalException(String message, HttpStatus httpStatus) { + super(message); + this.httpStatus = httpStatus; + } + public HttpStatus getHttpStatus() { + return httpStatus; + } +} diff --git a/src/main/java/com/greenpoint/server/history/controller/HistoryController.java b/src/main/java/com/greenpoint/server/history/controller/HistoryController.java new file mode 100644 index 0000000..1f98f8b --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/controller/HistoryController.java @@ -0,0 +1,65 @@ +package com.greenpoint.server.history.controller; +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.customer.service.CustomerService; +import com.greenpoint.server.history.model.History; +import com.greenpoint.server.history.model.HistoryRequest; +import com.greenpoint.server.history.model.HistoryResponse; +import com.greenpoint.server.history.service.HistoryService; +import com.greenpoint.server.store.model.Store; +import com.greenpoint.server.store.service.StoreService; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.text.ParseException; +import java.util.List; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class HistoryController { + + @Autowired + private HistoryService historyService; + @Autowired + private StoreService storeService; + @Autowired + private CustomerService customerService; + + @GetMapping(value = "/history/{cid}") + public ResponseEntity> findAllById(@PathVariable Long cid){ + List res = historyService.findAllById(cid); + return ResponseEntity.ok(res); + } + + @PostMapping(value="/history") + public ResponseEntity addHistory(@RequestBody HistoryRequest request){ + Customer customer = customerService.findById(request.getCustomerId()); + Store store = storeService.findById(request.getStoreId()); + Long res = historyService.create(History.from(store, request), customer); + return ResponseEntity.ok(res); + } + @GetMapping(value="/dailyHistory") + public int[] readDailyHistory(@RequestParam("customerId") Long customerId) throws ParseException { + int[] arr = historyService.findDailyHistory(customerId); + return arr; + } + + @GetMapping(value="/history/three/{cid}") + public ResponseEntity> findThreeByCID(@PathVariable Long cid){ + List res = historyService.findThreeByCID(cid); + return ResponseEntity.ok(res); + } + + +// @GetMapping(value="/dailyHistory") +// public List readDailyHistory(@RequestParam("customerId") Long customerId){ +// List histories = historyService.findDailyHistory(customerId); +// return histories; +// } + + +} diff --git a/src/main/java/com/greenpoint/server/history/model/History.java b/src/main/java/com/greenpoint/server/history/model/History.java new file mode 100644 index 0000000..e8d1559 --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/model/History.java @@ -0,0 +1,53 @@ +package com.greenpoint.server.history.model; + + +import com.greenpoint.server.common.BaseEntity; +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.customer.service.CustomerService; +import com.greenpoint.server.store.model.Store; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +@SQLDelete(sql = "UPDATE history SET deleted = true Where id = ?") +public class History extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private Long customerId; + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) + private Store store; + + private int cost; + private int currentPoint; + private int savedPoint; + private int usedPoint; + + + public static History from(Store store, HistoryRequest request){ + return History.builder() + .customerId(request.getCustomerId()) + .store(store) + .cost(request.getCost()) + .savedPoint(request.getSavedPoint()) + .usedPoint(request.getUsedPoint()) + .build(); + } + + public void pointCheck(Customer customer){ + this.currentPoint = customer.getPoint(); + } + + +} diff --git a/src/main/java/com/greenpoint/server/history/model/HistoryCntResponse.java b/src/main/java/com/greenpoint/server/history/model/HistoryCntResponse.java new file mode 100644 index 0000000..5522d86 --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/model/HistoryCntResponse.java @@ -0,0 +1,23 @@ +package com.greenpoint.server.history.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HistoryCntResponse { + Integer dayCnt; + + public static HistoryCntResponse from(Integer cnt){ + return HistoryCntResponse.builder() + .dayCnt(cnt) + .build(); + + } +} + + diff --git a/src/main/java/com/greenpoint/server/history/model/HistoryRequest.java b/src/main/java/com/greenpoint/server/history/model/HistoryRequest.java new file mode 100644 index 0000000..6487b6e --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/model/HistoryRequest.java @@ -0,0 +1,18 @@ +package com.greenpoint.server.history.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class HistoryRequest { + private Long customerId; + private Long storeId; + private int cost; + private int savedPoint; + private int usedPoint; +} diff --git a/src/main/java/com/greenpoint/server/history/model/HistoryResponse.java b/src/main/java/com/greenpoint/server/history/model/HistoryResponse.java new file mode 100644 index 0000000..a46b91b --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/model/HistoryResponse.java @@ -0,0 +1,41 @@ +package com.greenpoint.server.history.model; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HistoryResponse { + + private String storeName; + private int savedPoint; + private int usedPoint; + private int currentPoint; + private String image; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") + private LocalDateTime created_at; + + + + public static HistoryResponse from(History history){ + return HistoryResponse.builder() + .storeName(history.getStore().getName()) + .savedPoint(history.getSavedPoint()) + .usedPoint(history.getUsedPoint()) + .currentPoint(history.getCurrentPoint()) + .image(history.getStore().getImage()) + .created_at(history.getCreated_at()) + .build(); + } + +} diff --git a/src/main/java/com/greenpoint/server/history/repository/HistoryRepository.java b/src/main/java/com/greenpoint/server/history/repository/HistoryRepository.java new file mode 100644 index 0000000..6a59e6e --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/repository/HistoryRepository.java @@ -0,0 +1,30 @@ +package com.greenpoint.server.history.repository; + + +import com.greenpoint.server.history.model.History; +import com.greenpoint.server.history.model.HistoryResponse; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public interface HistoryRepository extends JpaRepository { + + @Query("select h from History h where h.customerId = :cid") + List findAllById(Long cid); + + + @Query(nativeQuery = true, value="SELECT DATE(created_at) FROM history where customer_id = :customerId GROUP BY DATE(created_at) order by DATE(created_at) desc limit 1") + String findMaxDate(Long customerId); + + @Query(nativeQuery= true, value ="SELECT DATE(created_at) FROM history where not created_at is Null and customer_id = :customerId GROUP BY DATE(created_at) order by DATE(created_at) limit 1") + String findMinDate(Long customerId); + + @Query(nativeQuery = true, value="SELECT DATE(created_at) ,COUNT(Id) FROM history where Date(created_at) is not null and customer_id = :customerId GROUP BY DATE(created_at) order by DATE(created_at)") +// List findExistDate(Long customerId); + List findExistDate(Long customerId); +} diff --git a/src/main/java/com/greenpoint/server/history/service/HistoryService.java b/src/main/java/com/greenpoint/server/history/service/HistoryService.java new file mode 100644 index 0000000..67a8be6 --- /dev/null +++ b/src/main/java/com/greenpoint/server/history/service/HistoryService.java @@ -0,0 +1,143 @@ +package com.greenpoint.server.history.service; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.greenpoint.server.customer.model.Customer; +import com.greenpoint.server.history.model.History; +import com.greenpoint.server.history.model.HistoryCntResponse; +import com.greenpoint.server.history.model.HistoryResponse; +import com.greenpoint.server.history.repository.HistoryRepository; +import com.greenpoint.server.level.model.Level; +import com.greenpoint.server.level.service.LevelService; +import com.greenpoint.server.storeLevel.model.StoreLevel; +import com.greenpoint.server.storeLevel.service.StoreLevelService; +import com.sun.org.apache.xpath.internal.operations.Mult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import java.util.List; +import java.util.stream.Collectors; +import java.util.Map.Entry; + +@Service +public class HistoryService { + + @Autowired + private HistoryRepository historyRepository; + + @Autowired + private LevelService levelService; + + @Autowired + private StoreLevelService storeLevelService; + + @PersistenceContext + private EntityManager em; + + + + + @Transactional + public Long create(History history, Customer customer){ + History res = historyRepository.save(history); + + int grade = customer.getLevel().getGrade(); + customer.usepoint(history.getUsedPoint()); + int newgrade = customer.addpoint(history.getSavedPoint()); + if(newgrade > grade){ + Level level = levelService.findByGrade(newgrade); + customer.upgrade(level); + } + res.pointCheck(customer); + + int before = res.getStore().getStoreLevel().getGrade(); + int after = res.getStore().pointUp(history.getSavedPoint()); + if(after > before) { + StoreLevel level = storeLevelService.findByGrade(after); + history.getStore().gradeChange(level); + } + return res.getId(); + } + + + @Transactional + public List findAllById(Long customerId) { + List histories = historyRepository.findAllById(customerId); + return histories.stream().map(HistoryResponse::from).collect(Collectors.toList()); + } + + @Transactional + public int[] findDailyHistory(Long customerId) throws ParseException { + String maxDate = historyRepository.findMaxDate(customerId); + String minDate = historyRepository.findMinDate(customerId); + List existDate = historyRepository.findExistDate(customerId); + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + Date max_date = formatter.parse(maxDate); + System.out.println("max_date = " + max_date); + Date min_date = formatter.parse(minDate); + System.out.println("min_date = " + min_date); + long diffSec = (max_date.getTime() - min_date.getTime()) / 1000; + long diffDays = diffSec / (24*60*60); // 일자수 차이 + System.out.println("diffDays = " + diffDays); + + Map existDateList = new HashMap<>(); + for(String value : existDate){ + String[] temp = value.split(","); + Date temp_date = formatter.parse(temp[0]); + Integer point = Integer.valueOf(temp[1]); + existDateList.put(temp_date, point); + } + for (Entry entrySet : existDateList.entrySet()) { + System.out.println(entrySet.getKey() + " : " + entrySet.getValue()); + } + + Calendar cal1 = Calendar.getInstance(); + cal1.setTime(min_date); // 시간 설정 + int[] arr = new int[(int)diffDays+1]; + + if(existDateList.containsKey(min_date)) { + arr[0] = existDateList.get(min_date); + } + for(int i=1; i findThreeByCID(Long cid) { + List histories = em.createQuery("select h from History h where h.customerId = " + cid + " and h.savedPoint != " + 0 + " order by h.created_at desc").setMaxResults(3).getResultList(); + return histories.stream().map(HistoryResponse::from).collect(Collectors.toList()); + } + + +// @Transactional +// public List findDailyHistory(Long customerId) { +// List histories = historyRepository.findDailyHistory(customerId); +// System.out.println("histories = " + histories); +// return histories; +// } + +} diff --git a/src/main/java/com/greenpoint/server/level/controller/LevelController.java b/src/main/java/com/greenpoint/server/level/controller/LevelController.java new file mode 100644 index 0000000..78d5a7d --- /dev/null +++ b/src/main/java/com/greenpoint/server/level/controller/LevelController.java @@ -0,0 +1,26 @@ +package com.greenpoint.server.level.controller; + +import com.greenpoint.server.level.model.Level; +import com.greenpoint.server.level.model.LevelRequest; +import com.greenpoint.server.level.service.LevelService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class LevelController { + + @Autowired + private LevelService levelService; + + @PostMapping(value="/level") + public ResponseEntity create(@RequestBody LevelRequest request){ + Level res = levelService.create(Level.from(request)); + return ResponseEntity.ok(res); + } + +} diff --git a/src/main/java/com/greenpoint/server/level/model/Level.java b/src/main/java/com/greenpoint/server/level/model/Level.java new file mode 100644 index 0000000..014b0bd --- /dev/null +++ b/src/main/java/com/greenpoint/server/level/model/Level.java @@ -0,0 +1,35 @@ +package com.greenpoint.server.level.model; + +import com.greenpoint.server.common.BaseEntity; +import com.greenpoint.server.customer.model.Customer; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.*; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +@SQLDelete(sql = "UPDATE level SET deleted = true Where id = ?") +public class Level extends BaseEntity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private int grade; + private String name; + private String image; + + public static Level from(LevelRequest request) { + return Level.builder() + .grade(request.getGrade()) + .name(request.getName()) + .image(request.getImage()) + .build(); + } +} diff --git a/src/main/java/com/greenpoint/server/level/model/LevelRequest.java b/src/main/java/com/greenpoint/server/level/model/LevelRequest.java new file mode 100644 index 0000000..e890f3d --- /dev/null +++ b/src/main/java/com/greenpoint/server/level/model/LevelRequest.java @@ -0,0 +1,15 @@ +package com.greenpoint.server.level.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class LevelRequest { + private int grade; + public String name; + public String image; +} diff --git a/src/main/java/com/greenpoint/server/level/model/LevelResponse.java b/src/main/java/com/greenpoint/server/level/model/LevelResponse.java new file mode 100644 index 0000000..5f20e5a --- /dev/null +++ b/src/main/java/com/greenpoint/server/level/model/LevelResponse.java @@ -0,0 +1,15 @@ +package com.greenpoint.server.level.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class LevelResponse { + private Long id; + private int grade; + private String name; + private String image; +} diff --git a/src/main/java/com/greenpoint/server/level/repository/LevelRepository.java b/src/main/java/com/greenpoint/server/level/repository/LevelRepository.java new file mode 100644 index 0000000..578379d --- /dev/null +++ b/src/main/java/com/greenpoint/server/level/repository/LevelRepository.java @@ -0,0 +1,11 @@ +package com.greenpoint.server.level.repository; + + +import com.greenpoint.server.level.model.Level; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +public interface LevelRepository extends JpaRepository { + @Query("select l from Level l where l.grade = :newgrade") + Level findByGrade(int newgrade); +} diff --git a/src/main/java/com/greenpoint/server/level/service/LevelService.java b/src/main/java/com/greenpoint/server/level/service/LevelService.java new file mode 100644 index 0000000..7811cfd --- /dev/null +++ b/src/main/java/com/greenpoint/server/level/service/LevelService.java @@ -0,0 +1,25 @@ +package com.greenpoint.server.level.service; + +import com.greenpoint.server.level.model.Level; +import com.greenpoint.server.level.repository.LevelRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class LevelService { + + @Autowired + private LevelRepository levelRepository; + + @Transactional + public Level create(Level level){ + Level ret = levelRepository.save(level); + return ret; + } + + public Level findByGrade(int newgrade) { + Level ret = levelRepository.findByGrade(newgrade); + return ret; + } +} diff --git a/src/main/java/com/greenpoint/server/menu/controller/MenuController.java b/src/main/java/com/greenpoint/server/menu/controller/MenuController.java new file mode 100644 index 0000000..9898e00 --- /dev/null +++ b/src/main/java/com/greenpoint/server/menu/controller/MenuController.java @@ -0,0 +1,47 @@ +package com.greenpoint.server.menu.controller; + +import com.greenpoint.server.menu.model.Menu; +import com.greenpoint.server.menu.model.MenuRequest; +import com.greenpoint.server.menu.service.MenuService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class MenuController { + + @Autowired + private MenuService menuService; + + + @GetMapping("/menu/{sid}") + public ResponseEntity> findByStoreId(@PathVariable Long sid){ + List res = menuService.findByStoreId(sid); + return ResponseEntity.ok(res); + } + + @PostMapping("/menu/{sid}") + public ResponseEntity create(@PathVariable Long sid, @RequestBody MenuRequest request){ + Menu res = menuService.create(Menu.from(sid, request)); + return ResponseEntity.ok(res); + } + + @PatchMapping("/menu/{mid}") + public ResponseEntity update(@PathVariable Long mid, @RequestBody MenuRequest request){ + Menu res = menuService.update(mid, request); + return ResponseEntity.ok(res); + } + + @DeleteMapping("/menu/{mid}") + public void delete(@PathVariable Long mid){ + menuService.delete(mid); + } + + +} diff --git a/src/main/java/com/greenpoint/server/menu/model/Menu.java b/src/main/java/com/greenpoint/server/menu/model/Menu.java new file mode 100644 index 0000000..42f1c2f --- /dev/null +++ b/src/main/java/com/greenpoint/server/menu/model/Menu.java @@ -0,0 +1,48 @@ +package com.greenpoint.server.menu.model; + +import com.greenpoint.server.common.BaseEntity; +import com.greenpoint.server.store.model.Store; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.*; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +@SQLDelete(sql = "UPDATE menu SET deleted = true Where id = ?") +public class Menu extends BaseEntity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + +// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) +// private Store store; + + private Long storeId; + private String name; + private String image; + private int price; + + + public static Menu from(Long sid, MenuRequest request){ + return Menu.builder() + .storeId(sid) + .name(request.getName()) + .image(request.getImage()) + .price( request.getPrice()) + .build(); + } + + public void update(MenuRequest request) { + this.name = request.getName(); + this.price = request.getPrice(); + this.image = request.getImage(); + } +} diff --git a/src/main/java/com/greenpoint/server/menu/model/MenuRequest.java b/src/main/java/com/greenpoint/server/menu/model/MenuRequest.java new file mode 100644 index 0000000..4ef4a95 --- /dev/null +++ b/src/main/java/com/greenpoint/server/menu/model/MenuRequest.java @@ -0,0 +1,15 @@ +package com.greenpoint.server.menu.model; + + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class MenuRequest { + private String name; + private String image; + private int price; +} diff --git a/src/main/java/com/greenpoint/server/menu/repository/MenuRepository.java b/src/main/java/com/greenpoint/server/menu/repository/MenuRepository.java new file mode 100644 index 0000000..16831a3 --- /dev/null +++ b/src/main/java/com/greenpoint/server/menu/repository/MenuRepository.java @@ -0,0 +1,14 @@ +package com.greenpoint.server.menu.repository; + + +import com.greenpoint.server.menu.model.Menu; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface MenuRepository extends JpaRepository { + + @Query("select m from Menu m where m.storeId = :sid") + List findByStoreId(Long sid); +} diff --git a/src/main/java/com/greenpoint/server/menu/service/MenuService.java b/src/main/java/com/greenpoint/server/menu/service/MenuService.java new file mode 100644 index 0000000..3b6edbe --- /dev/null +++ b/src/main/java/com/greenpoint/server/menu/service/MenuService.java @@ -0,0 +1,42 @@ +package com.greenpoint.server.menu.service; + +import com.greenpoint.server.menu.model.Menu; +import com.greenpoint.server.menu.model.MenuRequest; +import com.greenpoint.server.menu.repository.MenuRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +public class MenuService { + + @Autowired + private MenuRepository menuRepository; + + + @Transactional + public void delete(Long menuid) { + menuRepository.deleteById(menuid); + } + + @Transactional + public Menu update(Long menuid, MenuRequest request) { + Menu menu = menuRepository.findById(menuid).get(); + menu.update(request); + return menu; + } + + @Transactional + public Menu create(Menu from) { + Menu ret = menuRepository.save(from); + return ret; + } + + @Transactional(readOnly = true) + public List findByStoreId(Long storeid) { + List ret = menuRepository.findByStoreId(storeid); + return ret; + } +} diff --git a/src/main/java/com/greenpoint/server/point/controller/PointController.java b/src/main/java/com/greenpoint/server/point/controller/PointController.java new file mode 100644 index 0000000..029d30d --- /dev/null +++ b/src/main/java/com/greenpoint/server/point/controller/PointController.java @@ -0,0 +1,52 @@ +package com.greenpoint.server.point.controller; + +import com.greenpoint.server.point.model.Point; +import com.greenpoint.server.point.model.PointRequest; +import com.greenpoint.server.point.service.PointService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +//import javax.xml.ws.Response; +import java.util.List; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class PointController { + + @Autowired + private PointService pointService; + + @GetMapping(value = "/point") + public ResponseEntity> findAll(){ + return ResponseEntity.ok(pointService.findAll()); + } + + @GetMapping(value = "/point/{sid}") + public ResponseEntity> findAllByStore(@PathVariable Long sid){ + List res = pointService.findAllByStore(sid); + return ResponseEntity.ok(pointService.findAll()); + } + + @PostMapping(value="/point") + public ResponseEntity create(@RequestBody PointRequest request){ + Long res = pointService.create(Point.from(request)); + return ResponseEntity.ok(res); + } + + @PatchMapping(value = "/point/{id}") + public ResponseEntity update(@PathVariable Long id, @RequestBody PointRequest request){ + Point res = pointService.update(id, request); + return ResponseEntity.ok(res); + } + + @DeleteMapping(value = "/point/{id}") + public void delete(@PathVariable Long id){ + pointService.delete(id); + } + + +} diff --git a/src/main/java/com/greenpoint/server/point/model/Point.java b/src/main/java/com/greenpoint/server/point/model/Point.java new file mode 100644 index 0000000..c1353b4 --- /dev/null +++ b/src/main/java/com/greenpoint/server/point/model/Point.java @@ -0,0 +1,43 @@ +package com.greenpoint.server.point.model; + +import com.greenpoint.server.common.BaseEntity; +import com.greenpoint.server.store.model.Store; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.*; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +@SQLDelete(sql = "UPDATE point SET deleted = true Where id = ?") +public class Point extends BaseEntity{ + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + +// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) +// private Store store; + private Long storeId; + private String name; + private int weight; + + public static Point from(PointRequest request){ + return Point.builder() + .storeId(request.getStoreId()) + .name(request.getName()) + .weight(request.getWeight()) + .build(); + } + + public void update(PointRequest request) { + this.name = request.getName(); + this.weight = request.getWeight(); + } +} diff --git a/src/main/java/com/greenpoint/server/point/model/PointRequest.java b/src/main/java/com/greenpoint/server/point/model/PointRequest.java new file mode 100644 index 0000000..7474421 --- /dev/null +++ b/src/main/java/com/greenpoint/server/point/model/PointRequest.java @@ -0,0 +1,15 @@ +package com.greenpoint.server.point.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class PointRequest { + private Long storeId; + private String name; + private int weight; +} diff --git a/src/main/java/com/greenpoint/server/point/repository/PointRepository.java b/src/main/java/com/greenpoint/server/point/repository/PointRepository.java new file mode 100644 index 0000000..7ebde9e --- /dev/null +++ b/src/main/java/com/greenpoint/server/point/repository/PointRepository.java @@ -0,0 +1,18 @@ +package com.greenpoint.server.point.repository; + + +import com.greenpoint.server.point.model.Point; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface PointRepository extends JpaRepository { + @Query("select p from Point p where p.storeId = :sid") + List findAllByStore(Long sid); + + @Query("select sum(p.weight) from Point p where p.storeId = :sid group by p.storeId") + int findMaxPointByStore(Long sid); +} diff --git a/src/main/java/com/greenpoint/server/point/service/PointService.java b/src/main/java/com/greenpoint/server/point/service/PointService.java new file mode 100644 index 0000000..250f751 --- /dev/null +++ b/src/main/java/com/greenpoint/server/point/service/PointService.java @@ -0,0 +1,61 @@ +package com.greenpoint.server.point.service; + +import com.greenpoint.server.point.model.Point; +import com.greenpoint.server.point.model.PointRequest; +import com.greenpoint.server.point.repository.PointRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +public class PointService { + + @Autowired + private PointRepository pointRepository; + + private Point findOne(Long id){ + return pointRepository.findById(id).get(); + } + + @Transactional + public Point update(Long id, PointRequest request) { + Point res = pointRepository.findById(id).get(); + res.update(request); + return res; + } + @Transactional + public Long create(Point point){ + pointRepository.save(point); + return point.getId(); + } + @Transactional(readOnly = true) + public List findAll() { + return pointRepository.findAll(); + } + + @Transactional + public void delete(Long id) { + pointRepository.delete(this.findOne(id)); + } + + @Transactional(readOnly = true) + public List findAllByStore(Long storeid) { + List res = pointRepository.findAllByStore(storeid); + return res; + } + + + public int findMaxPointByStore(Long storeid) { + int ret = 0; + try{ + ret = pointRepository.findMaxPointByStore(storeid); + } + catch(Exception e){ + ret = 0; + return ret; + } + return ret; + } +} diff --git a/src/main/java/com/greenpoint/server/store/controller/StoreController.java b/src/main/java/com/greenpoint/server/store/controller/StoreController.java new file mode 100644 index 0000000..afa58a3 --- /dev/null +++ b/src/main/java/com/greenpoint/server/store/controller/StoreController.java @@ -0,0 +1,50 @@ +package com.greenpoint.server.store.controller; + +import com.greenpoint.server.store.model.Store; +import com.greenpoint.server.store.model.StoreClientResponse; +import com.greenpoint.server.store.model.StoreRequest; +import com.greenpoint.server.store.service.StoreService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +//import javax.xml.ws.Response; +import java.util.List; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class StoreController { + + @Autowired + private StoreService storeService; + + @GetMapping(value="/store") + public ResponseEntity> findAll(){ + List res = storeService.findAll(); + return ResponseEntity.ok(res); + } + @GetMapping(value="/store/{id}") + public ResponseEntity findById(@PathVariable Long id){ + Store res = storeService.findById(id); + return ResponseEntity.ok(res); + } + + @PostMapping(value="/store") + public ResponseEntity create(@RequestBody StoreRequest request){ + Store res = storeService.create(Store.from(request)); + return ResponseEntity.ok(res); + } + @PatchMapping(value="/store/{sid}") + public ResponseEntity update(@PathVariable Long sid, @RequestBody StoreRequest request){ + Store res = storeService.update(sid, request); + return ResponseEntity.ok(res); + } + @DeleteMapping(value="/store/{sid}") + public void delete(@PathVariable Long sid){ + storeService.delete(sid); + } + +} diff --git a/src/main/java/com/greenpoint/server/store/model/Store.java b/src/main/java/com/greenpoint/server/store/model/Store.java new file mode 100644 index 0000000..cd5d0ea --- /dev/null +++ b/src/main/java/com/greenpoint/server/store/model/Store.java @@ -0,0 +1,78 @@ +package com.greenpoint.server.store.model; + + +import com.greenpoint.server.common.BaseEntity; +import com.greenpoint.server.history.model.History; +import com.greenpoint.server.menu.model.Menu; +import com.greenpoint.server.point.model.Point; +import com.greenpoint.server.storeLevel.model.StoreLevel; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +@SQLDelete(sql = "UPDATE store SET deleted = true Where id = ?") +public class Store extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String loginID; + private String password; + private String category; + private String name; + private String image; + private double latitude; + private double longitude; + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) + private StoreLevel storeLevel; + private int totalPoint; + + + public static Store from(StoreRequest request){ + return Store.builder() + .loginID(request.getLoginID()) + .password(request.getPassword()) + .category(request.getCategory()) + .name(request.getName()) + .image(request.getImage()) + .latitude(request.getLatitude()) + .longitude(request.getLongitude()) + .totalPoint(request.getTotalPoint()) + .build(); + } + + + public void update(StoreRequest request) { + this.category = request.getCategory(); + this.image = request.getImage(); + this.loginID = request.getLoginID(); + this.name = request.getName(); + this.password = request.getPassword(); + this.latitude = request.getLatitude(); + this.longitude = request.getLongitude(); + } + public int pointUp(int n){ + this.totalPoint = this.totalPoint + n; + int ret = 0; + if(this.totalPoint >= 1000000) ret = 3; + else if(this.totalPoint >= 100000) ret = 2; + else ret = 1; + return ret; + } + + public void gradeChange(StoreLevel level) { + this.storeLevel = level; + } +} diff --git a/src/main/java/com/greenpoint/server/store/model/StoreClientResponse.java b/src/main/java/com/greenpoint/server/store/model/StoreClientResponse.java new file mode 100644 index 0000000..a1bda42 --- /dev/null +++ b/src/main/java/com/greenpoint/server/store/model/StoreClientResponse.java @@ -0,0 +1,39 @@ +package com.greenpoint.server.store.model; + +import com.greenpoint.server.point.service.PointService; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StoreClientResponse { + + + private Long storeId; + private String category; + private String name; + private String image; + private double latitude; + private double longitude; + private int maximumPoint; + + public static StoreClientResponse from(Store store){ + return StoreClientResponse.builder() + .storeId(store.getId()) + .category(store.getCategory()) + .name(store.getName()) + .image(store.getImage()) + .latitude(store.getLatitude()) + .longitude(store.getLongitude()) + .build(); + } + public void maxp(int n){ + this.maximumPoint = n; + } + +} diff --git a/src/main/java/com/greenpoint/server/store/model/StoreRequest.java b/src/main/java/com/greenpoint/server/store/model/StoreRequest.java new file mode 100644 index 0000000..a4745d1 --- /dev/null +++ b/src/main/java/com/greenpoint/server/store/model/StoreRequest.java @@ -0,0 +1,19 @@ +package com.greenpoint.server.store.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class StoreRequest { + private String loginID; + private String password; + private String category; + private String name; + private String image; + private double latitude; + private double longitude; + private int totalPoint; +} diff --git a/src/main/java/com/greenpoint/server/store/repository/StoreRepository.java b/src/main/java/com/greenpoint/server/store/repository/StoreRepository.java new file mode 100644 index 0000000..ad7dfa5 --- /dev/null +++ b/src/main/java/com/greenpoint/server/store/repository/StoreRepository.java @@ -0,0 +1,15 @@ +package com.greenpoint.server.store.repository; + +import com.greenpoint.server.store.model.Store; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface StoreRepository extends JpaRepository { + +// @Query(nativeQuery = true, value ="select s from Store s where s.id = :id order by s. LIMIT 3") +// List findThreeById(Long id); +} diff --git a/src/main/java/com/greenpoint/server/store/service/StoreService.java b/src/main/java/com/greenpoint/server/store/service/StoreService.java new file mode 100644 index 0000000..41dc16f --- /dev/null +++ b/src/main/java/com/greenpoint/server/store/service/StoreService.java @@ -0,0 +1,73 @@ +package com.greenpoint.server.store.service; + +import com.greenpoint.server.exception.GlobalException; +import com.greenpoint.server.point.service.PointService; +import com.greenpoint.server.store.model.Store; +import com.greenpoint.server.store.model.StoreClientResponse; +import com.greenpoint.server.store.model.StoreRequest; +import com.greenpoint.server.store.repository.StoreRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + + +@Service +public class StoreService { + + @Autowired + private StoreRepository storeRepository; + + @Autowired + private PointService pointService; + + + @Transactional(readOnly = true) + public Store findById(Long storeId) { + Store ret = storeRepository.findById(storeId).get(); + return ret; + } + + @Transactional(readOnly = true) + public List findAll() { + List stores = storeRepository.findAll(); + List ret = stores.stream().map(StoreClientResponse::from).collect(Collectors.toList()); + for(int i=0; i findThreeById(Long id) { +// List ret = storeRepository.findThreeById(id); +// return ret; +// } +} diff --git a/src/main/java/com/greenpoint/server/storeLevel/controller/StoreLevelController.java b/src/main/java/com/greenpoint/server/storeLevel/controller/StoreLevelController.java new file mode 100644 index 0000000..fd97c84 --- /dev/null +++ b/src/main/java/com/greenpoint/server/storeLevel/controller/StoreLevelController.java @@ -0,0 +1,13 @@ +package com.greenpoint.server.storeLevel.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@CrossOrigin +@RequestMapping("/api") +public class StoreLevelController { +} diff --git a/src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java b/src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java new file mode 100644 index 0000000..f9f0b44 --- /dev/null +++ b/src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java @@ -0,0 +1,29 @@ +package com.greenpoint.server.storeLevel.model; + +import com.greenpoint.server.common.BaseEntity; +import lombok.*; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.Where; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Where(clause = "deleted = false") +@SQLDelete(sql = "UPDATE storelevel SET deleted = true Where id = ?") +public class StoreLevel extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String name; + private String image; + private int grade; +} diff --git a/src/main/java/com/greenpoint/server/storeLevel/repository/StoreLevelRepository.java b/src/main/java/com/greenpoint/server/storeLevel/repository/StoreLevelRepository.java new file mode 100644 index 0000000..bb856dc --- /dev/null +++ b/src/main/java/com/greenpoint/server/storeLevel/repository/StoreLevelRepository.java @@ -0,0 +1,11 @@ +package com.greenpoint.server.storeLevel.repository; + +import com.greenpoint.server.storeLevel.model.StoreLevel; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +public interface StoreLevelRepository extends JpaRepository { + + @Query("select s from StoreLevel s where s.grade = :after") + StoreLevel findByGrade(int after); +} diff --git a/src/main/java/com/greenpoint/server/storeLevel/service/StoreLevelService.java b/src/main/java/com/greenpoint/server/storeLevel/service/StoreLevelService.java new file mode 100644 index 0000000..d658278 --- /dev/null +++ b/src/main/java/com/greenpoint/server/storeLevel/service/StoreLevelService.java @@ -0,0 +1,21 @@ +package com.greenpoint.server.storeLevel.service; + +import com.greenpoint.server.storeLevel.model.StoreLevel; +import com.greenpoint.server.storeLevel.repository.StoreLevelRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class StoreLevelService { + + @Autowired + private StoreLevelRepository storeLevelRepository; + + + @Transactional + public StoreLevel findByGrade(int after) { + StoreLevel storeLevel = storeLevelRepository.findByGrade(after); + return storeLevel; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index beb5efd..ab950f8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,4 +4,7 @@ spring.datasource.url=jdbc:mysql://walab.handong.edu:3306/23_Camp5 spring.datasource.username=23_Camp5 spring.datasource.password=CIkTVPOVMrQwhxr8 -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver \ No newline at end of file +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.jpa.generate-ddl=true +spring.jpa.properties.hibernate.globally_quoted_identifiers=true +spring.jackson.serialization.fail-on-empty-beans=false \ No newline at end of file