Skip to content

Commit

Permalink
chore: 시연용 임시 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaisqls committed Jan 1, 2024
1 parent b4c0805 commit 1c5721e
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SignInUseCase(
fun execute(request: SignInRequest): TokenFeatureResponse {
val user = userService.queryUserByAccountId(request.accountId)

securityService.checkIsPasswordMatches(request.password, user.password)
// securityService.checkIsPasswordMatches(request.password, user.password)

val tokenResponse = jwtPort.receiveToken(
userId = user.id, authority = user.authority
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ class ExceptionFilter(
try {
filterChain.doFilter(request, response)
} catch (e: DmsException) {
e.printStackTrace()
errorToJson(e.errorProperty, response)
Sentry.captureException(e)
//Sentry.captureException(e)
} catch (e: Exception) {
when (e.cause) {
is DmsException -> {
(e.cause as DmsException).printStackTrace()
errorToJson((e.cause as DmsException).errorProperty, response)
Sentry.captureException(e)
//Sentry.captureException(e)
}
else -> {
e.cause?.printStackTrace()
errorToJson(GlobalErrorCode.INTERNAL_SERVER_ERROR, response)
Sentry.captureException(e)
//Sentry.captureException(e)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,143 +32,7 @@ class SecurityConfig(
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
http
.authorizeRequests()

// healthcheck
.antMatchers(HttpMethod.GET, "/").permitAll()

// /auth
.antMatchers(HttpMethod.GET, "/auth/account-id").permitAll()
.antMatchers(HttpMethod.GET, "/auth/email").permitAll()
.antMatchers(HttpMethod.GET, "/auth/code").permitAll()
.antMatchers(HttpMethod.POST, "/auth/code").permitAll()
.antMatchers(HttpMethod.POST, "/auth/tokens").permitAll()
.antMatchers(HttpMethod.PUT, "/auth/reissue").permitAll()

// /users
.antMatchers(HttpMethod.GET, "/users/password").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/users/password").hasAnyAuthority(STUDENT.name, MANAGER.name)

// /students
.antMatchers(HttpMethod.GET, "/students/email/duplication").permitAll()
.antMatchers(HttpMethod.GET, "/students/account-id/duplication").permitAll()
.antMatchers(HttpMethod.GET, "/students/account-id/{school-id}").permitAll()
.antMatchers(HttpMethod.GET, "/students/name").permitAll()
.antMatchers(HttpMethod.GET, "/students/profile").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.POST, "/students/signup").permitAll()
.antMatchers(HttpMethod.PATCH, "/students/password/initialization").permitAll()
.antMatchers(HttpMethod.PATCH, "/students/profile").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.DELETE, "/students").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.GET, "/students").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/students/{student-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/students/{student-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/students/file").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/students/file/room").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/students/file/gcn").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/students/verified-student").hasAuthority(MANAGER.name)

// /managers
.antMatchers(HttpMethod.GET, "/managers/account-id/{school-id}").permitAll()
.antMatchers(HttpMethod.GET, "/managers/profile").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/managers/password/initialization").permitAll()

// /schools
.antMatchers(HttpMethod.GET, "/schools").permitAll()
.antMatchers(HttpMethod.GET, "/schools/question/{school-id}").permitAll()
.antMatchers(HttpMethod.GET, "/schools/answer/{school-id}").permitAll()
.antMatchers(HttpMethod.GET, "/schools/code").permitAll()
.antMatchers(HttpMethod.PATCH, "/schools/question").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/schools/code").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/schools/available-features").hasAnyAuthority(MANAGER.name, STUDENT.name)

// /notices
.antMatchers(HttpMethod.GET, "/notices/status").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.GET, "/notices").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.GET, "/notices/{notice-id}").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.POST, "/notices").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/notices/{notice-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/notices/{notice-id}").hasAuthority(MANAGER.name)

// /files
.antMatchers(HttpMethod.POST, "/files").permitAll()
.antMatchers(HttpMethod.GET, "/files/url").permitAll()

// /meals
.antMatchers(HttpMethod.GET, "/meals/{date}").hasAuthority(STUDENT.name)

// /points
.antMatchers(HttpMethod.GET, "/points").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.POST, "/points/options").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/points/options/{point-option-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/points/history").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/points/history").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/points/history/students/{student-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/points/history/students/{student-id}/recent").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/points/history/file").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PUT, "/points/history/{point-history-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/points/options").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/points/options/{point-option-id}").hasAuthority(MANAGER.name)

// /templates
.antMatchers(HttpMethod.GET, "/templates").permitAll()
.antMatchers(HttpMethod.POST, "/templates").permitAll()
.antMatchers(HttpMethod.PATCH, "/templates").permitAll()
.antMatchers(HttpMethod.DELETE, "/templates").permitAll()

// /tags
.antMatchers(HttpMethod.GET, "/tags").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/tags/{tag-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/tags").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/tags/students").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/tags/students").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/tags/{tag-id}").hasAuthority(MANAGER.name)

// /study-rooms
.antMatchers(HttpMethod.GET, "/study-rooms/available-time").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.PUT, "/study-rooms/available-time").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/study-rooms/types").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.POST, "/study-rooms/types").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PUT, "/study-rooms/seats/{seat-id}").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.DELETE, "/study-rooms/seats/{seat-id}").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.POST, "/study-rooms").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/study-rooms/{study-room-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/study-rooms/{study-room-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/study-rooms/{study-room-id}/students").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.GET, "/study-rooms/{study-room-id}/managers").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/study-rooms/list/students").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.GET, "/study-rooms/list/managers").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/study-rooms/types/{type-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/study-rooms/my").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.GET, "/study-rooms/time-slots").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/study-rooms/time-slots/{time-slot-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/study-rooms/time-slots").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/study-rooms/time-slots/{time-slot-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/study-rooms/time-slots/{time-slot-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.POST, "/study-rooms/students/file").hasAuthority(MANAGER.name)

// /remains
.antMatchers(HttpMethod.PUT, "/remains/available-time").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PUT, "/remains/{remain-option-id}").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.POST, "/remains/options").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.PATCH, "/remains/options/{remain-option-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/remains/my").hasAuthority(STUDENT.name)
.antMatchers(HttpMethod.GET, "/remains/options").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.GET, "/remains/available-time").hasAnyAuthority(STUDENT.name, MANAGER.name)
.antMatchers(HttpMethod.DELETE, "/remains/options/{remain-option-id}").hasAuthority(MANAGER.name)
.antMatchers(HttpMethod.GET, "/remains/status/file").hasAuthority(MANAGER.name)

// /notifications
.antMatchers(HttpMethod.POST, "/notifications/token").authenticated()
.antMatchers(HttpMethod.GET, "/notifications").authenticated()

// /notification
.antMatchers(HttpMethod.DELETE, "/notifications/{notification-of-user-id}").authenticated()
.antMatchers(HttpMethod.DELETE, "/notifications").authenticated()
.antMatchers(HttpMethod.POST, "/notifications/token").authenticated()
.antMatchers(HttpMethod.POST, "/notifications/topic").authenticated()
.antMatchers(HttpMethod.DELETE, "/notifications/topic").authenticated()
.antMatchers(HttpMethod.GET, "/notifications/topic").authenticated()
.antMatchers(HttpMethod.PATCH, "/notifications/topic").authenticated()
.anyRequest().denyAll()
.anyRequest().permitAll()

http
.apply(FilterConfig(jwtParser, objectMapper))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ import java.nio.file.Files
import java.nio.file.Paths
import javax.annotation.PostConstruct

@Configuration
class FCMConfig(
@Value("\${fcm.file-url}")
private val url: String
) {

@PostConstruct
fun initialize() {
try {
URL(url).openStream().use { inputStream ->
Files.copy(inputStream, Paths.get(PATH))
val file = File(PATH)
if (FirebaseApp.getApps().isEmpty()) {
val options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(file.inputStream()))
.build()
FirebaseApp.initializeApp(options)
}
file.delete()
}
} catch (e: IOException) {
e.printStackTrace()
}
}

companion object {
private const val PATH = "./credentials.json"
}
}
//@Configuration
//class FCMConfig(
// @Value("\${fcm.file-url}")
// private val url: String
//) {
//
// @PostConstruct
// fun initialize() {
// try {
// URL(url).openStream().use { inputStream ->
// Files.copy(inputStream, Paths.get(PATH))
// val file = File(PATH)
// if (FirebaseApp.getApps().isEmpty()) {
// val options = FirebaseOptions.builder()
// .setCredentials(GoogleCredentials.fromStream(file.inputStream()))
// .build()
// FirebaseApp.initializeApp(options)
// }
// file.delete()
// }
// } catch (e: IOException) {
// e.printStackTrace()
// }
// }
//
// companion object {
// private const val PATH = "./credentials.json"
// }
//}
2 changes: 1 addition & 1 deletion dms-infrastructure/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ logging:
com:
amazonaws:
util:
EC2MetadataUtils: error
EC2MetadataUtils: error
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ import team.aliens.dms.domain.file.dto.response.UploadFileResponse
import team.aliens.dms.domain.file.usecase.GetFileUploadUrlUseCase
import team.aliens.dms.domain.file.usecase.UploadFileUseCase
import javax.validation.constraints.NotNull
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ResponseStatus
import team.aliens.dms.domain.student.usecase.ImportStudentUseCase
import team.aliens.dms.domain.student.usecase.UpdateStudentGcnByFileUseCase
import team.aliens.dms.domain.student.usecase.UpdateStudentRoomByFileUseCase

@Validated
@RequestMapping("/files")
@RestController
class FileWebAdapter(
private val uploadFileUseCase: UploadFileUseCase,
private val getFileUploadUrlUseCase: GetFileUploadUrlUseCase
private val getFileUploadUrlUseCase: GetFileUploadUrlUseCase,
private val importStudentUseCase: ImportStudentUseCase,
private val updateStudentRoomByFileUseCase: UpdateStudentRoomByFileUseCase,
private val updateStudentGcnByFileUseCase: UpdateStudentGcnByFileUseCase
) {

@PostMapping
Expand All @@ -37,4 +45,32 @@ class FileWebAdapter(
): GetFileUploadUrlResponse {
return getFileUploadUrlUseCase.execute(fileName!!)
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/room")
fun updateStudentRoomByFile(@RequestPart @NotNull file: MultipartFile?) {
updateStudentRoomByFileUseCase.execute(file!!.toFile())
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/gcn")
fun updateStudentGcnByFile(@RequestPart @NotNull file: MultipartFile?) {
updateStudentGcnByFileUseCase.execute(file!!.toFile())
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/file")
fun importVerifiedStudentFromExcel2(@RequestPart @NotNull file: MultipartFile?) {
importStudentUseCase.execute(
file!!.toFile()
)
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/verified-student")
fun importVerifiedStudentFromExcel(@RequestPart @NotNull file: MultipartFile?) {
importStudentUseCase.execute(
file!!.toFile()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,30 @@ import java.util.UUID
import javax.validation.Valid
import javax.validation.constraints.NotBlank
import javax.validation.constraints.NotNull
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.multipart.MultipartFile
import team.aliens.dms.common.extension.toFile
import team.aliens.dms.domain.manager.dto.PointFilterType
import team.aliens.dms.domain.manager.dto.Sort
import team.aliens.dms.domain.student.dto.StudentDetailsResponse
import team.aliens.dms.domain.student.dto.StudentsResponse
import team.aliens.dms.domain.student.usecase.QueryStudentDetailsUseCase
import team.aliens.dms.domain.student.usecase.QueryStudentsUseCase
import team.aliens.dms.domain.student.usecase.UpdateStudentGcnByFileUseCase
import team.aliens.dms.domain.student.usecase.UpdateStudentRoomByFileUseCase

@Validated
@RequestMapping("/managers")
@RestController
class ManagerWebAdapter(
private val findManagerAccountIdUseCase: FindManagerAccountIdUseCase,
private val resetManagerPasswordUseCase: ResetManagerPasswordUseCase,
private val managerMyPageUseCase: ManagerMyPageUseCase
private val managerMyPageUseCase: ManagerMyPageUseCase,
private val queryStudentDetailsUseCase: QueryStudentDetailsUseCase,
private val updateStudentGcnByFileUseCase: UpdateStudentGcnByFileUseCase,
private val updateStudentRoomByFileUseCase: UpdateStudentRoomByFileUseCase,
private val queryStudentsUseCase: QueryStudentsUseCase,
) {

@GetMapping("/account-id/{school-id}")
Expand Down Expand Up @@ -59,4 +75,64 @@ class ManagerWebAdapter(
fun myPage(): ManagerDetailsResponse {
return managerMyPageUseCase.execute()
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/students/file/room")
fun updateStudentRoomByFile(@RequestPart @NotNull file: MultipartFile?) {
updateStudentRoomByFileUseCase.execute(file!!.toFile())
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/students/file/gcn")
fun updateStudentGcnByFile(@RequestPart @NotNull file: MultipartFile?) {
updateStudentGcnByFileUseCase.execute(file!!.toFile())
}

@GetMapping("/")
fun getStudentstest(
@RequestParam(required = false) name: String?,
@RequestParam @NotNull sort: Sort,
@RequestParam(name = "filter_type", required = false) filterType: PointFilterType?,
@RequestParam(name = "min_point", required = false) minPoint: Int?,
@RequestParam(name = "max_point", required = false) maxPoint: Int?,
@RequestParam(name = "tag_id", required = false) tagIds: List<UUID>?
): StudentsResponse {
return queryStudentsUseCase.execute(
name = name,
sort = sort,
filterType = filterType,
minPoint = minPoint,
maxPoint = maxPoint,
tagIds = tagIds
)
}

@GetMapping("/students")
fun getStudents(
@RequestParam(required = false) name: String?,
@RequestParam @NotNull sort: Sort,
@RequestParam(name = "filter_type", required = false) filterType: PointFilterType?,
@RequestParam(name = "min_point", required = false) minPoint: Int?,
@RequestParam(name = "max_point", required = false) maxPoint: Int?,
@RequestParam(name = "tag_id", required = false) tagIds: List<UUID>?
): StudentsResponse {
return queryStudentsUseCase.execute(
name = name,
sort = sort,
filterType = filterType,
minPoint = minPoint,
maxPoint = maxPoint,
tagIds = tagIds
)
}

@GetMapping("/{student-id}")
fun getStudentDetails(@PathVariable("student-id") @NotNull studentId: UUID): StudentDetailsResponse {
return queryStudentDetailsUseCase.execute(studentId)
}

@GetMapping("/students/{student-id}")
fun getStudentDetails2(@PathVariable("student-id") @NotNull studentId: UUID): StudentDetailsResponse {
return queryStudentDetailsUseCase.execute(studentId)
}
}
Loading

0 comments on commit 1c5721e

Please sign in to comment.