Skip to content

Commit

Permalink
fix: apply ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
huGgW committed Sep 18, 2024
1 parent 8caa5be commit d97d4d2
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ProfessorEventService {
@Service
class ProfessorEventServiceImpl(
private val professorRepository: ProfessorRepository,
private val labRepository: LabRepository,
private val labRepository: LabRepository
) : ProfessorEventService {
@EventListener
@Transactional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.wafflestudio.csereal.core.research.api.req

import com.wafflestudio.csereal.core.research.dto.LabProfessorResponse
import com.wafflestudio.csereal.core.resource.attachment.dto.AttachmentResponse

data class CreateLabLanguageReqBody(
val ko: CreateLabReqBody,
val en: CreateLabReqBody,
val en: CreateLabReqBody
)

data class CreateLabReqBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.wafflestudio.csereal.core.research.api.req

data class ModifyLabLanguageReqBody(
val ko: ModifyLabReqBody,
val en: ModifyLabReqBody,
val en: ModifyLabReqBody
)

data class ModifyLabReqBody(
Expand All @@ -15,5 +15,5 @@ data class ModifyLabReqBody(
val websiteURL: String?,
val groupId: Long?,
val professorIds: Set<Long>,
val removePdf: Boolean,
val removePdf: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.wafflestudio.csereal.core.research.dto.LabDto
import com.wafflestudio.csereal.core.research.dto.ResearchDto
import com.wafflestudio.csereal.core.research.dto.ResearchGroupResponse
import com.wafflestudio.csereal.core.research.service.LabService
import com.wafflestudio.csereal.core.research.service.LabServiceImpl
import com.wafflestudio.csereal.core.research.service.ResearchSearchService
import com.wafflestudio.csereal.core.research.service.ResearchService
import jakarta.validation.Valid
Expand All @@ -19,7 +18,7 @@ import org.springframework.web.bind.annotation.*
class ResearchController(
private val researchService: ResearchService,
private val researchSearchService: ResearchSearchService,
private val labService: LabService,
private val labService: LabService
) {
@GetMapping("/groups")
fun readAllResearchGroups(
Expand Down Expand Up @@ -49,7 +48,6 @@ class ResearchController(
return ResponseEntity.ok(labService.readLab(labId))
}


@GetMapping("/search/top")
fun searchTop(
@RequestParam(required = true) keyword: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.springframework.web.multipart.MultipartFile
class ResearchController(
private val researchService: ResearchService,
private val labService: LabService,
private val researchSearchService: ResearchSearchService,
private val researchSearchService: ResearchSearchService
) {
// Research APIs

Expand Down Expand Up @@ -86,14 +86,12 @@ class ResearchController(
@RequestParam(required = false, defaultValue = "ko") language: String
): List<LabDto> = labService.readAllLabs(language)


// TODO: Change to Language Unified API
@GetMapping("/lab/{labId}")
fun readLab(
@PathVariable labId: Long
): LabLanguageDto = labService.readLabLanguage(labId)


@AuthenticatedStaff
@PostMapping("/lab", consumes = ["multipart/form-data"])
fun createLab(
Expand All @@ -107,17 +105,23 @@ class ResearchController(
@AuthenticatedStaff
@PutMapping("/lab/{koreanLabId}/{englishLabId}", consumes = ["multipart/form-data"])
fun updateLab(
@PathVariable @Positive koreanLabId: Long,
@PathVariable @Positive englishLabId: Long,
@Valid @RequestPart("request") request: ModifyLabLanguageReqBody,
@PathVariable @Positive
koreanLabId: Long,
@PathVariable @Positive
englishLabId: Long,
@Valid
@RequestPart("request")
request: ModifyLabLanguageReqBody,
@RequestPart("pdf") pdf: MultipartFile?
): LabLanguageDto = labService.updateLabLanguage(koreanLabId, englishLabId, request, pdf)

@AuthenticatedStaff
@DeleteMapping("/lab/{koreanLabId}/{englishLabId}")
fun deleteLab(
@PathVariable @Positive koreanLabId: Long,
@PathVariable @Positive englishLabId: Long,
@PathVariable @Positive
koreanLabId: Long,
@PathVariable @Positive
englishLabId: Long
) {
labService.deleteLabLanguage(koreanLabId, englishLabId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.wafflestudio.csereal.core.research.database
import com.wafflestudio.csereal.common.config.BaseTimeEntity
import com.wafflestudio.csereal.common.enums.LanguageType
import com.wafflestudio.csereal.core.member.database.ProfessorEntity
import com.wafflestudio.csereal.core.research.dto.LabDto
import com.wafflestudio.csereal.core.research.dto.LabUpdateRequest
import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEntity
import jakarta.persistence.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import jakarta.persistence.*
@Entity(name = "research_language")
@Table(
uniqueConstraints = [
UniqueConstraint(columnNames = ["korean_id", "english_id", "type"]),
UniqueConstraint(columnNames = ["korean_id", "english_id", "type"])
]
)
class ResearchLanguageEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ResearchLanguageCustomRepositoryImpl(
.join(en).on(researchLanguageEntity.englishId.eq(en.id))
.where(
researchLanguageEntity.type.eq(
ResearchRelatedType.LAB,
ResearchRelatedType.LAB
),
researchLanguageEntity.koreanId.eq(id).or(
researchLanguageEntity.englishId.eq(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.wafflestudio.csereal.core.research.dto

data class LabLanguageDto(
val ko: LabDto,
val en: LabDto,
val en: LabDto
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ package com.wafflestudio.csereal.core.research.event
data class LabCreatedEvent(
val id: Long,
val researchId: Long?,
val professorIds: Set<Long>,
val professorIds: Set<Long>
)

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.wafflestudio.csereal.core.research.event
data class LabDeletedEvent(
val id: Long,
val researchId: Long?,
val professorIds: Set<Long>,
val professorIds: Set<Long>
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.wafflestudio.csereal.core.research.event
data class LabModifiedEvent(
val id: Long,
val researchIdModified: Pair<Long?, Long?>,
val professorIdsModified: Pair<Set<Long>, Set<Long>>,
val professorIdsModified: Pair<Set<Long>, Set<Long>>
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface LabEventService {

@Service
class LabEventServiceImpl(
private val labRepository: LabRepository,
private val labRepository: LabRepository
) : LabEventService {
@EventListener
@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class LabServiceImpl(
private val researchRepository: ResearchRepository,
private val professorRepository: ProfessorRepository,
private val endpointProperties: EndpointProperties,
private val applicationEventPublisher: ApplicationEventPublisher,
private val applicationEventPublisher: ApplicationEventPublisher
) : LabService {
// TODO: Solve N+1 Problem
@Transactional(readOnly = true)
Expand Down Expand Up @@ -129,7 +129,7 @@ class LabServiceImpl(
override fun createLab(language: LanguageType, request: CreateLabReqBody, pdf: MultipartFile?): LabDto {
val researchGroup = request.groupId?.let {
researchRepository.findByIdOrNull(request.groupId)
?: throw CserealException.Csereal404("해당 연구그룹을 찾을 수 없습니다.(researchGroupId = ${it})")
?: throw CserealException.Csereal404("해당 연구그룹을 찾을 수 없습니다.(researchGroupId = $it)")
}?.apply {
if (this.postType != ResearchType.GROUPS) {
throw CserealException.Csereal404("해당 id 연구그룹이 아닙니다.(researchGroupId = ${this.id})")
Expand All @@ -156,7 +156,7 @@ class LabServiceImpl(
tel = request.tel,
youtube = request.youtube,
research = researchGroup,
professors = professors.toMutableSet(),
professors = professors.toMutableSet()
).apply {
pdf?.let {
attachmentService.uploadAttachmentInLabEntity(this, it)
Expand All @@ -171,7 +171,7 @@ class LabServiceImpl(
LabCreatedEvent(
newSavedLab.id,
request.groupId,
request.professorIds,
request.professorIds
)
)

Expand All @@ -183,7 +183,7 @@ class LabServiceImpl(
koreanId: Long,
englishId: Long,
request: ModifyLabLanguageReqBody,
pdf: MultipartFile?,
pdf: MultipartFile?
): LabLanguageDto {
val koLabDto = updateLab(LanguageType.KO, koreanId, request.ko, pdf)
val enLabDto = updateLab(LanguageType.EN, englishId, request.en, pdf)
Expand All @@ -204,7 +204,7 @@ class LabServiceImpl(
val oldGroup = labEntity.research
val newGroup = request.groupId?.let {
researchRepository.findByIdAndPostType(it, ResearchType.GROUPS)
?: throw CserealException.Csereal404("해당 연구그룹을 찾을 수 없습니다.(researchGroupId = ${it})")
?: throw CserealException.Csereal404("해당 연구그룹을 찾을 수 없습니다.(researchGroupId = $it)")
}

val oldProfessors = labEntity.professors
Expand Down Expand Up @@ -246,7 +246,7 @@ class LabServiceImpl(
LabModifiedEvent(
labId,
oldGroup?.id to newGroup?.id,
oldProfessors.map { it.id }.toSet() to request.professorIds,
oldProfessors.map { it.id }.toSet() to request.professorIds
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ResearchEventService {
@Service
class ResearchEventServiceImpl(
private val researchRepository: ResearchRepository,
private val labRepository: LabRepository,
private val labRepository: LabRepository
) : ResearchEventService {
@EventListener
@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface ResearchService {
class ResearchServiceImpl(
private val researchRepository: ResearchRepository,
private val researchLanguageRepository: ResearchLanguageRepository,
private val mainImageService: MainImageService,
private val mainImageService: MainImageService
) : ResearchService {
@Transactional
override fun createResearchLanguage(
Expand Down

0 comments on commit d97d4d2

Please sign in to comment.