From d5a8e6fd273531d658d5af26d92fc068039b1b5d Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Sat, 5 Oct 2024 19:30:38 +0900 Subject: [PATCH] ... --- .../back/lun/controllers/UserController.kt | 72 ++++++++++--------- src/main/resources/templates/user/join.html | 6 +- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt index 0af24f9..74c9c32 100644 --- a/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt +++ b/src/main/kotlin/kr/lunaticbum/back/lun/controllers/UserController.kt @@ -8,14 +8,12 @@ import kr.lunaticbum.back.lun.model.User import kr.lunaticbum.back.lun.model.UserManager import kr.lunaticbum.back.lun.utils.LogService import org.springframework.beans.factory.annotation.Autowired -import org.springframework.data.annotation.AccessType import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* import org.springframework.web.reactive.function.client.WebClient import org.springframework.web.servlet.ModelAndView -import org.springframework.web.servlet.function.ServerResponse -import reactor.core.publisher.Mono +import java.util.* @RestController @@ -35,7 +33,12 @@ class UserController { fun hello(httpServletRequest: HttpServletRequest): ModelAndView { logService.log("onJoin") val vm = ModelAndView() - vm.modelMap.put("ddd","asdas") + when(System.currentTimeMillis() % 5L) { + 0L -> vm.modelMap.put("ENC","T4") + 1L -> vm.modelMap.put("ENC","T3") + 2L -> vm.modelMap.put("ENC","T2") + else -> vm.modelMap.put("ENC","T0") + } logService.log("${vm.toString()}") return vm } @@ -48,36 +51,39 @@ class UserController { fun joinUser(httpServletRequest: HttpServletRequest, @RequestBody jsonString: String) : ResponseEntity { logService.log("${httpServletRequest.requestURI}") logService.log(jsonString) - val reqString = jsonString.split("_||L_") - var nb = arrayListOf() - (reqString[0].replace("_||L_","").split("")).toList().let { - nb.addAll(it) - } - logService.log(nb.toString()) - var na = arrayListOf() - reqString[1].replace("_||L_","").split("").toList().let { - na.addAll(it) - } - - logService.log(na.toString()) - var max = nb.size + na.size - var fullData = arrayListOf() - for (idx in 0..max) { - if (idx % 2 == 0) { - if (nb.size > 0) { - fullData.add(nb.removeLast()) - } - } else { - if (na.size > 0) { - fullData.add(na.removeLast()) - } - } - } - logService.log(fullData.joinToString("")) - var user = Gson().fromJson(fullData.joinToString(""), User::class.java) var u : User? = null - if (user.checkValid()) { - u = userManager.save(user).block() + val decodedBytes: ByteArray = Base64.getDecoder().decode(jsonString) + String(decodedBytes)?.let { jsonString -> + val reqString = jsonString.split("_||L_") + var nb = arrayListOf() + (reqString[0].replace("_||L_","").split("")).toList().let { + nb.addAll(it) + } + logService.log(nb.toString()) + var na = arrayListOf() + reqString[1].replace("_||L_","").split("").toList().let { + na.addAll(it) + } + + logService.log(na.toString()) + var max = nb.size + na.size + var fullData = arrayListOf() + for (idx in 0..max) { + if (idx % 2 == 0) { + if (nb.size > 0) { + fullData.add(nb.removeLast()) + } + } else { + if (na.size > 0) { + fullData.add(na.removeLast()) + } + } + } + logService.log(fullData.joinToString("")) + var user = Gson().fromJson(fullData.joinToString(""), User::class.java) + if (user.checkValid()) { + u = userManager.save(user).block() + } } val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply { resultCode = if (u != null) 0 else 8245 diff --git a/src/main/resources/templates/user/join.html b/src/main/resources/templates/user/join.html index a9a5d17..f229c8d 100644 --- a/src/main/resources/templates/user/join.html +++ b/src/main/resources/templates/user/join.html @@ -63,15 +63,17 @@ background-color: rgb(61, 135, 255); } -