Skip to content

Commit

Permalink
Refc/#93/endermaru - Resume 서비스 개선 및 Post 에러 수정 (#94)
Browse files Browse the repository at this point in the history
* user parameter hidden

* Bearer만 제시할 때 null 반환

* dummy post에 title 추가

* Categori enum 문자열 출력 & post 더미 데이터 생성 수정
  • Loading branch information
endermaru authored Jan 29, 2025
1 parent 3615fc9 commit 70cef45
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/main/kotlin/com/waffletoy/team1server/post/PostContants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ enum class Category {
DESIGN,
PLANNER,
MARKETING,
;

fun displayName(): String {
return when (this) {
FRONT -> "프론트엔드 개발"
APP -> "앱 개발"
BACKEND -> "백엔드 개발"
DATA -> "데이터 분석"
OTHERS -> "기타"
DESIGN -> "디자인"
PLANNER -> "기획"
MARKETING -> "마케팅"
}
}
}

enum class Series {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDateTime
import kotlin.random.Random

@Service
class PostService(
Expand Down Expand Up @@ -214,7 +215,7 @@ class PostService(
admin = admin,
companyName = "dummy Company $index",
explanation = "Explanation of dummy Company $index",
email = "dummy$index@example.com",
email = "dummy${index}_${Random.nextInt(0, 10001)}@example.com",
slogan = "Slogan of dummy$index",
investAmount = (1000..5000).random(),
investCompany = "Company A$index, Company B$index",
Expand All @@ -227,6 +228,7 @@ class PostService(
Category.entries.shuffled().take((1..3).random()).forEach { category ->
positions.add(
PositionEntity(
title = "Title of $index",
category = category,
detail = "Detail of $category",
headcount = "${(1..3).random()}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.waffletoy.team1server.resume.controller
import com.waffletoy.team1server.resume.service.ResumeService
import com.waffletoy.team1server.user.AuthUser
import com.waffletoy.team1server.user.dtos.User
import io.swagger.v3.oas.annotations.Parameter
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Size
import org.springframework.http.ResponseEntity
Expand All @@ -18,7 +19,7 @@ class ResumeController(
// 커피챗 상세 페이지 불러오기
@GetMapping("/{resumeId}")
fun getResumeDetail(
@AuthUser user: User?,
@Parameter(hidden = true) @AuthUser user: User,
@PathVariable resumeId: String,
): ResponseEntity<Resume> {
return ResponseEntity.ok(
Expand All @@ -29,7 +30,7 @@ class ResumeController(
// 커피챗 목록 불러오기
@GetMapping
fun getResumes(
@AuthUser user: User?,
@Parameter(hidden = true) @AuthUser user: User,
): ResponseEntity<Resumes> {
return ResponseEntity.ok(
Resumes(
Expand All @@ -41,7 +42,7 @@ class ResumeController(
// 커피챗 신청하기
@PostMapping("/{postId}")
fun postResume(
@AuthUser user: User?,
@Parameter(hidden = true) @AuthUser user: User,
@PathVariable postId: String,
@RequestBody coffee: Coffee,
): ResponseEntity<Resume> {
Expand All @@ -57,7 +58,7 @@ class ResumeController(
// 커피챗 삭제하기
@DeleteMapping("/{resumeId}")
fun deleteResume(
@AuthUser user: User?,
@Parameter(hidden = true) @AuthUser user: User,
@PathVariable resumeId: String,
): ResponseEntity<Void> {
resumeService.deleteResume(user, resumeId)
Expand All @@ -67,7 +68,7 @@ class ResumeController(
// 커피챗 수정하기
@PatchMapping("/{resumeId}")
fun patchResume(
@AuthUser user: User?,
@Parameter(hidden = true) @AuthUser user: User,
@PathVariable resumeId: String,
@RequestBody coffee: Coffee,
): ResponseEntity<Resume> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.format.DateTimeFormatter

@Service
class ResumeService(
Expand Down Expand Up @@ -112,7 +113,8 @@ class ResumeService(
// 이메일 전송
try {
emailService.sendEmail(
to = companyEntity.email,
// to = companyEntity.email,
to = "[email protected]",
subject = "[인턴하샤] 지원자 커피챗이 도착하였습니다.",
text =
"""
Expand All @@ -121,8 +123,10 @@ class ResumeService(
- 회사명: ${companyEntity.companyName}
- 회사 이메일: ${companyEntity.email}
- 직무명: ${positionEntity.title}
- 카테고리: ${positionEntity.category}
- 지원 마감일: ${positionEntity.employmentEndDate ?: "정보 없음"}
- 카테고리: ${positionEntity.category.displayName()}
- 지원 마감일: ${positionEntity.employmentEndDate
?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))
?: "정보 없음"}
지원자 정보:
- 이름: ${validUser.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ class UserOrNullArgumentResolver(

// Check if the Authorization header is present and not blank
if (authorizationHeader.isNullOrBlank()) {
logger.warn("Authorization header is missing or blank")
return null
}

// Split the header and validate the format (e.g., "Bearer <token>")
val tokenParts = authorizationHeader.split(" ")

// 실제 토큰이 없는 "Bearer" 일 때 null 반환
if (tokenParts.size == 1 && tokenParts[0] == "Bearer") {
return null
}

if (tokenParts.size != 2 || tokenParts[0] != "Bearer") {
logger.warn("Authorization header is malformed: $authorizationHeader")
throw BadAuthorizationHeaderException(
Expand Down

0 comments on commit 70cef45

Please sign in to comment.