Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rudeh2926 committed Apr 8, 2024
2 parents 420227d + 9e4c673 commit fcb1a72
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 75 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/klint-check.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
name: ktlint
name: Ktlint Ci

on:
pull_request:
branches:
- main
on: [pull_request]

jobs:
ktlint:
name: Check Code Quality
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
java-version: [ 17 ]

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: 'zulu'

- name: Clone repo
uses: actions/checkout@v2
uses: actions/checkout@master
with:
fetch-depth: 1

- name: Setup JDK
uses: actions/setup-java@v2
- name: ktlint
uses: ScaCap/action-ktlint@master
with:
java-version: '17'
distribution: 'adopt'

- name: Run ktlint
run: |
./gradlew ktlintCheck --daemon --parallel --configure-on-demand
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
reporter: github-pr-check # Change review
fail_on_error: true
Binary file added dump.rdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dsm.pick2024.domain.attendance.domain

import dsm.pick2024.domain.afterschool.enums.Status
import java.util.*
import java.util.UUID

data class Attendance(
val id: UUID? = null,
Expand All @@ -10,7 +10,7 @@ data class Attendance(
val classNum: Int,
val num: Int,
val name: String,
val club: String,
val club: String? = null,
val period6: Status,
val period7: Status,
val period8: Status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AttendanceMapper : GenericMapper<AttendanceJpaEntity, Attendance> {
classNum = classNum,
num = num,
name = name,
club = club!!,
club = club,
period6 = period6,
period7 = period7,
period8 = period8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dsm.pick2024.domain.attendance.persistence

import com.querydsl.jpa.impl.JPAQueryFactory
import dsm.pick2024.domain.attendance.domain.Attendance
import dsm.pick2024.domain.attendance.entity.QAttendanceJpaEntity
import dsm.pick2024.domain.attendance.mapper.AttendanceMapper
import dsm.pick2024.domain.attendance.persistence.repository.AttendanceRepository
import dsm.pick2024.domain.attendance.port.out.AttendancePort
Expand All @@ -21,4 +22,19 @@ class AttendancePersistenceAdapter(

override fun findByUserId(userId: UUID) =
attendanceJpaRepository.findByUserId(userId).let { attendanceMapper.toDomain(it) }

override fun findByGradeAndClassNum(
grade: Int,
classNum: Int
) = jpaQueryFactory
.selectFrom(QAttendanceJpaEntity.attendanceJpaEntity)
.where(
QAttendanceJpaEntity.attendanceJpaEntity.grade.eq(grade),
QAttendanceJpaEntity.attendanceJpaEntity.classNum.eq(classNum)
)
.orderBy(
QAttendanceJpaEntity.attendanceJpaEntity.num.asc()
)
.fetch()
.map { attendanceMapper.toDomain(it) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dsm.pick2024.domain.attendance.port.`in`

import dsm.pick2024.domain.attendance.presentation.dto.response.QueryAttendanceResponse

interface QueryClassAttendanceUseCase {
fun queryClassAttendance(
grade: Int,
classNum: Int
): List<QueryAttendanceResponse>
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package dsm.pick2024.domain.attendance.port.out

interface AttendancePort :
SaveAll,
FindByUserIdPort
FindByUserIdPort,
QueryClassAttendancePort
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dsm.pick2024.domain.attendance.port.out

import dsm.pick2024.domain.attendance.domain.Attendance

interface QueryClassAttendancePort {
fun findByGradeAndClassNum(
grade: Int,
classNum: Int
): List<Attendance>
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package dsm.pick2024.domain.attendance.presentation

import dsm.pick2024.domain.attendance.port.`in`.ChangeAttendanceUseCase
import dsm.pick2024.domain.attendance.port.`in`.SaveAllAttendanceUseCase
import dsm.pick2024.domain.attendance.port.`in`.QueryClassAttendanceUseCase
import dsm.pick2024.domain.attendance.presentation.dto.request.ChangeAttendanceRequest
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.PatchMapping
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.RequestParam
import org.springframework.web.bind.annotation.RestController
Expand All @@ -15,17 +16,19 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/attendance")
class AttendanceController(
private val saveAllAttendanceUseCase: SaveAllAttendanceUseCase,
private val changeAttendanceUseCase: ChangeAttendanceUseCase
private val changeAttendanceUseCase: ChangeAttendanceUseCase,
private val queryClassAttendanceUseCase: QueryClassAttendanceUseCase
) {

@Operation(summary = "데이터 저장 api")
@PostMapping("/all")
fun all(@RequestParam(name = "key") key: String) =
saveAllAttendanceUseCase.saveAll(key)

@Operation(summary = "자습 or 방과후 상태관리")
@Operation(summary = "자습 or 동아리 상태관리")
@PatchMapping("/modify")
fun changeAttendance(changeAttendanceRequest: List<ChangeAttendanceRequest>) =
changeAttendanceUseCase.changeAttendance(changeAttendanceRequest)
fun changeAttendance(
@RequestBody changeAttendanceRequest: List<ChangeAttendanceRequest>
) = changeAttendanceUseCase.changeAttendance(changeAttendanceRequest)

@Operation(summary = "자습 교실 별 조회 api")
@GetMapping("/grade")
fun queryClassAttendance(
@RequestParam(name = "grade") grade: Int,
@RequestParam(name = "class_num") classNum: Int
) = queryClassAttendanceUseCase.queryClassAttendance(grade, classNum)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dsm.pick2024.domain.attendance.presentation.dto.response

import dsm.pick2024.domain.afterschool.enums.Status
import java.util.UUID

data class QueryAttendanceResponse(
val id: UUID,
val username: String,
val grade: Int,
val classNum: Int,
val num: Int,
val status8: Status,
val status9: Status,
val status10: Status
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dsm.pick2024.domain.attendance.service

import dsm.pick2024.domain.attendance.port.`in`.QueryClassAttendanceUseCase
import dsm.pick2024.domain.attendance.port.out.QueryClassAttendancePort
import dsm.pick2024.domain.attendance.presentation.dto.response.QueryAttendanceResponse
import org.springframework.stereotype.Service

@Service
class QueryClassAttendanceService(
private val queryClassAttendancePort: QueryClassAttendancePort
) : QueryClassAttendanceUseCase {
override fun queryClassAttendance(
grade: Int,
classNum: Int
) = queryClassAttendancePort.findByGradeAndClassNum(grade, classNum)
.map { it ->
QueryAttendanceResponse(
id = it.userId,
username = it.name,
grade = it.grade,
classNum = it.classNum,
num = it.num,
status8 = it.period8,
status9 = it.period9,
status10 = it.period10
)
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring:
import: "optional:configserver:"
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${DB_URL}
url: jdbc:mysql://mysql.xquare.app:3306/stag_new_pick
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
hikari:
Expand Down

0 comments on commit fcb1a72

Please sign in to comment.