관리자 시그니처 설정 #172
| @@ -22,11 +22,12 @@ class AdminSignatureCanController(private val service: AdminSignatureCanService) | ||||
|     @PostMapping | ||||
|     fun createSignatureCan( | ||||
|         @RequestParam("can") can: Int, | ||||
|         @RequestParam("time") time: Int, | ||||
|         @RequestParam("image") image: MultipartFile, | ||||
|         @RequestParam("creator_id") creatorId: Long, | ||||
|         @RequestParam("isAdult", required = false) isAdult: Boolean = false | ||||
|     ) = ApiResponse.ok( | ||||
|         service.createSignatureCan(can = can, creatorId = creatorId, image = image, isAdult = isAdult), | ||||
|         service.createSignatureCan(can = can, time = time, creatorId = creatorId, image = image, isAdult = isAdult), | ||||
|         "등록되었습니다." | ||||
|     ) | ||||
|  | ||||
| @@ -34,16 +35,24 @@ class AdminSignatureCanController(private val service: AdminSignatureCanService) | ||||
|     fun modifySignatureCan( | ||||
|         @RequestParam("id") id: Long, | ||||
|         @RequestParam("can", required = false) can: Int?, | ||||
|         @RequestParam("time", required = false) time: Int?, | ||||
|         @RequestParam("image", required = false) image: MultipartFile?, | ||||
|         @RequestParam("isActive", required = false) isActive: Boolean?, | ||||
|         @RequestParam("isAdult", required = false) isAdult: Boolean? | ||||
|     ) = run { | ||||
|         if (can == null && image == null && isActive == null && isAdult == null) { | ||||
|         if (can == null && time == null && image == null && isActive == null && isAdult == null) { | ||||
|             throw SodaException("변경사항이 없습니다.") | ||||
|         } | ||||
|  | ||||
|         ApiResponse.ok( | ||||
|             service.modifySignatureCan(id = id, can = can, image = image, isActive = isActive, isAdult = isAdult), | ||||
|             service.modifySignatureCan( | ||||
|                 id = id, | ||||
|                 can = can, | ||||
|                 time = time, | ||||
|                 image = image, | ||||
|                 isActive = isActive, | ||||
|                 isAdult = isAdult | ||||
|             ), | ||||
|             "수정되었습니다." | ||||
|         ) | ||||
|     } | ||||
|   | ||||
| @@ -30,6 +30,7 @@ class AdminSignatureCanQueryRepositoryImpl( | ||||
|             QGetSignatureCanListItem( | ||||
|                 signatureCan.id, | ||||
|                 signatureCan.can, | ||||
|                 signatureCan.time, | ||||
|                 signatureCan.image.prepend("/").prepend(imageHost), | ||||
|                 signatureCan.isAdult, | ||||
|                 member.nickname | ||||
|   | ||||
| @@ -37,8 +37,10 @@ class AdminSignatureCanService( | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
|     fun createSignatureCan(can: Int, creatorId: Long, image: MultipartFile, isAdult: Boolean) { | ||||
|     fun createSignatureCan(can: Int, time: Int, creatorId: Long, image: MultipartFile, isAdult: Boolean) { | ||||
|         if (creatorId < 1) throw SodaException("올바른 크리에이터를 선택해 주세요.") | ||||
|         if (can <= 0) throw SodaException("1캔 이상 설정할 수 있습니다.") | ||||
|         if (time < 3 || time > 20) throw SodaException("시간은 3초 이상 20초 이하로 설정할 수 있습니다.") | ||||
|  | ||||
|         val creator = memberRepository.findCreatorByIdOrNull(memberId = creatorId) | ||||
|             ?: throw SodaException("올바른 크리에이터를 선택해 주세요.") | ||||
| @@ -60,14 +62,27 @@ class AdminSignatureCanService( | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
|     fun modifySignatureCan(id: Long, can: Int?, image: MultipartFile?, isActive: Boolean?, isAdult: Boolean?) { | ||||
|     fun modifySignatureCan( | ||||
|         id: Long, | ||||
|         can: Int?, | ||||
|         time: Int?, | ||||
|         image: MultipartFile?, | ||||
|         isActive: Boolean?, | ||||
|         isAdult: Boolean? | ||||
|     ) { | ||||
|         val signatureCan = repository.findByIdOrNull(id = id) | ||||
|             ?: throw SodaException("잘못된 요청입니다.") | ||||
|  | ||||
|         if (can != null) { | ||||
|             if (can <= 0) throw SodaException("1캔 이상 설정할 수 있습니다.") | ||||
|             signatureCan.can = can | ||||
|         } | ||||
|  | ||||
|         if (time != null) { | ||||
|             if (time < 3 || time > 20) throw SodaException("시간은 3초 이상 20초 이하로 설정할 수 있습니다.") | ||||
|             signatureCan.time = time | ||||
|         } | ||||
|  | ||||
|         if (isActive != null) { | ||||
|             signatureCan.isActive = isActive | ||||
|         } | ||||
|   | ||||
| @@ -10,6 +10,7 @@ data class GetSignatureCanListResponse( | ||||
| data class GetSignatureCanListItem @QueryProjection constructor( | ||||
|     val id: Long, | ||||
|     val can: Int, | ||||
|     val time: Int, | ||||
|     val image: String, | ||||
|     val isAdult: Boolean, | ||||
|     val nickname: String | ||||
|   | ||||
| @@ -38,12 +38,12 @@ class CreatorAdminSignatureService( | ||||
|  | ||||
|     @Transactional | ||||
|     fun createSignature(can: Int, time: Int, image: MultipartFile, memberId: Long, isAdult: Boolean) { | ||||
|         val member = memberRepository.findCreatorByIdOrNull(memberId = memberId) | ||||
|             ?: throw SodaException("잘못된 접근입니다.") | ||||
|  | ||||
|         if (can <= 0) throw SodaException("1캔 이상 설정할 수 있습니다.") | ||||
|         if (time < 3 || time > 20) throw SodaException("시간은 3초 이상 20초 이하로 설정할 수 있습니다.") | ||||
|  | ||||
|         val member = memberRepository.findCreatorByIdOrNull(memberId = memberId) | ||||
|             ?: throw SodaException("잘못된 접근입니다.") | ||||
|  | ||||
|         val signatureCan = SignatureCan(can = can, time = time, isAdult = isAdult) | ||||
|         signatureCan.creator = member | ||||
|         repository.save(signatureCan) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user