...
This commit is contained in:
@@ -125,16 +125,14 @@ class BlogController() {
|
||||
return responce
|
||||
}
|
||||
|
||||
@GetMapping("viewer/{blogId}")
|
||||
fun viewer(@PathVariable blogId : String) : ModelAndView{
|
||||
@GetMapping("viewer/{postId}")
|
||||
fun viewer(@PathVariable postId : String) : ModelAndView{
|
||||
val vm = ModelAndView("content/blog/viewer")
|
||||
// when(System.currentTimeMillis() % 5L) {
|
||||
// 0L -> vm.modelMap.put(EncTypeKey,"T4")
|
||||
// 1L -> vm.modelMap.put(EncTypeKey,"T3")
|
||||
// 2L -> vm.modelMap.put(EncTypeKey,"T2")
|
||||
// else -> vm.modelMap.put(EncTypeKey,"T0")
|
||||
// }
|
||||
|
||||
postManageg.getPost(postId).block().apply {
|
||||
this?.title = URLDecoder.decode(this?.title)
|
||||
this?.content = URLDecoder.decode(this?.content)
|
||||
vm.modelMap.put("srcPost",this)
|
||||
}
|
||||
return vm
|
||||
}
|
||||
|
||||
@@ -163,7 +161,11 @@ class BlogController() {
|
||||
@GetMapping("editor/{postId}")
|
||||
fun editor(@PathVariable postId : String, @RequestParam("token") token : String?) : ModelAndView{
|
||||
val vm = ModelAndView("content/blog/editor")
|
||||
vm.modelMap.put("srcPost",postManageg.getPost(postId).block().apply { })
|
||||
postManageg.getPost(postId).block().apply {
|
||||
this?.title = URLDecoder.decode(this?.title)
|
||||
this?.content = URLDecoder.decode(this?.content)
|
||||
vm.modelMap.put("srcPost",this)
|
||||
}
|
||||
if (TEMPTOKEN.equals(token)) {
|
||||
vm.modelMap.put(WRITE_PERMISSION_KEY,"OK")
|
||||
} else {
|
||||
|
||||
@@ -5,10 +5,12 @@ import jakarta.servlet.http.HttpServletResponse
|
||||
import kr.lunaticbum.back.lun.model.PostManageg
|
||||
import kr.lunaticbum.back.lun.utils.LogService
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.web.servlet.ModelAndView
|
||||
import java.net.URLDecoder
|
||||
import java.net.http.HttpClient.Redirect
|
||||
|
||||
@RestController
|
||||
@@ -24,11 +26,14 @@ class Home {
|
||||
@GetMapping("/","/home")
|
||||
fun home() : ModelAndView {
|
||||
val vm = ModelAndView("content/home")
|
||||
vm.modelMap.put("posts", postManageg.find20().apply {
|
||||
vm.modelMap.put("Posts", postManageg.find20(Pageable.ofSize(20)).apply {
|
||||
this.forEach {
|
||||
it.title = URLDecoder.decode(it.title)
|
||||
it.content = URLDecoder.decode(it.content)
|
||||
logService.log(Gson().toJson(it))
|
||||
}
|
||||
})
|
||||
vm.modelMap.put("path","/blog/viewer/")
|
||||
return vm
|
||||
}
|
||||
@GetMapping("/login")
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bson.codecs.pojo.annotations.BsonCreator
|
||||
import org.bson.codecs.pojo.annotations.BsonId
|
||||
import org.bson.codecs.pojo.annotations.BsonRepresentation
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.mongodb.repository.Query
|
||||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository
|
||||
@@ -52,6 +53,7 @@ class Post {
|
||||
@Repository
|
||||
interface PostRepository : ReactiveMongoRepository<Post, String> {
|
||||
fun findAllByModifyTime(time : Long? = 0): Flux<Post>
|
||||
fun findAllByPostingTrue(pageable: Pageable): Flux<Post>
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +69,10 @@ class PostManageg {
|
||||
private lateinit var bCryptPasswordEncoder: PasswordEncoder
|
||||
fun getPost(id : String) : Mono<Post> = postRepository.findById(id)
|
||||
|
||||
fun find20(pageable :Pageable) : List<Post> {
|
||||
return postRepository.findAllByPostingTrue(pageable).takeLast(20).buffer(20).blockLast(Duration.ofSeconds(30)) ?: listOf()
|
||||
}
|
||||
|
||||
fun find20() : List<Post> {
|
||||
return postRepository.findAllByModifyTime(0).takeLast(20).buffer(20).blockLast(Duration.ofSeconds(30)) ?: listOf()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user