Skip to content

Commit

Permalink
feat: add User controller, service, dao 틀 완성
Browse files Browse the repository at this point in the history
  • Loading branch information
shinsj4653 committed Jan 15, 2024
1 parent f454103 commit 3cdde26
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
14 changes: 7 additions & 7 deletions src/main/java/gdsc/pointer/controller/UserController.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package gdsc.pointer.controller;

import gdsc.pointer.domain.User;
import gdsc.pointer.dto.ResultDto;
import gdsc.pointer.dto.request.UserDto;
import gdsc.pointer.dto.response.ResultDto;
import gdsc.pointer.service.UserService;
import lombok.RequiredArgsConstructor;
import org.apache.coyote.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -26,10 +25,11 @@ public ResponseEntity<?> getUsers() throws Exception {
}


// @PostMapping("/insertUser")
// public ResponseEntity<?> insertUser(@RequestBody User user) throws Exception{
// return userService.insertUser(user);
// }
@PostMapping()
public ResponseEntity<?> addUser(@RequestBody UserDto userDto) throws Exception{
userService.addUser(userDto);
return ResponseEntity.ok(ResultDto.res(HttpStatus.CREATED, "회원 가입 완료"));
}
//
// @GetMapping("/getUserDetail")
// public ResponseEntity<?> getUserDetail(@RequestParam("id") String id) throws Exception{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gdsc/pointer/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.cloud.firestore.QuerySnapshot;
import com.google.firebase.cloud.FirestoreClient;
import gdsc.pointer.domain.User;
import gdsc.pointer.dto.request.UserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

Expand All @@ -29,4 +30,9 @@ public List<User> getUsers() throws Exception {
return list;
}

public void addUser(UserDto userDto) throws Exception {

}


}
1 change: 1 addition & 0 deletions src/main/java/gdsc/pointer/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class User {

private String id;
private String name;
private String email;

}
10 changes: 10 additions & 0 deletions src/main/java/gdsc/pointer/dto/request/UserDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gdsc.pointer.dto.request;

import lombok.Getter;

@Getter
public class UserDto {
private String id;
private String name;
private String email;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gdsc.pointer.dto;
package gdsc.pointer.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gdsc/pointer/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gdsc.pointer.service;

import gdsc.pointer.domain.User;
import gdsc.pointer.dto.request.UserDto;
import org.springframework.http.ResponseEntity;

import java.util.List;

public interface UserService {
List<User> getUsers() throws Exception;

void addUser(UserDto userDto) throws Exception;
}
22 changes: 6 additions & 16 deletions src/main/java/gdsc/pointer/service/UserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
package gdsc.pointer.service;

import com.google.api.core.ApiFuture;
import com.google.cloud.firestore.DocumentReference;
import com.google.cloud.firestore.DocumentSnapshot;
import com.google.cloud.firestore.Firestore;
import com.google.cloud.firestore.WriteResult;
import com.google.firebase.cloud.FirestoreClient;
import gdsc.pointer.dao.UserDao;
import gdsc.pointer.domain.User;
import gdsc.pointer.dto.request.UserDto;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService{
public class UserServiceImpl implements UserService {

private final UserDao userDao;

Expand All @@ -27,13 +20,10 @@ public List<User> getUsers() throws Exception {
}


// @Override
// public ResponseEntity<?> insertUser(User user) throws Exception {
// Firestore firestore = FirestoreClient.getFirestore();
// ApiFuture<WriteResult> apiFuture =
// firestore.collection(COLLECTION_NAME).document(user.getId()).set(user);
// return new ResponseEntity<>("회원 추가 완료", HttpStatus.OK);
// }
@Override
public void addUser(UserDto userDto) throws Exception {
userDao.addUser(userDto);
}
//
// @Override
// public ResponseEntity<?> getUserDetail(String id) throws Exception {
Expand Down

0 comments on commit 3cdde26

Please sign in to comment.