Skip to content

Commit

Permalink
prod deploy (#320)
Browse files Browse the repository at this point in the history
* 교과목 정렬, 쿠키 secure 옵션 추가 (#308)

* feat: 교과목 정렬

* feat: 쿠키 secure 옵션 추가

* referrer policy 헤더 추가 (#311)

* referrer policy 헤더 추가

* 헤더 수정

* feat: scholarship CRUD (#309)

* feat: scholarship CRUD

* 불필요한 라인 삭제

* 리뷰 반영

* Update deploy_dev.yaml

* 강의실 예약 제한 (#312)

* feat: 소개 탭 CRUD (#314)

* feat: 소개 탭 CRUD

* fix: 권한 체크 추가

* fix: 동아리 id 기준으로 로직 변경

* fix: 쿠키 same-site: strict

* 리뷰 반영

* 리뷰 반영

* 로그인 핫픽스 (#316)

* Feat: Research Group & Center 언어포함 CRUD 생성 (#315)

* refactor: deprecated v1 controller

* refactor: extract types in seperate package, remove unused attachment from research

* feat: make lab's research as nullable

* feat: add research language entity & repository

* feat: add language & sealed dtos

* feat: remove migrate methods & seperate update index methods

* feat: add CRUD language considered methods

* feat: add v2 reserach controller

* fix: fix test compiling

* test: fix professerservice test

* refactor: fix ktlint formatting

* review: research -> fetch lazy

* Refactor: 구성원 POST API image => mainImage 리펙토링 #317

* Refactor: PUT API newImage => newMainImage 수정 #318

* Feat: Lab CRUD (#319)

* feat: add request body

* feat: modify dto nullability

* feat: extract lab service && implement CRUD

* feat: add lab language dto

* feat: add lab events

* fix: fix unique constraints for research language entity

* feat: add methods to repositories

* feat: add LAB CRUD APIs

* refactor: seperate event services

* refactor: professors to mutable var

* fix: fix typos

* comment: add comment to professor service method

* test: remove unneed test file

* feat: split search service and event service

* feat: implement professor, research event service

* fix: apply ktlint

* cascade 제거 (#321)

* cascade 제거

* 이미지 제거 추가

---------

Co-authored-by: Junhyeong Kim <[email protected]>
  • Loading branch information
huGgW and leeeryboy authored Sep 23, 2024
1 parent 08586b7 commit facc71f
Show file tree
Hide file tree
Showing 58 changed files with 2,158 additions and 1,623 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.wafflestudio.csereal.core.about.api.req

data class CreateClubReq(
val ko: ClubReqBody,
val en: ClubReqBody
)

data class ClubReqBody(
val name: String,
val description: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.wafflestudio.csereal.core.about.api.req

data class CreateCompanyReq(
val name: String,
val url: String?,
val year: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.wafflestudio.csereal.core.about.api.req

data class CreateFacReq(
val ko: FacDto,
val en: FacDto
)

data class FacDto(
val name: String,
val description: String,
val locations: MutableList<String>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.wafflestudio.csereal.core.about.api.req

data class UpdateAboutReq(
val ko: BasicAbout,
val en: BasicAbout,
val removeImage: Boolean
)

data class BasicAbout(
val description: String,
val deleteIds: List<Long>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.wafflestudio.csereal.core.about.api.req

import com.wafflestudio.csereal.core.about.dto.ClubDto

data class UpdateClubReq(
val ko: ClubDto,
val en: ClubDto,
val removeImage: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.wafflestudio.csereal.core.about.api.req

data class UpdateDescriptionReq(
val koDescription: String,
val enDescription: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.wafflestudio.csereal.core.about.api.req

data class UpdateFacReq(
val ko: FacDto,
val en: FacDto,
val removeImage: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package com.wafflestudio.csereal.core.about.api
package com.wafflestudio.csereal.core.about.api.v1

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.common.enums.LanguageType
import com.wafflestudio.csereal.core.about.api.req.*
import com.wafflestudio.csereal.core.about.api.res.AboutSearchResBody
import com.wafflestudio.csereal.core.about.dto.*
import com.wafflestudio.csereal.core.about.dto.AboutRequest
import com.wafflestudio.csereal.core.about.dto.FutureCareersRequest
import com.wafflestudio.csereal.core.about.service.AboutService
import jakarta.validation.Valid
import jakarta.validation.constraints.Positive
import org.springframework.context.annotation.Profile
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile

@RequestMapping("/api/v1/about")
@RestController
@RestController("AboutControllerV1")
class AboutController(
private val aboutService: AboutService
) {
Expand All @@ -24,18 +20,6 @@ class AboutController(
// postType: directions / name -> by-public-transit, by-car, from-far-away

// Todo: 학부장 인사말(greetings) signature
@AuthenticatedStaff
@PostMapping("/{postType}")
fun createAbout(
@PathVariable postType: String,
@Valid
@RequestPart("request")
request: AboutDto,
@RequestPart("mainImage") mainImage: MultipartFile?,
@RequestPart("attachments") attachments: List<MultipartFile>?
): ResponseEntity<AboutDto> {
return ResponseEntity.ok(aboutService.createAbout(postType, request, mainImage, attachments))
}

// read 목록이 하나
@GetMapping("/{postType}")
Expand All @@ -46,6 +30,7 @@ class AboutController(
return ResponseEntity.ok(aboutService.readAbout(language, postType))
}

@Deprecated("Use V2 API")
@GetMapping("/student-clubs")
fun readAllClubs(
@RequestParam(required = false, defaultValue = "ko") language: String
Expand Down Expand Up @@ -101,56 +86,4 @@ class AboutController(
pageNum,
amount
)

@Profile("!prod")
@PostMapping("/migrate")
fun migrateAbout(
@RequestBody requestList: List<AboutRequest>
): ResponseEntity<List<AboutDto>> {
return ResponseEntity.ok(aboutService.migrateAbout(requestList))
}

@Profile("!prod")
@PostMapping("/future-careers/migrate")
fun migrateFutureCareers(
@RequestBody request: FutureCareersRequest
): ResponseEntity<FutureCareersPage> {
return ResponseEntity.ok(aboutService.migrateFutureCareers(request))
}

@Profile("!prod")
@PostMapping("/student-clubs/migrate")
fun migrateStudentClubs(
@RequestBody requestList: List<StudentClubDto>
): ResponseEntity<List<StudentClubDto>> {
return ResponseEntity.ok(aboutService.migrateStudentClubs(requestList))
}

@Profile("!prod")
@PostMapping("/facilities/migrate")
fun migrateFacilities(
@RequestBody requestList: List<FacilityDto>
): ResponseEntity<List<FacilityDto>> {
return ResponseEntity.ok(aboutService.migrateFacilities(requestList))
}

@Profile("!prod")
@PostMapping("/directions/migrate")
fun migrateDirections(
@RequestBody requestList: List<DirectionDto>
): ResponseEntity<List<DirectionDto>> {
return ResponseEntity.ok(aboutService.migrateDirections(requestList))
}

@Profile("!prod")
@PatchMapping("/migrateImage/{aboutId}")
fun migrateAboutImageAndAttachment(
@PathVariable aboutId: Long,
@RequestPart("mainImage") mainImage: MultipartFile?,
@RequestPart("attachments") attachments: List<MultipartFile>?
): ResponseEntity<AboutDto> {
return ResponseEntity.ok(
aboutService.migrateAboutImageAndAttachments(aboutId, mainImage, attachments)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.wafflestudio.csereal.core.about.api.v2

import com.wafflestudio.csereal.common.aop.AuthenticatedStaff
import com.wafflestudio.csereal.core.about.api.req.*
import com.wafflestudio.csereal.core.about.dto.GroupedClubDto
import com.wafflestudio.csereal.core.about.service.AboutService
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile

@RequestMapping("/api/v2/about")
@RestController
class AboutController(
private val aboutService: AboutService
) {
@GetMapping("/student-clubs")
fun readAllClubs(): List<GroupedClubDto> = aboutService.readAllGroupedClubs()

@AuthenticatedStaff
@PostMapping("/student-clubs")
fun createClub(
@RequestPart request: CreateClubReq,
@RequestPart mainImage: MultipartFile?
) = aboutService.createClub(request, mainImage)

@AuthenticatedStaff
@PutMapping("/student-clubs")
fun updateClub(
@RequestPart request: UpdateClubReq,
@RequestPart newMainImage: MultipartFile?
) = aboutService.updateClub(request, newMainImage)

@AuthenticatedStaff
@DeleteMapping("/student-clubs/{id}")
fun deleteClub(@PathVariable id: Long) = aboutService.deleteClub(id)

@AuthenticatedStaff
@PutMapping("/{postType}")
fun updateAbout(
@PathVariable postType: String,
@RequestPart request: UpdateAboutReq,
@RequestPart newMainImage: MultipartFile?,
@RequestPart newAttachments: List<MultipartFile>?
) = aboutService.updateAbout(postType, request, newMainImage, newAttachments)

@AuthenticatedStaff
@PostMapping("/facilities")
fun createFacilities(@RequestPart request: CreateFacReq, @RequestPart mainImage: MultipartFile?) =
aboutService.createFacilities(request, mainImage)

@AuthenticatedStaff
@PutMapping("/facilities/{id}")
fun updateFacility(
@PathVariable id: Long,
@RequestPart request: UpdateFacReq,
@RequestPart newMainImage: MultipartFile?
) = aboutService.updateFacility(id, request, newMainImage)

@AuthenticatedStaff
@DeleteMapping("/facilities/{id}")
fun deleteFacility(@PathVariable id: Long) = aboutService.deleteFacility(id)

@AuthenticatedStaff
@PutMapping("/directions/{id}")
fun updateDirection(@PathVariable id: Long, @RequestBody request: UpdateDescriptionReq) =
aboutService.updateDirection(id, request)

@AuthenticatedStaff
@PutMapping("/future-careers")
fun updateFutureCareersPage(@RequestBody request: UpdateDescriptionReq) =
aboutService.updateFutureCareersPage(request)

@AuthenticatedStaff
@PostMapping("/future-careers/company")
fun createCompany(@RequestBody request: CreateCompanyReq) = aboutService.createCompany(request)

@AuthenticatedStaff
@PutMapping("/future-careers/company/{id}")
fun updateCompany(@PathVariable id: Long, @RequestBody request: CreateCompanyReq) =
aboutService.updateCompany(id, request)

@AuthenticatedStaff
@DeleteMapping("/future-careers/company/{id}")
fun deleteCompany(@PathVariable id: Long) = aboutService.deleteCompany(id)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ class AboutEntity(
@Column(columnDefinition = "mediumText")
var description: String,

var year: Int?,

@Column(columnDefinition = "TEXT")
@Convert(converter = StringListConverter::class)
var locations: MutableList<String> = mutableListOf(),

@OneToMany(mappedBy = "about", cascade = [CascadeType.ALL], orphanRemoval = true)
var attachments: MutableList<AttachmentEntity> = mutableListOf(),

@OneToOne
@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL], orphanRemoval = true)
var mainImage: MainImageEntity? = null,

@Column(columnDefinition = "TEXT")
Expand All @@ -52,7 +50,6 @@ class AboutEntity(
language = languageType,
name = aboutDto.name,
description = aboutDto.description,
year = aboutDto.year,
locations = aboutDto.locations?.toMutableList() ?: mutableListOf(),
searchContent = ""
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.wafflestudio.csereal.core.about.database

import com.wafflestudio.csereal.common.config.BaseTimeEntity
import jakarta.persistence.*

@Entity(name = "about_language")
class AboutLanguageEntity(
@OneToOne
@JoinColumn(name = "korean_id")
val koAbout: AboutEntity,

@OneToOne
@JoinColumn(name = "english_id")
val enAbout: AboutEntity
) : BaseTimeEntity()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.wafflestudio.csereal.core.about.database

import org.springframework.data.jpa.repository.JpaRepository

interface AboutLanguageRepository : JpaRepository<AboutLanguageEntity, Long> {
fun findByKoAbout(koAboutEntity: AboutEntity): AboutLanguageEntity?
fun findByEnAbout(enAboutEntity: AboutEntity): AboutLanguageEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface AboutRepository : JpaRepository<AboutEntity, Long>, AboutCustomReposit
languageType: LanguageType,
postType: AboutPostType
): List<AboutEntity>

fun findByLanguageAndPostType(
languageType: LanguageType,
postType: AboutPostType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.wafflestudio.csereal.core.about.database
import org.springframework.data.jpa.repository.JpaRepository

interface CompanyRepository : JpaRepository<CompanyEntity, Long> {
fun findAllByOrderByYearDesc(): List<CompanyEntity>
fun findAllByOrderByNameDesc(): List<CompanyEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ data class AboutDto(
val language: String,
val name: String?,
val description: String,
val year: Int?,
val createdAt: LocalDateTime?,
val modifiedAt: LocalDateTime?,
val locations: List<String>?,
Expand All @@ -30,7 +29,6 @@ data class AboutDto(
language = LanguageType.makeLowercase(this.language),
name = this.name,
description = this.description,
year = this.year,
createdAt = this.createdAt,
modifiedAt = this.modifiedAt,
locations = this.locations,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wafflestudio.csereal.core.about.dto

import com.wafflestudio.csereal.core.about.database.AboutEntity

data class GroupedClubDto(
val ko: ClubDto,
val en: ClubDto
)

data class ClubDto(
val id: Long,
val name: String,
val description: String,
val imageURL: String?
) {
companion object {
fun of(aboutEntity: AboutEntity, imageURL: String?): ClubDto {
return ClubDto(aboutEntity.id, aboutEntity.name!!, aboutEntity.description, imageURL)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ data class StudentClubDto(
val name: String,
val engName: String,
val description: String,
val year: Int?,
val createdAt: LocalDateTime?,
val modifiedAt: LocalDateTime?,
val locations: List<String>?,
Expand All @@ -34,7 +33,6 @@ data class StudentClubDto(
name = name,
engName = engName,
description = this.description,
year = this.year,
createdAt = this.createdAt,
modifiedAt = this.modifiedAt,
locations = this.locations,
Expand Down
Loading

0 comments on commit facc71f

Please sign in to comment.