Skip to content

Commit

Permalink
Feat/#13 (#22)
Browse files Browse the repository at this point in the history
* 로그인 API 구현

* 로그인 API 완성

* feat[#13]

회원가입 API, 회원탈퇴 API 구현

* feat[#13]

* feat[#13]

* Update UserService.java

merge conflict resolved

* 해커톤 화이팅

이것저것 구현함

* ㅇ

ㅇ
  • Loading branch information
shinel98 authored Jan 27, 2023
1 parent 905129f commit 733480d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,14 +17,19 @@
public class CustomerController {

@Autowired
private CustomerService cs;
private CustomerService customerService;
@GetMapping("/readCustomer")
public ResponseEntity<Customer> 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<Customer> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,14 +33,16 @@ public ResponseEntity<List<HistoryResponse>> findAllById(@PathVariable Long cust
return ResponseEntity.ok(res);
}



@PostMapping(value="/history")
public ResponseEntity<Long> addHistory(@RequestBody HistoryRequest request){
Customer customer = customerService.findById(request.getCustomerId());
Store store = storeService.findStoreById(request.getStoreId());
Long res = historyService.create(History.from(store, request), customer);
return ResponseEntity.ok(res);
}
// @GetMapping(value="/dailyHistory")
// public ResponseEntity<List<History>> readDailyHistory(@RequestParam("id") Long id){
//
// }

}
2 changes: 0 additions & 2 deletions src/main/java/com/greenpoint/server/level/model/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
@AllArgsConstructor
public class LevelRequest {
private int grade;
private int lpoint;
public String name;
public String image;
}
15 changes: 15 additions & 0 deletions src/main/java/com/greenpoint/server/level/model/LevelResponse.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ public class StoreLevel extends BaseEntity {
private String name;
private String image;
private int grade;
private int lpoint;
}

0 comments on commit 733480d

Please sign in to comment.