-
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 #1 from DDD-Community/feature/POLABO-32
feat(POLABO-32): 1차 MVP 기능 개발
- Loading branch information
Showing
34 changed files
with
907 additions
and
9 deletions.
There are no files selected for viewing
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,60 @@ | ||
name: Java CI with Gradle | ||
|
||
on: | ||
pull_request: | ||
branches: [ "dev" ] | ||
|
||
jobs: | ||
build: | ||
## checkout후 자바 21 버전으로 설정을 합니다 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
## gradlew 의 권한을 줍니다. | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
## gradle build | ||
- name: Build with Gradle | ||
run: ./gradlew clean build --debug | ||
env: | ||
DB_URL: ${{ secrets.DB_URL }} | ||
DB_USER: ${{ secrets.DB_USER }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
JASYPT_ENCRYPTOR_PASSWORD: ${{ secrets.JASYPT_ENCRYPTOR_PASSWORD }} | ||
|
||
## 이미지 태그에 시간 설정을 하기위해서 현재 시간을 가져옵니다. | ||
- name: Get current time | ||
uses: 1466587594/get-current-time@v2 | ||
id: current-time | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
utcOffset: "+09:00" | ||
|
||
- name: Show Current Time | ||
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" | ||
## AWS에 로그인. aws-region은 서울로 설정(ap-northeast-2) | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 | ||
## ECR에 로그인 | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
## sample라는 ECR 리파지터리에 현재 시간 태그를 생성하고, 푸쉬 | ||
## 앞의 스탭에서 ${{steps.current-time.outputs.formattedTime}}로 현재 시간을 가져옵니다. | ||
- name: Build, tag, and push image to Amazon ECR | ||
run: | | ||
docker build --build-arg PASSWORD=$PASSWORD -t polabo:${{steps.current-time.outputs.formattedTime}} . | ||
docker tag polabo:${{steps.current-time.outputs.formattedTime}} 058264417437.dkr.ecr.ap-northeast-2.amazonaws.com/polabo:${{steps.current-time.outputs.formattedTime}} | ||
docker push 058264417437.dkr.ecr.ap-northeast-2.amazonaws.com/polabo:${{steps.current-time.outputs.formattedTime}} | ||
env: | ||
PASSWORD: ${{ secrets.JASYPT_ENCRYPTOR_PASSWORD }} |
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,6 @@ | ||
FROM openjdk:21 | ||
ARG JAR_FILE=./build/libs/*SNAPSHOT.jar | ||
ARG PASSWORD | ||
COPY ${JAR_FILE} polabo.jar | ||
ENV JASYPT_ENCRYPTOR_PASSWORD=${PASSWORD} | ||
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} ${ENVIRONMENT_VALUE} -jar /polabo.jar.jar", "-Djasypt.encryptor.password=${JASYPT_ENCRYPTOR_PASSWORD}"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: '3.7' | ||
|
||
services: | ||
mysql: | ||
image: mysql:latest | ||
container_name: polabo_mysql | ||
hostname: polabo_mysql | ||
volumes: | ||
- ./mysqldata:/var/lib/mysql | ||
environment: | ||
- MYSQL_USER=polabo | ||
- MYSQL_PASSWORD=polabo | ||
- MYSQL_ROOT_PASSWORD=polabo | ||
- MYSQL_HOST=localhost | ||
- MYSQL_PORT=3306 | ||
- MYSQL_DATABASE=polabo | ||
ports: | ||
- "3306:3306" | ||
|
||
|
||
# redis: | ||
# image: redis | ||
# container_name: polabo_redis | ||
# hostname: polabo_redis | ||
# ports: | ||
# - "6379:6379" |
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
3 changes: 2 additions & 1 deletion
3
src/main/kotlin/com/ddd/sonnypolabobe/SonnyPolaboBeApplication.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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package com.ddd.sonnypolabobe | ||
|
||
import org.slf4j.LoggerFactory | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
|
||
@SpringBootApplication | ||
class SonnyPolaboBeApplication | ||
|
||
inline fun <reified T> T.logger() = LoggerFactory.getLogger(T::class.java)!! | ||
fun main(args: Array<String>) { | ||
runApplication<SonnyPolaboBeApplication>(*args) | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/BoardController.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,42 @@ | ||
package com.ddd.sonnypolabobe.domain.board.controller | ||
|
||
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardCreateRequest | ||
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardGetResponse | ||
import com.ddd.sonnypolabobe.domain.board.service.BoardService | ||
import com.ddd.sonnypolabobe.global.response.ApplicationResponse | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
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 | ||
|
||
@Tag(name = "Board API", description = "보드 관련 API") | ||
@RestController | ||
@RequestMapping("/api/v1/boards") | ||
class BoardController( | ||
private val boardService: BoardService | ||
) { | ||
@Operation(summary = "보드 생성", description = """ | ||
보드를 생성합니다. | ||
userId는 추후 회원가입 기능이 추가될 것을 대비한 것입니다. 지금은 null로 주세요. | ||
""") | ||
@PostMapping | ||
fun create(@RequestBody request : BoardCreateRequest) | ||
= ApplicationResponse.ok(this.boardService.create(request)) | ||
|
||
@Operation(summary = "보드 조회", description = """ | ||
보드를 조회합니다. | ||
""") | ||
@GetMapping("/{id}") | ||
fun get(@PathVariable id : String) | ||
= ApplicationResponse.ok(this.boardService.getById(id)) | ||
|
||
@Operation(summary = "보드 누적 생성 수 조회", description = """ | ||
보드 누적 생성 수를 조회합니다. | ||
""") | ||
@GetMapping("/total-count") | ||
fun getTotalCount() = ApplicationResponse.ok(this.boardService.getTotalCount()) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardCreateRequest.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,15 @@ | ||
package com.ddd.sonnypolabobe.domain.board.controller.dto | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.Pattern | ||
import java.util.* | ||
|
||
data class BoardCreateRequest( | ||
@Schema(description = "제목", example = "쏘니의 보드") | ||
@field:NotBlank | ||
@field:Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*()_+=-])(?=.*[ㄱ-ㅎㅏ-ㅣ가-힣]).{1,20}$", message = "제목은 국문, 영문, 숫자, 특수문자, 띄어쓰기를 포함한 20자 이내여야 합니다.") | ||
val title: String, | ||
@Schema(description = "작성자 아이디", example = "null", required = false) | ||
val userId: UUID? = null | ||
) |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardGetResponse.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,11 @@ | ||
package com.ddd.sonnypolabobe.domain.board.controller.dto | ||
|
||
import com.ddd.sonnypolabobe.domain.polaroid.controller.dto.PolaroidGetResponse | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class BoardGetResponse( | ||
@Schema(description = "제목", example = "쏘니의 보드") | ||
val title: String, | ||
@Schema(description = "작성자", example = "작성자입니다.") | ||
val items: List<PolaroidGetResponse> | ||
) |
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/entity/BoardEntity.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,15 @@ | ||
package com.ddd.sonnypolabobe.domain.board.entity | ||
|
||
import com.ddd.sonnypolabobe.global.entity.BaseEntity | ||
import com.ddd.sonnypolabobe.global.util.UuidGenerator | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
class BoardEntity() : BaseEntity { | ||
override val id: UUID = UuidGenerator.create() | ||
var title: String = "" | ||
var userId : UUID? = null | ||
override var yn: Boolean = true | ||
override val createdAt: LocalDateTime = LocalDateTime.now() | ||
override var updatedAt: LocalDateTime = LocalDateTime.now() | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/BoardJooqRepository.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,12 @@ | ||
package com.ddd.sonnypolabobe.domain.board.repository | ||
|
||
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardCreateRequest | ||
import org.jooq.Record6 | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
interface BoardJooqRepository { | ||
fun insertOne(request: BoardCreateRequest): ByteArray? | ||
fun selectOneById(id: UUID) : Array<out Record6<String?, Long?, String?, String?, LocalDateTime?, ByteArray?>> | ||
fun selectTotalCount(): Long | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/BoardJooqRepositoryImpl.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,69 @@ | ||
package com.ddd.sonnypolabobe.domain.board.repository | ||
|
||
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardCreateRequest | ||
import com.ddd.sonnypolabobe.domain.board.controller.dto.BoardGetResponse | ||
import com.ddd.sonnypolabobe.global.util.UuidConverter | ||
import com.ddd.sonnypolabobe.global.util.UuidGenerator | ||
import com.ddd.sonnypolabobe.jooq.polabo.tables.Board | ||
import com.ddd.sonnypolabobe.jooq.polabo.tables.Polaroid | ||
import org.jooq.DSLContext | ||
import org.jooq.Record6 | ||
import org.springframework.stereotype.Repository | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
@Repository | ||
class BoardJooqRepositoryImpl( | ||
private val dslContext: DSLContext | ||
) : BoardJooqRepository { | ||
override fun insertOne(request: BoardCreateRequest): ByteArray? { | ||
val jBoard = Board.BOARD | ||
val id = UuidConverter.uuidToByteArray(UuidGenerator.create()) | ||
val insertValue = jBoard.newRecord().apply { | ||
this.id = id | ||
this.title = request.title | ||
this.createdAt = LocalDateTime.now() | ||
this.yn = 1 | ||
this.activeyn = 1 | ||
} | ||
val result = this.dslContext.insertInto(jBoard) | ||
.set(insertValue) | ||
.execute() | ||
|
||
return if (result == 1) id else null | ||
} | ||
|
||
override fun selectOneById(id: UUID): Array<out Record6<String?, Long?, String?, String?, LocalDateTime?, ByteArray?>> { | ||
val jBoard = Board.BOARD | ||
val jPolaroid = Polaroid.POLAROID | ||
return this.dslContext | ||
.select( | ||
jBoard.TITLE, | ||
jPolaroid.ID, | ||
jPolaroid.IMAGE_KEY, | ||
jPolaroid.ONE_LINE_MESSAGE, | ||
jPolaroid.CREATED_AT, | ||
jPolaroid.USER_ID | ||
) | ||
.from(jBoard) | ||
.leftJoin(jPolaroid).on( | ||
jBoard.ID.eq(jPolaroid.BOARD_ID).and(jPolaroid.YN.eq(1)) | ||
.and(jPolaroid.ACTIVEYN.eq(1)) | ||
) | ||
.where( | ||
jBoard.ID.eq(UuidConverter.uuidToByteArray(id)).and(jBoard.YN.eq(1)) | ||
.and(jBoard.ACTIVEYN.eq(1)) | ||
) | ||
.fetchArray() | ||
|
||
} | ||
|
||
override fun selectTotalCount(): Long { | ||
val jBoard = Board.BOARD | ||
return this.dslContext | ||
.selectCount() | ||
.from(jBoard) | ||
.where(jBoard.YN.eq(1).and(jBoard.ACTIVEYN.eq(1))) | ||
.fetchOne(0, Long::class.java) ?: 0 | ||
} | ||
} |
Oops, something went wrong.