This commit is contained in:
lunaticbum
2024-10-23 17:06:27 +09:00
parent 69d2df4ac4
commit 21df7cd3c3
12 changed files with 473 additions and 41 deletions
@@ -24,6 +24,8 @@ import org.springframework.web.multipart.MultipartFile
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.servlet.ModelAndView
import java.io.*
import java.net.URLDecoder
import java.text.SimpleDateFormat
import java.util.*
@@ -51,6 +53,7 @@ class BlogController() {
vm.modelMap.put(EncTypeKey, EncType11)
vm.modelMap.put(ApiKeyWordKey,"WRITE")
vm.modelMap.put("title","회원이 들어는 구나~!!")
vm.modelMap.put("defaultTitle","무제(無題) (Untitled, ${SimpleDateFormat("yyyy-MM-dd HH:mm").format(Date())})")
} else {
vm.modelMap.put(WRITE_PERMISSION_KEY,"NO")
}
@@ -70,7 +73,6 @@ class BlogController() {
logService.log(jsonString)
var lResultCode = 0
var lResultMsg = "Suscces"
var u : UserDetails? = null
val decodedBytes: ByteArray = Base64.getDecoder().decode(jsonString)
String(decodedBytes).let {
Gson().fromJson<RequestModel>(it, RequestModel::class.java)?.let { model ->
@@ -87,6 +89,13 @@ class BlogController() {
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(""), Post::class.java) ?: Post()
if (target.writeTime < 1L) {
target.writeTime = System.currentTimeMillis()
} else {
target.originId = target.id
target.id = null
target.modifyTime = System.currentTimeMillis()
}
var user = postManageg.save(target)
if (user != null) {
lResultMsg = "save post"
@@ -124,6 +133,25 @@ class BlogController() {
return vm
}
@GetMapping("modify")
fun modify() : ModelAndView{
logService.log("incoming modify")
val vm = ModelAndView("content/blog/modify")
postManageg.find20()?.apply {
forEach { it.title = URLDecoder.decode(it.title)}
vm.modelMap.put("posts",this)
}
return vm
}
@GetMapping("editor/{postId}")
fun editor(@PathVariable postId : String) : ModelAndView{
val vm = ModelAndView("content/blog/editor")
return vm
}
@GetMapping("recent")
fun recent() : ModelAndView{
val vm = ModelAndView("content/blog/viewer")
@@ -29,14 +29,22 @@ class Post {
@BsonRepresentation(BsonType.OBJECT_ID)
var id: String? = null
var originId: String? = null
var title : String? = null
var content : String? = null
var category : String? = null
var tags : String? = null
var writer : String? = null
var writeTime : Long = 0
var modifyTime : Long = 0
var posting : Boolean = false
var firstPostLat : Double = 0.0
var firstPostLon : Double = 0.0
var modifyTime : Long = 0
var modifyLat : Double = 0.0
var modifyLon : Double = 0.0
}