Skip to content

Commit a4b7267

Browse files
authored
Merge pull request #9 from CommitField/dev
feat: ๋„์ปค ์„ค์ • ํ›„ ๋ณ‘ํ•ฉ
2 parents 6426b09 + f77b123 commit a4b7267

File tree

19 files changed

+397
-12
lines changed

19 files changed

+397
-12
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## #๏ธโƒฃ Issue Number
2+
3+
<!--- ex) #์ด์Šˆ๋ฒˆํ˜ธ, #์ด์Šˆ๋ฒˆํ˜ธ -->
4+
5+
## ๐Ÿ“ ์š”์•ฝ(Summary)
6+
7+
<!--- ๋ณ€๊ฒฝ ์‚ฌํ•ญ ๋ฐ ๊ด€๋ จ ์ด์Šˆ์— ๋Œ€ํ•ด ๊ฐ„๋‹จํ•˜๊ฒŒ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์–ด๋–ป๊ฒŒ๋ณด๋‹ค ๋ฌด์—‡์„ ์™œ ์ˆ˜์ •ํ–ˆ๋Š”์ง€ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”. -->
8+
9+
## ๐Ÿ› ๏ธ PR ์œ ํ˜•
10+
11+
์–ด๋–ค ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๋‚˜์š”?
12+
13+
- [ ] ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ ์ถ”๊ฐ€
14+
- [ ] ๋ฒ„๊ทธ ์ˆ˜์ •
15+
- [ ] CSS ๋“ฑ ์‚ฌ์šฉ์ž UI ๋””์ž์ธ ๋ณ€๊ฒฝ
16+
- [ ] ์ฝ”๋“œ์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๋Š” ๋ณ€๊ฒฝ์‚ฌํ•ญ(์˜คํƒ€ ์ˆ˜์ •, ํƒญ ์‚ฌ์ด์ฆˆ ๋ณ€๊ฒฝ, ๋ณ€์ˆ˜๋ช… ๋ณ€๊ฒฝ)
17+
- [ ] ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง
18+
- [ ] ์ฃผ์„ ์ถ”๊ฐ€ ๋ฐ ์ˆ˜์ •
19+
- [ ] ๋ฌธ์„œ ์ˆ˜์ •
20+
- [ ] ํ…Œ์ŠคํŠธ ์ถ”๊ฐ€, ํ…Œ์ŠคํŠธ ๋ฆฌํŒฉํ† ๋ง
21+
- [ ] ๋นŒ๋“œ ๋ถ€๋ถ„ ํ˜น์€ ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ € ์ˆ˜์ •
22+
- [ ] ํŒŒ์ผ ํ˜น์€ ํด๋”๋ช… ์ˆ˜์ •
23+
- [ ] ํŒŒ์ผ ํ˜น์€ ํด๋” ์‚ญ์ œ
24+
25+
## ๐Ÿ“ธ์Šคํฌ๋ฆฐ์ƒท (์„ ํƒ)
26+
27+
## ๐Ÿ’ฌ ๊ณต์œ ์‚ฌํ•ญ to ๋ฆฌ๋ทฐ์–ด
28+
29+
<!--- ๋ฆฌ๋ทฐ์–ด๊ฐ€ ์ค‘์ ์ ์œผ๋กœ ๋ด์คฌ์œผ๋ฉด ์ข‹๊ฒ ๋Š” ๋ถ€๋ถ„์ด ์žˆ์œผ๋ฉด ์ ์–ด์ฃผ์„ธ์š”. -->
30+
<!--- ๋…ผ์˜ํ•ด์•ผํ•  ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด ์ ์–ด์ฃผ์„ธ์š”.-->
31+
<!--- ex) ๋ฉ”์„œ๋“œ XXX์˜ ์ด๋ฆ„์„ ๋” ์ž˜ ์ง“๊ณ  ์‹ถ์€๋ฐ ํ˜น์‹œ ์ข‹์€ ๋ช…์นญ์ด ์žˆ์„๊นŒ์š”? -->
32+
33+
## โœ… PR Checklist
34+
35+
PR์ด ๋‹ค์Œ ์š”๊ตฌ ์‚ฌํ•ญ์„ ์ถฉ์กฑํ•˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
36+
37+
- [ ] ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€ ์ปจ๋ฒค์…˜์— ๋งž๊ฒŒ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
38+
- [ ] ๋ณ€๊ฒฝ ์‚ฌํ•ญ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ํ–ˆ์Šต๋‹ˆ๋‹ค.(๋ฒ„๊ทธ ์ˆ˜์ •/๊ธฐ๋Šฅ์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ).

โ€Ž.gitignoreโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ override.tf.json
7171

7272
### ๋„์ปค ์ปดํฌ์ฆˆ ํŒŒ์ผ
7373
docker-compose.yml
74+
docker-compose.yaml
7475

7576
### dbํŒŒ์ผ
7677
db/

โ€Žbuild.gradle.ktsโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ repositories {
2626
dependencies {
2727
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
2828
implementation("org.springframework.boot:spring-boot-starter-security")
29+
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
2930
implementation("org.springframework.boot:spring-boot-starter-web")
3031
implementation("org.springframework.boot:spring-boot-starter-websocket")
3132
compileOnly("org.projectlombok:lombok")

โ€Žcompose.yamlโ€Ž

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# ํ…Œ์ŠคํŒ…
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cmf.commitField.domain.user.controller;
2+
3+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
4+
import org.springframework.security.oauth2.core.user.OAuth2User;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
import java.util.Map;
9+
10+
@RestController
11+
public class AuthController {
12+
@GetMapping("/user")
13+
public Map<String, Object> user(@AuthenticationPrincipal OAuth2User principal) {
14+
return principal.getAttributes(); // ์‚ฌ์šฉ์ž ์ •๋ณด ๋ฐ˜ํ™˜
15+
}
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cmf.commitField.domain.user.controller;
2+
3+
import jakarta.servlet.http.HttpServletRequest;
4+
import jakarta.servlet.http.HttpServletResponse;
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
8+
import java.io.IOException;
9+
10+
@Controller
11+
public class LogoutController {
12+
13+
@GetMapping("/logout")
14+
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
15+
request.getSession().invalidate();
16+
response.sendRedirect("/");
17+
}
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cmf.commitField.domain.user.entity;
2+
3+
import cmf.commitField.global.jpa.BaseEntity;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.Id;
6+
import lombok.Builder;
7+
8+
@Entity
9+
@Builder
10+
public class User extends BaseEntity {
11+
@Id
12+
private long id;
13+
private String email;
14+
private String nickname;
15+
private String password;
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package cmf.commitField.global.error;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
import org.springframework.http.HttpStatus;
6+
7+
@Getter
8+
@AllArgsConstructor
9+
public enum ErrorCode {
10+
11+
// Common
12+
INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "์ œ๊ณต๋œ ์ž…๋ ฅ ๊ฐ’์ด ์œ ํšจํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."),
13+
METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "ํ—ˆ์šฉ๋˜์ง€ ์•Š์€ ์š”์ฒญ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค."),
14+
ENTITY_NOT_FOUND(HttpStatus.BAD_REQUEST, "์š”์ฒญํ•œ ์—”ํ‹ฐํ‹ฐ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."),
15+
INVALID_TYPE_VALUE(HttpStatus.BAD_REQUEST, "์ œ๊ณต๋œ ๊ฐ’์˜ ํƒ€์ž…์ด ์œ ํšจํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."),
16+
ERROR_PARSING_JSON_RESPONSE(HttpStatus.BAD_REQUEST, "JSON ์‘๋‹ต์„ ํŒŒ์‹ฑํ•˜๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค."),
17+
MISSING_INPUT_VALUE(HttpStatus.BAD_REQUEST, "ํ•„์ˆ˜ ์ž…๋ ฅ ๊ฐ’์ด ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค."),
18+
DATABASE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค."),
19+
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "์„œ๋ฒ„ ๋‚ด๋ถ€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค."),
20+
21+
// User
22+
NOT_FOUND_USER(HttpStatus.BAD_REQUEST, "ํ•ด๋‹น ์œ ์ €๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค"),
23+
PASSWORD_MISMATCH(HttpStatus.BAD_REQUEST, "๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."),
24+
25+
// Auth
26+
ACCESS_DENIED(HttpStatus.UNAUTHORIZED, "์ธ์ฆ๋˜์ง€ ์•Š์€ ์œ ์ €์ž…๋‹ˆ๋‹ค."),
27+
SC_FORBIDDEN(HttpStatus.UNAUTHORIZED, "๊ถŒํ•œ์ด ์—†๋Š” ์œ ์ €์ž…๋‹ˆ๋‹ค."),
28+
INVALID_JWT_SIGNATURE(HttpStatus.UNAUTHORIZED, "์„œ๋ช… ๊ฒ€์ฆ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค." ),
29+
ILLEGAL_REGISTRATION_ID(HttpStatus.BAD_REQUEST,"ํ•ด๋‹น ์‚ฌํ•ญ์ด ์—†๋Š” ๋กœ๊ทธ์ธ ๊ฒฝ๋กœ์ž…๋‹ˆ๋‹ค."),
30+
31+
TOKEN_EXPIRED(HttpStatus.BAD_REQUEST, "ํ† ํฐ์ด ๋งŒ๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค."),
32+
33+
// member
34+
MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "์‚ฌ์šฉ์ž๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค");
35+
36+
37+
private final HttpStatus httpStatus;
38+
private final String message;
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cmf.commitField.global.error;
2+
3+
import lombok.Builder;
4+
import lombok.Getter;
5+
import org.springframework.http.ResponseEntity;
6+
7+
import java.time.LocalDateTime;
8+
9+
@Getter
10+
public class ErrorResponse {
11+
private final String timestamp;
12+
private final String error;
13+
private final String message;
14+
15+
@Builder
16+
public ErrorResponse(String timestamp, String error, String message){
17+
this.timestamp = timestamp;
18+
this.error = error;
19+
this.message = message;
20+
}
21+
public static ResponseEntity<ErrorResponse> toResponseEntity(ErrorCode errorCode){
22+
return ResponseEntity
23+
.status(errorCode.getHttpStatus())
24+
.body(ErrorResponse.builder()
25+
.timestamp(LocalDateTime.now().toString())
26+
.error(errorCode.getHttpStatus().name())
27+
.message(errorCode.getMessage())
28+
.build()
29+
);
30+
31+
}
32+
}

0 commit comments

Comments
ย (0)