diff --git a/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java b/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java index 9dfd848..7d65d9e 100644 --- a/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java +++ b/src/main/java/com/greenpoint/server/customer/controller/CustomerController.java @@ -1,11 +1,14 @@ 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; @RestController @@ -14,14 +17,19 @@ public class CustomerController { @Autowired - private CustomerService cs; + private CustomerService customerService; + @GetMapping("/readCustomer") + public ResponseEntity readCustomer(@RequestParam("token") String token) { - @GetMapping("/test") - public void print() { - System.out.println(" 들어옴! "); + Customer customer; + customer = customerService.findByToken(token); + return ResponseEntity.ok(customer); + } + @GetMapping("/readCustomerByNum") + public ResponseEntity readCustomerByNum(@RequestParam("contact") String contact) { Customer customer; - customer = cs.findById(1L); - System.out.println("customer = " + customer.getNickname()); + customer = customerService.findByContact(contact); + return ResponseEntity.ok(customer); } } diff --git a/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java b/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java index 172b24f..39714ff 100644 --- a/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java +++ b/src/main/java/com/greenpoint/server/customer/repository/CustomerRepository.java @@ -11,4 +11,9 @@ public interface CustomerRepository extends JpaRepository { @Query("delete from Customer where kakaoToken= :kakaoToken") public int deleteByKakaoToken(String kakaoToken); +// @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); } diff --git a/src/main/java/com/greenpoint/server/customer/service/CustomerService.java b/src/main/java/com/greenpoint/server/customer/service/CustomerService.java index ffb8f81..083a912 100644 --- a/src/main/java/com/greenpoint/server/customer/service/CustomerService.java +++ b/src/main/java/com/greenpoint/server/customer/service/CustomerService.java @@ -21,6 +21,16 @@ public Customer findById(Long id) { return ret; } + @Transactional + public Customer findByToken(String token) { + Customer customer = customerRepository.findByKakaoToken(token); + return customer; + } + @Transactional + public Customer findByContact(String contact) { + Customer customer = customerRepository.findByContact(contact); + return customer; + } } diff --git a/src/main/java/com/greenpoint/server/history/controller/HistoryController.java b/src/main/java/com/greenpoint/server/history/controller/HistoryController.java index f89aff6..c50fc71 100644 --- a/src/main/java/com/greenpoint/server/history/controller/HistoryController.java +++ b/src/main/java/com/greenpoint/server/history/controller/HistoryController.java @@ -7,6 +7,7 @@ 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; @@ -32,8 +33,6 @@ public ResponseEntity> findAllById(@PathVariable Long cust return ResponseEntity.ok(res); } - - @PostMapping(value="/history") public ResponseEntity addHistory(@RequestBody HistoryRequest request){ Customer customer = customerService.findById(request.getCustomerId()); @@ -41,5 +40,9 @@ public ResponseEntity addHistory(@RequestBody HistoryRequest request){ Long res = historyService.create(History.from(store, request), customer); return ResponseEntity.ok(res); } +// @GetMapping(value="/dailyHistory") +// public ResponseEntity> readDailyHistory(@RequestParam("id") Long id){ +// +// } } diff --git a/src/main/java/com/greenpoint/server/level/model/Level.java b/src/main/java/com/greenpoint/server/level/model/Level.java index fa11a0a..014b0bd 100644 --- a/src/main/java/com/greenpoint/server/level/model/Level.java +++ b/src/main/java/com/greenpoint/server/level/model/Level.java @@ -22,14 +22,12 @@ public class Level extends BaseEntity{ @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private int grade; - private int lpoint; private String name; private String image; public static Level from(LevelRequest request) { return Level.builder() .grade(request.getGrade()) - .lpoint(request.getLpoint()) .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 index 398b230..e890f3d 100644 --- a/src/main/java/com/greenpoint/server/level/model/LevelRequest.java +++ b/src/main/java/com/greenpoint/server/level/model/LevelRequest.java @@ -10,7 +10,6 @@ @AllArgsConstructor public class LevelRequest { private int grade; - private int lpoint; 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/storeLevel/model/StoreLevel.java b/src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java index 808ca68..f9f0b44 100644 --- a/src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java +++ b/src/main/java/com/greenpoint/server/storeLevel/model/StoreLevel.java @@ -26,5 +26,4 @@ public class StoreLevel extends BaseEntity { private String name; private String image; private int grade; - private int lpoint; }