Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LimiteDiTempo committed Nov 9, 2024
1 parent e54e558 commit 4cb6e77
Show file tree
Hide file tree
Showing 249 changed files with 5,100 additions and 0 deletions.
Empty file added Monologue-AI/api.py
Empty file.
Empty file added Monologue-AI/face.py
Empty file.
Empty file added Monologue-AI/i2i.py
Empty file.
Empty file added Monologue-AI/main.py
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.project.qvickv3.domain.auth.client.api

import com.project.qvickv3.domain.auth.client.request.AdminSignUpRequest
import com.project.qvickv3.domain.auth.client.request.RefreshTokenRequest
import com.project.qvickv3.domain.auth.client.request.SignInRequest
import com.project.qvickv3.domain.auth.client.request.SignUpRequest
import com.project.qvickv3.domain.auth.service.AuthService
import com.project.qvickv3.domain.auth.service.response.JsonWebTokenResponse
import com.project.qvickv3.domain.auth.service.response.RefreshTokenResponse
import com.project.qvickv3.global.common.dto.response.BaseResponse
import com.project.qvickv3.global.common.dto.response.BaseResponseData
import jakarta.validation.Valid
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/auth")
class AuthController (private val authService: AuthService) {

@PostMapping("/sign-up")
@ResponseStatus(HttpStatus.CREATED)
fun signUp(@RequestBody @Valid request: SignUpRequest): BaseResponse {
authService.signUp(request)
return BaseResponse.created("회원가입 성공")
}

@PostMapping("/sign-up/admin")
@ResponseStatus(HttpStatus.CREATED)
fun adminSignUp(@RequestBody @Valid request: AdminSignUpRequest): BaseResponse {
authService.adminSignUp(request)
return BaseResponse.created("회원가입 성공")
}

@PostMapping("/sign-up/teacher")
@ResponseStatus(HttpStatus.CREATED)
fun teacherSignUp(@RequestBody @Valid request: SignUpRequest): BaseResponse {
authService.teacherSignUp(request)
return BaseResponse.created("회원가입 성공")
}

@PostMapping("/sign-in")
fun signIn(@RequestBody @Valid request: SignInRequest): BaseResponseData<JsonWebTokenResponse> {
return BaseResponseData.ok(
message = "로그인 성공",
data = authService.signIn(request))
}

@PostMapping("/refresh")
fun refreshToken(@RequestBody @Valid request: RefreshTokenRequest): BaseResponseData<RefreshTokenResponse> {
return BaseResponseData.ok(
message = "토큰 재발급 성공",
data = authService.refresh(request)
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.project.qvickv3.domain.auth.client.request

import com.fasterxml.jackson.annotation.JsonProperty
import jakarta.validation.constraints.NotBlank

data class RefreshTokenRequest(
@JsonProperty("refreshToken")
val refreshToken: @NotBlank String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.project.qvickv3.domain.auth.client.request

import com.fasterxml.jackson.annotation.JsonProperty
import jakarta.validation.constraints.Email

data class SignInRequest(
@JsonProperty("email")
@field:Email
val email: String,
@JsonProperty("password")
val password: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.project.qvickv3.domain.auth.client.request

import com.fasterxml.jackson.annotation.JsonProperty
import com.project.qvickv3.domain.user.domain.enum.Gender
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.Pattern

data class SignUpRequest(
@JsonProperty("email")
@field:Email
val email: String,
@JsonProperty("name")
val name: String,
@JsonProperty("password")
val password: String,
@JsonProperty("stdId")
val stdId: String,
@JsonProperty("room")
val room: String,
@JsonProperty("phoneNum")
@field:Pattern(regexp = "^\\d{2,3}-\\d{3,4}-\\d{4}$", message = "정해진 핸드폰 양식을 따라주세요 (010-0000-0000)")
val phoneNum:String,
@JsonProperty("gender")
val gender: Gender,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.project.qvickv3.domain.auth.service

import com.project.qvickv3.domain.auth.client.request.AdminSignUpRequest
import com.project.qvickv3.domain.auth.client.request.RefreshTokenRequest
import com.project.qvickv3.domain.auth.client.request.SignInRequest
import com.project.qvickv3.domain.auth.client.request.SignUpRequest
import com.project.qvickv3.domain.auth.service.response.JsonWebTokenResponse
import com.project.qvickv3.domain.auth.service.response.RefreshTokenResponse
import com.project.qvickv3.domain.user.client.dto.User
import com.project.qvickv3.domain.user.domain.enum.Gender
import com.project.qvickv3.domain.user.domain.enum.UserRole
import com.project.qvickv3.domain.user.domain.repository.jpa.UserJpaRepository
import com.project.qvickv3.domain.user.exception.PasswordWrongException
import com.project.qvickv3.domain.user.exception.UserExistException
import com.project.qvickv3.domain.user.exception.UserNotFoundException
import com.project.qvickv3.global.security.jwt.JwtExtract
import com.project.qvickv3.global.security.jwt.JwtProvider
import com.project.qvickv3.global.security.jwt.exception.TokenExpiredException
import com.project.qvickv3.global.security.jwt.exception.error.JwtErrorType
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.stereotype.Service
import java.time.LocalDateTime

@Service
class AuthService (
private val userJpaRepository: UserJpaRepository,
private val encoder: PasswordEncoder,
private val jwtProvider: JwtProvider,
private val jwtExtract: JwtExtract,
) {

fun signUp(request: SignUpRequest) {
if(userJpaRepository.existsByEmailOrStdIdOrPhoneNum(request.email, request.stdId, request.phoneNum)) {
throw UserExistException.EXCEPTION
}
save(request)
}

fun teacherSignUp(request: SignUpRequest) {
if(userJpaRepository.existsByEmail(request.email)) {
throw UserExistException.EXCEPTION
}
save(request)
}

fun adminSignUp(request: AdminSignUpRequest) {
if(userJpaRepository.existsByEmail(request.email)) {
throw UserExistException.EXCEPTION
}
userJpaRepository.save(User.toEntity(User(
email = request.email,
name = request.name,
password = encoder.encode(request.password),
stdId = "",
room = "",
phoneNum = "",
gender = Gender.MALE,
userRole = UserRole.ADMIN,
isChecked = false,
checkedDate = LocalDateTime.now(),
)))
}

fun signIn(request: SignInRequest): JsonWebTokenResponse {
val user: User = userJpaRepository
.findByEmail(request.email)
.map { userEntity -> User.toUser(userEntity) }
.orElseThrow { UserNotFoundException.EXCEPTION }
val password: String = user.password
if (!encoder.matches(request.password, password))
throw PasswordWrongException.EXCEPTION
return JsonWebTokenResponse(
accessToken = jwtProvider.generateAccessToken(request.email, user.userRole),
refreshToken = jwtProvider.generateRefreshToken(request.email, user.userRole),
userRole = user.userRole)
}

fun refresh(request: RefreshTokenRequest): RefreshTokenResponse {
val got = jwtExtract.getToken(request.refreshToken)
val user = jwtExtract.findUserByEmail(got)
if (jwtExtract.checkTokenInfo(got) == JwtErrorType.ExpiredJwtException) {
throw TokenExpiredException.EXCEPTION
}
return RefreshTokenResponse(
jwtProvider.generateAccessToken(user.email, user.userRole),
)
}

fun save(request: SignUpRequest){
userJpaRepository.save(User.toEntity(User(
email = request.email,
name = request.name,
password = encoder.encode(request.password),
stdId = request.stdId,
room = request.room,
phoneNum = request.phoneNum,
gender = request.gender,
userRole = UserRole.USER,
isChecked = false,
checkedDate = LocalDateTime.now(),
)))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.project.qvickv3.domain.auth.service.response

import com.fasterxml.jackson.annotation.JsonInclude
import com.project.qvickv3.domain.user.domain.enum.UserRole
import lombok.Builder

@Builder
@JsonInclude(JsonInclude.Include.NON_EMPTY)
class JsonWebTokenResponse(
val accessToken: String,
val refreshToken: String,
val userRole: UserRole
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.project.qvickv3.domain.auth.service.response

import com.fasterxml.jackson.annotation.JsonInclude
import lombok.Builder

@Builder
@JsonInclude(JsonInclude.Include.NON_EMPTY)
data class RefreshTokenResponse(
val accessToken: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.azure.controller

class AzureController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.azure.service

class AzureService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.SWHackathon.Monologue.domain.health

import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("health")
class HealthController {
@GetMapping
fun health() : String{
return "health check"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.SWHackathon.Monologue.domain.image

data class Image(
val userId: String,

val profileImage: String,

val frameImage: String,

val beforeImage: String,

val resultImage:String,
){
constructor(userId: String?, profileImage: String?, frameImage: String?, beforeImage: String?, resultImage: String?): this (
userId = userId ?: "",
profileImage = profileImage ?: "",
frameImage = frameImage ?: "",
beforeImage = beforeImage ?: "",
resultImage = resultImage ?: ""
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.image

class AfterImageEntity {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.image.after

interface AfterImageRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.image

class BeforeImageEntity {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.image.before

interface BeforeImageRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.image

class FrameImageEntity {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.SWHackathon.Monologue.domain.image.frame

interface FrameImageRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.project.qvickv3.domain.user.client.api

import com.project.qvickv3.domain.user.client.dto.User
import com.project.qvickv3.domain.user.client.dto.request.UserEditRequest
import com.project.qvickv3.domain.user.service.UserService
import com.project.qvickv3.domain.user.usecase.UserUseCase
import com.project.qvickv3.global.common.dto.response.BaseResponse
import com.project.qvickv3.global.common.dto.response.BaseResponseData
import kotlinx.coroutines.flow.merge
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/user")
class UserController(
private val userUseCase: UserUseCase
) {

@PostMapping
fun editUser(@RequestBody request: UserEditRequest): BaseResponse {
userUseCase.editUser(request)
return BaseResponse.ok("유저 정보 수정 완료")
}

@GetMapping
fun getUser(): BaseResponseData<User>{
return BaseResponseData.ok(
message = "유저 프로필 조회 성공",
data = userUseCase.getUser()
)
}

@DeleteMapping
fun deleteUser(): BaseResponse {
userUseCase.deleteUser()
return BaseResponse.ok(message = "회원탈퇴 완료")
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.SWHackathon.Monologue.domain.user.client.dto

data class Profile()
Loading

0 comments on commit 4cb6e77

Please sign in to comment.