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