-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from EntryDSM/feature/entry-170-전형-요강-생성-api-개발
🔀 :: (ENTRY-170) 전형 요강 생성 api 개발
- Loading branch information
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/hs/kr/equus/feed/domain/screen/domain/Screen.kt
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 @@ | ||
package hs.kr.equus.feed.domain.screen.domain | ||
|
||
import hs.kr.equus.feed.domain.BaseEntity | ||
import java.util.UUID | ||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
|
||
@Entity(name = "tbl_screen") | ||
class Screen( | ||
|
||
id: UUID? = null, | ||
|
||
val image: String, | ||
|
||
@Column(columnDefinition = "VARCHAR(255)") | ||
val adminId: UUID | ||
) : BaseEntity(id) |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/hs/kr/equus/feed/domain/screen/domain/repository/ScreenRepository.kt
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,7 @@ | ||
package hs.kr.equus.feed.domain.screen.domain.repository | ||
|
||
import hs.kr.equus.feed.domain.screen.domain.Screen | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import java.util.UUID | ||
|
||
interface ScreenRepository : JpaRepository<Screen, UUID> |
25 changes: 25 additions & 0 deletions
25
src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/ScreenController.kt
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,25 @@ | ||
package hs.kr.equus.feed.domain.screen.presentation | ||
|
||
import hs.kr.equus.feed.domain.screen.presentation.dto.response.ScreenResponse | ||
import hs.kr.equus.feed.domain.screen.service.CreateScreenService | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestPart | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
import org.springframework.web.bind.annotation.RestController | ||
import org.springframework.web.multipart.MultipartFile | ||
|
||
@RestController | ||
@RequestMapping("/screen") | ||
class ScreenController( | ||
private val createScreenService: CreateScreenService | ||
) { | ||
|
||
@ResponseStatus(value = HttpStatus.CREATED) | ||
@PostMapping | ||
fun createScreen( | ||
@RequestPart(name = "image") image: MultipartFile | ||
): ScreenResponse = | ||
createScreenService.execute(image) | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/hs/kr/equus/feed/domain/screen/presentation/dto/response/ScreenResponse.kt
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,5 @@ | ||
package hs.kr.equus.feed.domain.screen.presentation.dto.response | ||
|
||
data class ScreenResponse( | ||
val image: String | ||
) |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/hs/kr/equus/feed/domain/screen/service/CreateScreenService.kt
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,33 @@ | ||
package hs.kr.equus.feed.domain.screen.service | ||
|
||
import hs.kr.equus.feed.domain.screen.domain.Screen | ||
import hs.kr.equus.feed.domain.screen.domain.repository.ScreenRepository | ||
import hs.kr.equus.feed.domain.screen.presentation.dto.response.ScreenResponse | ||
import hs.kr.equus.feed.global.utils.user.UserUtils | ||
import hs.kr.equus.feed.infrastructure.s3.PathList | ||
import hs.kr.equus.feed.infrastructure.s3.util.FileUtil | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
import org.springframework.web.multipart.MultipartFile | ||
|
||
@Service | ||
class CreateScreenService( | ||
private val screenRepository: ScreenRepository, | ||
private val fileUtil: FileUtil, | ||
private val userUtils: UserUtils | ||
) { | ||
|
||
@Transactional | ||
fun execute(file: MultipartFile): ScreenResponse { | ||
val adminId = userUtils.getCurrentUser().id | ||
|
||
val fileName = fileUtil.upload(file, PathList.SCREEN) | ||
screenRepository.save( | ||
Screen( | ||
image = fileName, | ||
adminId = adminId | ||
) | ||
) | ||
return ScreenResponse(fileName) | ||
} | ||
} |
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