Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ class ExcelCellWriter(

dayTotal += male + female
colIndex += 2

if (age == Age.OUT_OF_SCHOOL_YOUTH) {
colIndex += 2
}
Comment on lines +111 to +113
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

νŠΉμ • Age 값에 λŒ€ν•œ λΆ„κΈ° 처리λ₯Ό μœ„ν•΄ if 문을 μ‚¬μš©ν•˜μ…¨μŠ΅λ‹ˆλ‹€. ν˜„μž¬λŠ” 쑰건이 ν•˜λ‚˜λΏμ΄μ§€λ§Œ, ν–₯ν›„ λ‹€λ₯Έ Age 값에 λŒ€ν•œ μ˜ˆμ™Έ μ²˜λ¦¬κ°€ 좔가될 κ°€λŠ₯성을 κ³ λ €ν•˜λ©΄ when ν‘œν˜„μ‹μ„ μ‚¬μš©ν•˜λŠ” 것이 μ½”λ“œμ˜ ν™•μž₯μ„±κ³Ό 가독성 μΈ‘λ©΄μ—μ„œ 더 μœ λ¦¬ν•©λ‹ˆλ‹€. when을 μ‚¬μš©ν•˜λ©΄ μ—¬λŸ¬ 쑰건을 더 μ²΄κ³„μ μœΌλ‘œ 관리할 수 μžˆμŠ΅λ‹ˆλ‹€.

            when (age) {
                Age.OUT_OF_SCHOOL_YOUTH -> colIndex += 2
                else -> { /* No-op */ }
            }

}

if (dayTotal > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import org.aing.danurirest.global.exception.enums.CustomErrorCode
import org.aing.danurirest.persistence.form.entity.Form
import org.aing.danurirest.persistence.space.entity.Space
import org.aing.danurirest.persistence.usage.entity.UsageHistory
import org.aing.danurirest.persistence.user.Age
import org.aing.danurirest.persistence.user.Sex
import org.apache.poi.ss.usermodel.CellStyle
import org.apache.poi.ss.usermodel.Row
import org.apache.poi.ss.usermodel.Sheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
Expand Down Expand Up @@ -127,7 +131,7 @@ class ExcelService(
private fun writeUsageHistoryHeader(
sheet: Sheet,
formLabels: List<String>,
headerStyle: org.apache.poi.ss.usermodel.CellStyle,
headerStyle: CellStyle,
) {
val headerRow = sheet.createRow(0)
val baseHeaders = listOf("곡간 이름", "μ‹œμž‘ μ‹œκ°„", "μ’…λ£Œ μ‹œκ°„", "λŒ€μ—¬ ν•­λͺ© 수", "μ—°λ½μ²˜")
Expand Down Expand Up @@ -200,9 +204,9 @@ class ExcelService(
private fun writeDailyStatisticsData(
sheet: Sheet,
yearMonth: YearMonth,
dailyStats: Map<Int, Map<org.aing.danurirest.persistence.user.Age, Map<org.aing.danurirest.persistence.user.Sex, Int>>>,
redFontStyle: org.apache.poi.ss.usermodel.CellStyle,
blueFontStyle: org.apache.poi.ss.usermodel.CellStyle,
dailyStats: Map<Int, Map<Age, Map<Sex, Int>>>,
redFontStyle: CellStyle,
blueFontStyle: CellStyle,
) {
val daysInMonth = yearMonth.lengthOfMonth()
val year = yearMonth.year
Expand Down Expand Up @@ -280,7 +284,7 @@ class ExcelService(
}
}

private fun convertWorkbookToByteArray(workbook: org.apache.poi.xssf.usermodel.XSSFWorkbook): ByteArray =
private fun convertWorkbookToByteArray(workbook: XSSFWorkbook): ByteArray =
workbook.use { wb ->
ByteArrayOutputStream().use { outputStream ->
wb.write(outputStream)
Expand Down
Loading