-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Professor API 언어 통합 업데이트 (#304)
* refactor: move member search controller to v1 * feat: make a bit more query efficient * feat: change to language merged apis * fix: ktlint issue * fix: fix index columnlist
- Loading branch information
Showing
15 changed files
with
338 additions
and
124 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...in/kotlin/com/wafflestudio/csereal/core/member/api/req/CreateProfessorLanguagesReqBody.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,6 @@ | ||
package com.wafflestudio.csereal.core.member.api.req | ||
|
||
data class CreateProfessorLanguagesReqBody( | ||
val ko: CreateProfessorReqBody, | ||
val en: CreateProfessorReqBody | ||
) |
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
6 changes: 6 additions & 0 deletions
6
...in/kotlin/com/wafflestudio/csereal/core/member/api/req/ModifyProfessorLanguagesReqBody.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,6 @@ | ||
package com.wafflestudio.csereal.core.member.api.req | ||
|
||
data class ModifyProfessorLanguagesReqBody( | ||
val ko: ModifyProfessorReqBody, | ||
val en: ModifyProfessorReqBody | ||
) |
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
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/com/wafflestudio/csereal/core/member/api/v1/ProfessorController.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,34 @@ | ||
package com.wafflestudio.csereal.core.member.api.v1 | ||
|
||
import com.wafflestudio.csereal.core.member.dto.ProfessorDto | ||
import com.wafflestudio.csereal.core.member.dto.ProfessorPageDto | ||
import com.wafflestudio.csereal.core.member.dto.SimpleProfessorDto | ||
import com.wafflestudio.csereal.core.member.service.ProfessorService | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@Deprecated(message = "Use V2 API") | ||
@RequestMapping("/api/v1/professor") | ||
@RestController("ProfessorControllerV1") | ||
class ProfessorController( | ||
private val professorService: ProfessorService | ||
) { | ||
@GetMapping("/{professorId}") | ||
fun getProfessor(@PathVariable professorId: Long): ResponseEntity<ProfessorDto> { | ||
return ResponseEntity.ok(professorService.getProfessor(professorId)) | ||
} | ||
|
||
@GetMapping("/active") | ||
fun getActiveProfessors( | ||
@RequestParam(required = false, defaultValue = "ko") language: String | ||
): ResponseEntity<ProfessorPageDto> { | ||
return ResponseEntity.ok(professorService.getActiveProfessors(language)) | ||
} | ||
|
||
@GetMapping("/inactive") | ||
fun getInactiveProfessors( | ||
@RequestParam(required = false, defaultValue = "ko") language: String | ||
): ResponseEntity<List<SimpleProfessorDto>> { | ||
return ResponseEntity.ok(professorService.getInactiveProfessors(language)) | ||
} | ||
} |
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
56 changes: 55 additions & 1 deletion
56
src/main/kotlin/com/wafflestudio/csereal/core/member/database/ProfessorRepository.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,15 +1,69 @@ | ||
package com.wafflestudio.csereal.core.member.database | ||
|
||
import com.querydsl.core.types.dsl.Expressions | ||
import com.querydsl.jpa.JPAExpressions | ||
import com.querydsl.jpa.impl.JPAQueryFactory | ||
import com.wafflestudio.csereal.common.enums.LanguageType | ||
import com.wafflestudio.csereal.core.member.database.QCareerEntity.careerEntity | ||
import com.wafflestudio.csereal.core.member.database.QEducationEntity.educationEntity | ||
import com.wafflestudio.csereal.core.member.database.QMemberLanguageEntity.memberLanguageEntity | ||
import com.wafflestudio.csereal.core.member.database.QProfessorEntity.professorEntity | ||
import com.wafflestudio.csereal.core.member.database.QResearchAreaEntity.researchAreaEntity | ||
import com.wafflestudio.csereal.core.member.type.MemberType | ||
import com.wafflestudio.csereal.core.research.database.QLabEntity.labEntity | ||
import com.wafflestudio.csereal.core.resource.mainImage.database.QMainImageEntity.mainImageEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
interface ProfessorRepository : JpaRepository<ProfessorEntity, Long> { | ||
interface ProfessorRepository : JpaRepository<ProfessorEntity, Long>, ProfessorRepositoryCustom { | ||
fun findByLanguageAndStatus( | ||
languageType: LanguageType, | ||
status: ProfessorStatus | ||
): List<ProfessorEntity> | ||
|
||
fun findByLanguageAndStatusNot( | ||
languageType: LanguageType, | ||
status: ProfessorStatus | ||
): List<ProfessorEntity> | ||
} | ||
|
||
interface ProfessorRepositoryCustom { | ||
fun findProfessorAllLanguages(id: Long): Map<LanguageType, List<ProfessorEntity>> | ||
} | ||
|
||
@Repository | ||
class ProfessorRepositoryCustomImpl( | ||
private val queryFactory: JPAQueryFactory | ||
) : ProfessorRepositoryCustom { | ||
override fun findProfessorAllLanguages(id: Long): Map<LanguageType, List<ProfessorEntity>> { | ||
val professors = queryFactory.selectFrom(professorEntity) | ||
.where( | ||
professorEntity.id.`in`( | ||
JPAExpressions.select( | ||
memberLanguageEntity.koreanId | ||
).from(memberLanguageEntity) | ||
.where( | ||
memberLanguageEntity.englishId.eq(id), | ||
memberLanguageEntity.type.eq(MemberType.PROFESSOR) | ||
), | ||
JPAExpressions.select( | ||
memberLanguageEntity.englishId | ||
).from(memberLanguageEntity) | ||
.where( | ||
memberLanguageEntity.koreanId.eq(id), | ||
memberLanguageEntity.type.eq(MemberType.PROFESSOR) | ||
), | ||
Expressions.constant(id) | ||
) | ||
).leftJoin(mainImageEntity).fetchJoin() | ||
.leftJoin(labEntity).fetchJoin() | ||
.leftJoin(careerEntity).on(careerEntity.professor.eq(professorEntity)) | ||
.leftJoin(researchAreaEntity).on(researchAreaEntity.professor.eq(professorEntity)) | ||
.leftJoin(educationEntity).on(educationEntity.professor.eq(professorEntity)) | ||
.fetch() | ||
|
||
return professors.groupBy { | ||
it.language | ||
} | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/com/wafflestudio/csereal/core/member/dto/ProfessorLanguagesDto.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,6 @@ | ||
package com.wafflestudio.csereal.core.member.dto | ||
|
||
data class ProfessorLanguagesDto( | ||
val ko: ProfessorDto?, | ||
val en: ProfessorDto? | ||
) |
Oops, something went wrong.