This commit is contained in:
lunaticbum 2024-10-05 19:30:38 +09:00
parent b27b9ff60f
commit d5a8e6fd27
2 changed files with 43 additions and 35 deletions

View File

@ -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<ResponceResult> {
logService.log("${httpServletRequest.requestURI}")
logService.log(jsonString)
val reqString = jsonString.split("_||L_")
var nb = arrayListOf<String>()
(reqString[0].replace("_||L_","").split("")).toList().let {
nb.addAll(it)
}
logService.log(nb.toString())
var na = arrayListOf<String>()
reqString[1].replace("_||L_","").split("").toList().let {
na.addAll(it)
}
logService.log(na.toString())
var max = nb.size + na.size
var fullData = arrayListOf<String>()
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<String>()
(reqString[0].replace("_||L_","").split("")).toList().let {
nb.addAll(it)
}
logService.log(nb.toString())
var na = arrayListOf<String>()
reqString[1].replace("_||L_","").split("").toList().let {
na.addAll(it)
}
logService.log(na.toString())
var max = nb.size + na.size
var fullData = arrayListOf<String>()
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

View File

@ -63,15 +63,17 @@
background-color: rgb(61, 135, 255);
}
</style>
<script>
<script th:inline="javascript">
function getDivder() {
return "_||L_"
}
function mergeData(a , b) {
return a.join("") + getDivder() + b.join("")
return btoa(a.join("") + getDivder() + b.join(""))
}
function userJoin() {
var type = [[${ENC}]]
console.log(type)
var httpRequest;
var user_id = document.getElementById("user_id").value;
var user_pw = document.getElementById("user_pw").value;