...
This commit is contained in:
parent
2e7192f91b
commit
e187006627
@ -7,6 +7,10 @@ import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class GlobalEnvironment : EnvironmentAware {
|
||||
companion object {
|
||||
private val pad = "%7C%2A-%2A%7C"
|
||||
fun padding(key : String) = pad.plus(key).plus(pad)
|
||||
}
|
||||
@Value("\${telegram.bot.key}")
|
||||
var telegramBotKey: String? = ""
|
||||
|
||||
@ -19,8 +23,7 @@ class GlobalEnvironment : EnvironmentAware {
|
||||
@Value("\${weather.api.key}")
|
||||
var weatherApiKey: String? = ""
|
||||
|
||||
private val pad = "%7C%2A-%2A%7C"
|
||||
fun padding(key : String) = pad.plus(key).plus(pad)
|
||||
|
||||
|
||||
override fun setEnvironment(environment: Environment) {
|
||||
println ("telegramBotKey $telegramBotKey")
|
||||
|
||||
@ -70,7 +70,7 @@ class BlogController() {
|
||||
|
||||
@PostMapping("post.ajax")
|
||||
fun post(httpServletRequest: HttpServletRequest, @RequestBody jsonString: String) : ResponseEntity<ResponceResult> {
|
||||
logService.log("${httpServletRequest.requestURI}")
|
||||
logService.log(httpServletRequest.requestURI)
|
||||
logService.log(jsonString)
|
||||
var lResultCode = 0
|
||||
var lResultMsg = "Suscces"
|
||||
|
||||
@ -23,15 +23,12 @@ import kotlin.math.log
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
class UserController {
|
||||
companion object{
|
||||
val EncTypeKey = "enc"
|
||||
val EncType00 = "T0"
|
||||
val EncType11 = "T3"
|
||||
val EncType10 = "T2"
|
||||
val EncType01 = "T1"
|
||||
val ApiKeyWordKey = "keyword"
|
||||
}
|
||||
|
||||
val EncTypeKey = "enc"
|
||||
val EncType00 = "T0"
|
||||
val EncType11 = "T3"
|
||||
val EncType10 = "T2"
|
||||
val EncType01 = "T1"
|
||||
val ApiKeyWordKey = "keyword"
|
||||
@Autowired
|
||||
lateinit var globalEvv : GlobalEnvironment
|
||||
|
||||
@ -57,11 +54,10 @@ class UserController {
|
||||
logService.log(file.absolutePath)
|
||||
vm.modelMap.put(EncTypeKey,EncType11)
|
||||
vm.modelMap.put(ApiKeyWordKey,"JOIN")
|
||||
vm.modelMap.put("title","회원이 들어는 구나~!!")
|
||||
return vm
|
||||
}
|
||||
|
||||
@GetMapping("login","login")
|
||||
@GetMapping("login")
|
||||
fun userLogin(httpServletRequest: HttpServletRequest): ModelAndView {
|
||||
logService.log("onJoin")
|
||||
val vm = ModelAndView("content/user/login")
|
||||
@ -80,7 +76,7 @@ class UserController {
|
||||
@ResponseBody
|
||||
@PostMapping("login.ajax")
|
||||
fun login(httpServletRequest: HttpServletRequest, @RequestBody jsonString: String) : ResponseEntity<ResponceResult> {
|
||||
logService.log("${httpServletRequest.requestURI}")
|
||||
logService.log(httpServletRequest.requestURI)
|
||||
logService.log(jsonString)
|
||||
var lResultCode = 0
|
||||
var lResultMsg = "Suscces"
|
||||
@ -91,16 +87,9 @@ class UserController {
|
||||
logService.log(Gson().toJson(model))
|
||||
model.data?.let { jsonString ->
|
||||
try {
|
||||
val reqString = jsonString.split(globalEvv.padding(model.getKeyword()))
|
||||
val nb = arrayListOf<String>()
|
||||
val na = arrayListOf<String>()
|
||||
reqString[0].replace(globalEvv.padding(model.getKeyword()),"").split("").toList().let { na.addAll(it) }
|
||||
reqString[1].replace(globalEvv.padding(model.getKeyword()),"").split("").toList().let { nb.addAll(it) }
|
||||
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(""))
|
||||
val target = Gson().fromJson(fullData.joinToString(""), User::class.java) ?: User()
|
||||
val originDataString = model.extractData()
|
||||
logService.log(originDataString)
|
||||
val target = Gson().fromJson(originDataString, User::class.java) ?: User()
|
||||
var user = userManager.findById(target.user_id!!)?.block()
|
||||
if (user == null && ((target.user_id?.length ?: 0) > 3 == true)) {
|
||||
user = userManager.findByEmail(target.user_id!!)?.block()
|
||||
@ -124,8 +113,7 @@ class UserController {
|
||||
}
|
||||
}
|
||||
}
|
||||
val responce = ResponseEntity.ok().headers {
|
||||
}.contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
||||
val responce = ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(ResponceResult().apply {
|
||||
this.resultCode = lResultCode
|
||||
this.resultMsg = lResultMsg
|
||||
})
|
||||
@ -147,16 +135,9 @@ class UserController {
|
||||
logService.log(Gson().toJson(model))
|
||||
model.data?.let { jsonString ->
|
||||
try {
|
||||
val reqString = jsonString.split(globalEvv.padding(model.getKeyword()))
|
||||
val nb = arrayListOf<String>()
|
||||
val na = arrayListOf<String>()
|
||||
reqString[0].replace(globalEvv.padding(model.getKeyword()),"").split("").toList().let { na.addAll(it) }
|
||||
reqString[1].replace(globalEvv.padding(model.getKeyword()),"").split("").toList().let { nb.addAll(it) }
|
||||
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(""))
|
||||
val user = Gson().fromJson(fullData.joinToString(""), User::class.java) ?: User()
|
||||
val originDataString = model.extractData()
|
||||
logService.log(originDataString)
|
||||
val user = Gson().fromJson(originDataString, User::class.java) ?: User()
|
||||
if (user.checkValid() == false) {
|
||||
lResultCode = 7009
|
||||
lResultMsg = "user insert Fail Reason : Not Correct Data"
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package kr.lunaticbum.back.lun.model
|
||||
|
||||
import kr.lunaticbum.back.lun.configs.GlobalEnvironment
|
||||
import lombok.Getter
|
||||
|
||||
@Getter
|
||||
@ -9,4 +10,19 @@ class RequestModel {
|
||||
var data : String? = null
|
||||
|
||||
fun getKeyword() = key ?: ""
|
||||
|
||||
fun extractData() : String {
|
||||
data?.let {
|
||||
val reqString = data?.split(GlobalEnvironment.padding(getKeyword()))
|
||||
val nb = arrayListOf<String>()
|
||||
val na = arrayListOf<String>()
|
||||
reqString?.get(0)?.replace(GlobalEnvironment.padding(getKeyword()),"")?.split("")?.toList()?.let { na.addAll(it) }
|
||||
reqString?.get(1)?.replace(GlobalEnvironment.padding(getKeyword()),"")?.split("")?.toList()?.let { nb.addAll(it) }
|
||||
val max = nb.size + na.size
|
||||
val 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()) } } }
|
||||
return fullData.joinToString("")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user