관리자 - 개인정보처리방침, 이용약관 API
This commit is contained in:
parent
3d514e8ad4
commit
87a5ceee9c
|
@ -0,0 +1,33 @@
|
|||
package kr.co.vividnext.sodalive.member.stipulation
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
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.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/stplat")
|
||||
class StipulationController(private val service: StipulationService) {
|
||||
@PostMapping
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
fun enrollment(@RequestBody request: StipulationDto) = ApiResponse.ok(
|
||||
service.enrollment(request),
|
||||
"등록되었습니다."
|
||||
)
|
||||
|
||||
@PostMapping("/modify")
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
fun modify(@RequestBody request: StipulationModifyRequest) = ApiResponse.ok(
|
||||
service.modify(request),
|
||||
"수정되었습니다."
|
||||
)
|
||||
|
||||
@GetMapping("/terms_of_service")
|
||||
fun getTermsOfService() = ApiResponse.ok(service.getTermsOfService())
|
||||
|
||||
@GetMapping("/privacy_policy")
|
||||
fun getPrivacyPolicy() = ApiResponse.ok(service.getPrivacyPolicy())
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package kr.co.vividnext.sodalive.member.stipulation
|
||||
|
||||
data class StipulationDto(
|
||||
val id: Long = 0,
|
||||
val title: String,
|
||||
val description: String
|
||||
) {
|
||||
constructor(stipulation: Stipulation) : this(stipulation.id!!, stipulation.title, stipulation.description)
|
||||
|
||||
fun toEntity() = Stipulation(title, description)
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.member.stipulation
|
||||
|
||||
data class StipulationModifyRequest(
|
||||
val id: Long,
|
||||
val description: String
|
||||
)
|
|
@ -0,0 +1,38 @@
|
|||
package kr.co.vividnext.sodalive.member.stipulation
|
||||
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.stipulation.StipulationIds.PRIVACY_POLICY_ID
|
||||
import kr.co.vividnext.sodalive.member.stipulation.StipulationIds.TERMS_OF_SERVICE_ID
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
class StipulationService(private val repository: StipulationRepository) {
|
||||
fun enrollment(request: StipulationDto) {
|
||||
repository.save(request.toEntity())
|
||||
}
|
||||
|
||||
fun getTermsOfService(): StipulationDto {
|
||||
val stipulation = repository.findByIdOrNull(TERMS_OF_SERVICE_ID)
|
||||
?: throw SodaException("잘못된 요청입니다\n앱 종료 후 다시 시도해 주세요.")
|
||||
|
||||
return StipulationDto(stipulation)
|
||||
}
|
||||
|
||||
fun getPrivacyPolicy(): StipulationDto {
|
||||
val stipulation = repository.findByIdOrNull(PRIVACY_POLICY_ID)
|
||||
?: throw SodaException("잘못된 요청입니다\n앱 종료 후 다시 시도해 주세요.")
|
||||
|
||||
return StipulationDto(stipulation)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun modify(request: StipulationModifyRequest) {
|
||||
val stipulation = repository.findByIdOrNull(request.id)
|
||||
?: throw SodaException("잘못된 요청입니다\n앱 종료 후 다시 시도해 주세요.")
|
||||
|
||||
stipulation.description = request.description
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue