-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: 일반 로그인, 소셜로그인, 브랜드 조회
- Loading branch information
Showing
55 changed files
with
1,754 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: "[\U0001F331Feat] 이슈 설명" | ||
labels: "\U0001F527Feature" | ||
assignees: '' | ||
|
||
--- | ||
|
||
## 🛠️기능 설명 or 브랜치 생성 목적 | ||
> 홈화면 & 자체 로그인 기능 | ||
## ✅To-do list🗒️ | ||
- [ ] | ||
- [ ] | ||
- [ ] | ||
- [ ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/example/neoul/controller/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.example.neoul.controller; | ||
|
||
import com.example.neoul.dto.TokenRes; | ||
import com.example.neoul.dto.UserReq; | ||
import com.example.neoul.global.entity.ApiResponse; | ||
import com.example.neoul.global.entity.BaseEntity; | ||
import com.example.neoul.global.exception.BadRequestException; | ||
import com.example.neoul.service.AuthService; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@RestController | ||
@Api(tags={"01.user"}) | ||
@RequestMapping("/oauth") | ||
@RequiredArgsConstructor | ||
public class AuthController { | ||
private final AuthService authService; | ||
|
||
|
||
/** | ||
* 카카오 소셜로그인 | ||
* https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=abf4119e38a436ab64718033228aad2d&redirect_uri=http://localhost:8080/oauth/kakao | ||
* */ | ||
@ApiOperation(value = "인가코드 캐치를 위한 api, 사용x, 백엔드 터미널로 반환중", | ||
notes = "https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=abf4119e38a436ab64718033228aad2d&redirect_uri=http://localhost:8080/oauth/kakao" + | ||
"원래는 프론트엔드가 첫 회원가입 링크로 들어가서 code를 받고, 그 받은 코드로 이 api에 접근해서" + | ||
"카카오의 access_token을 반환 후" + | ||
"access_token을 /kakao/login의 요청에 넣어서 우리 사이트의 로그인하고 그 결과를 얻음") | ||
@GetMapping("/kakao") | ||
public ApiResponse<String> getAccessTokenKakao(@RequestParam String code) { | ||
String accessToken=authService.getKakaoAccessToken(code); | ||
System.out.println("code for kakaoServer : " + code); | ||
System.out.println("for /oauth/kakao : " + accessToken); | ||
|
||
return new ApiResponse<>(accessToken); | ||
} | ||
|
||
@ApiOperation(value = "카카오 로그인", notes = "카카오 로그인") | ||
@PostMapping("/kakao/login") | ||
public TokenRes kakaoSignupOrLogin(@RequestBody UserReq.SocialReq socialReq) { | ||
TokenRes tokenRes = authService.createAndLoginKakaoUser(socialReq); | ||
|
||
if(tokenRes == null) | ||
throw new BadRequestException("사용자 정보가 없습니다"); | ||
return tokenRes; | ||
} | ||
|
||
|
||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/example/neoul/controller/BrandController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.example.neoul.controller; | ||
|
||
import com.example.neoul.dto.brand.BrandRes; | ||
import com.example.neoul.global.entity.ApiResponse; | ||
import com.example.neoul.service.BrandService; | ||
import io.swagger.annotations.Api; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Api(tags={"02.brand"}) | ||
@RequestMapping("/brand") | ||
public class BrandController { | ||
private final BrandService brandService; | ||
|
||
// 브랜드 list | ||
@GetMapping("/list") | ||
public ApiResponse<List<BrandRes.BrandListRes>> list(){ | ||
return new ApiResponse(brandService.list()); | ||
} | ||
|
||
// 브랜드 상세조회 | ||
@GetMapping("/{brandId}") | ||
public ApiResponse<BrandRes.BrandInfoRes> brandInfo(@PathVariable("brandId") Long brandId){ | ||
return new ApiResponse<>(brandService.info(brandId)); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/example/neoul/controller/StoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.example.neoul.controller; | ||
|
||
import com.example.neoul.dto.Story.StoryRes; | ||
import com.example.neoul.global.entity.ApiResponse; | ||
import com.example.neoul.service.StoryService; | ||
import io.swagger.annotations.Api; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Api(tags={"03.story"}) | ||
@RequestMapping("/story") | ||
public class StoryController { | ||
private final StoryService storyService; | ||
|
||
// 스토리 list | ||
@GetMapping("/list") | ||
public ApiResponse<List<StoryRes.StoryListRes>> list(){ | ||
return new ApiResponse(storyService.list()); | ||
} | ||
|
||
// 스토리 상세조회 | ||
@GetMapping("/{storyId}") | ||
public ApiResponse<StoryRes.StoryInfoRes> storyInfo(@PathVariable("storyId") Long storyId){ | ||
return new ApiResponse<>(storyService.info(storyId)); | ||
} | ||
} | ||
|
20 changes: 19 additions & 1 deletion
20
src/main/java/com/example/neoul/controller/TestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
package com.example.neoul.controller; | ||
|
||
import com.example.neoul.global.entity.ApiResponse; | ||
import com.example.neoul.global.exception.BadRequestException; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
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; | ||
|
||
@Slf4j | ||
@RestController | ||
@Api(tags={"00.test"}) | ||
@RequestMapping("/test") | ||
public class TestController { | ||
@GetMapping("/testapi") | ||
public ResponseEntity test(){ | ||
log.info("test api 수신"); | ||
log.error("test api 수신"); | ||
return new ResponseEntity("test ok",HttpStatus.OK); | ||
} | ||
|
||
|
||
@ApiOperation(value = "API 응답 반환 형식 예", notes = "API 응답 반환 형식 예") | ||
@GetMapping("") | ||
public ApiResponse<String> test2(@RequestParam(required = false) String s){ | ||
|
||
if("null".equals(s)) | ||
throw new BadRequestException("오류 던지기"); | ||
|
||
return new ApiResponse<>("데이터가 들어갈 자리(문자열, 객체 등"); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/example/neoul/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.example.neoul.controller; | ||
|
||
|
||
import com.example.neoul.dto.TokenRes; | ||
import com.example.neoul.dto.UserReq; | ||
import com.example.neoul.dto.UserRes; | ||
import com.example.neoul.entity.user.User; | ||
import com.example.neoul.global.entity.ApiResponse; | ||
import com.example.neoul.global.exception.BadRequestException; | ||
import com.example.neoul.service.UserService; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@Api(tags={"01.user"}) | ||
@RequestMapping("/user") | ||
public class UserController { | ||
|
||
private final UserService userService; | ||
|
||
|
||
@ApiOperation(value = "현재 로그인 유저", notes = "현재 로그인 유저") | ||
@GetMapping("/now") | ||
public ApiResponse<User> now(){ | ||
return new ApiResponse<>(userService.findNowLoginUser()); | ||
} | ||
|
||
|
||
@ApiOperation(value = "회원가입", notes = "회원가입") | ||
@PostMapping("/signup") | ||
public ApiResponse<UserRes.UserDetailDto> signup(@RequestBody UserReq.SignupUserDto signupUserDto) { | ||
//이메일 형식 체크 | ||
if(userService.validationEmail(signupUserDto.getUsername())) | ||
throw new BadRequestException("이메일 형식으로 입력해주세요"); | ||
|
||
//비밀번호 형식 체크 | ||
if(signupUserDto.getPassword().length() < 6) | ||
throw new BadRequestException("비밀번호를 6자리 이상 입력해주세요"); | ||
|
||
|
||
return new ApiResponse<>(userService.signup(signupUserDto)); | ||
} | ||
|
||
|
||
|
||
|
||
@ApiOperation(value = "로그인", notes = "로그인") | ||
@PostMapping("/login") | ||
public ApiResponse<TokenRes> signup(@RequestBody UserReq.LoginUserDto loginUserDto) { | ||
return new ApiResponse<>(userService.login(loginUserDto)); | ||
} | ||
|
||
// | ||
// @ApiOperation(value = "회원 탈퇴", notes = "회원 탈퇴") | ||
// @GetMapping("/withdrawal") | ||
// public BaseResponse<String> withdrawal() { | ||
// if(userService.withdrawal() != null) | ||
// return BaseResponse.ok(SUCCESS, userService.withdrawal()); | ||
// | ||
// return BaseResponse.ok(USER_FAILED_TO_WITHDRAWAL); | ||
// } | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example.neoul.dto.Story; | ||
|
||
import com.example.neoul.dto.brand.BrandRes; | ||
import lombok.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public class StoryRes { | ||
|
||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Setter | ||
@Getter | ||
// content와 content/상세 - 브랜드 후원 이야기 | ||
public static class StoryListRes { | ||
private Long sid; //후원 이야기 id | ||
private String categoryVName; // 후원 카테고리 이름 | ||
private String preImg; //후원글 프리뷰 이미지 | ||
private String title; //후원글 제목 | ||
private LocalDateTime createdAt; //후원글 작성 일시 | ||
} | ||
|
||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Setter | ||
@Getter | ||
// content와 content/상세 - 브랜드 후원 이야기 | ||
public static class StoryInfoRes { | ||
private Long sid; //후원 이야기 id | ||
// private Long bid; //브랜드 id | ||
private String categoryVName; // 후원 브랜드 이름 | ||
private String preImg; //후원글 프리뷰 이미지 | ||
private String title; //후원글 제목 | ||
private String content; //후원글 내용 | ||
private LocalDateTime createdAt; //후원글 작성 일시 | ||
private List<BrandRes.BrandListRes> brandListRes; // 브랜드 별 물품 리스트 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ public class UserReq { | |
@AllArgsConstructor | ||
@Setter | ||
@Getter | ||
public static class LoginUserReq { | ||
public static class LoginUserDto { | ||
@ApiModelProperty(example = "[email protected]") | ||
private String username; | ||
@ApiModelProperty(example = "test1234") | ||
|
@@ -22,7 +22,7 @@ public static class LoginUserReq { | |
@AllArgsConstructor | ||
@Setter | ||
@Getter | ||
public static class SocialLoginUserReq { | ||
public static class SocialLoginUserDto { | ||
@ApiModelProperty(example = "[email protected]") | ||
private String username; | ||
@ApiModelProperty(example = "kakao") | ||
|
@@ -37,14 +37,12 @@ public static class SocialLoginUserReq { | |
@AllArgsConstructor | ||
@Setter | ||
@Getter | ||
public static class SignupUserReq { | ||
public static class SignupUserDto { | ||
private String username; | ||
private String password; | ||
private String name; | ||
private String phone; | ||
private String imageUrl; | ||
|
||
@ApiModelProperty(example = "true or false") | ||
private boolean emailVerified; | ||
} | ||
|
||
|
||
|
@@ -53,7 +51,7 @@ public static class SignupUserReq { | |
@AllArgsConstructor | ||
@Setter | ||
@Getter | ||
public static class EmailAuthReq { | ||
public static class EmailAuthDto { | ||
private String email; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.