diff --git a/src/main/kotlin/team8/fruitable/FruitableApplication.kt b/src/main/kotlin/team8/fruitable/FruitableApplication.kt index 2608a58..4cf80d6 100644 --- a/src/main/kotlin/team8/fruitable/FruitableApplication.kt +++ b/src/main/kotlin/team8/fruitable/FruitableApplication.kt @@ -2,8 +2,6 @@ package team8.fruitable import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController @SpringBootApplication class FruitableApplication diff --git a/src/main/kotlin/team8/fruitable/controller/action/Account.kt b/src/main/kotlin/team8/fruitable/controller/action/Account.kt index 658e661..0bfbfb5 100644 --- a/src/main/kotlin/team8/fruitable/controller/action/Account.kt +++ b/src/main/kotlin/team8/fruitable/controller/action/Account.kt @@ -33,7 +33,7 @@ class Account(private val repository: AccountRepository) { redirectAttributes: RedirectAttributes, title: String, message: String, - redirect: String = "redirect:/" + redirect: String = "/" ): String { redirectAttributes.addFlashAttribute("title", title) redirectAttributes.addFlashAttribute("message", message) @@ -87,4 +87,4 @@ class Account(private val repository: AccountRepository) { redirect?.let { return it } return "redirect:/" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/team8/fruitable/controller/api/Item.kt b/src/main/kotlin/team8/fruitable/controller/api/Item.kt index a6b9200..b673850 100644 --- a/src/main/kotlin/team8/fruitable/controller/api/Item.kt +++ b/src/main/kotlin/team8/fruitable/controller/api/Item.kt @@ -4,8 +4,8 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RestController import team8.fruitable.datebase.entity.User -import team8.fruitable.datebase.repository.ItemRepository import team8.fruitable.datebase.repository.AccountRepository +import team8.fruitable.datebase.repository.ItemRepository import team8.fruitable.util.ResultBuilderJson @RestController diff --git a/src/main/kotlin/team8/fruitable/controller/page/Error.kt b/src/main/kotlin/team8/fruitable/controller/page/Error.kt index 58c3987..c6e2956 100644 --- a/src/main/kotlin/team8/fruitable/controller/page/Error.kt +++ b/src/main/kotlin/team8/fruitable/controller/page/Error.kt @@ -15,18 +15,14 @@ class Error(private val repository: AccountRepository) : ErrorController { fun error( model: Model, @CookieValue("TOKEN", required = false) token: String?, - @ModelAttribute("title") title: String?, - @ModelAttribute("message") message: String?, - @ModelAttribute("redirect") redirect: String? - ): Model { + @ModelAttribute("title") title: String, + @ModelAttribute("message") message: String, + @ModelAttribute("redirect") redirect: String + ): String { token?.let(repository::findByToken)?.let { model["user"] = it } - - model["error"] = mapOf( - "title" to title, - "message" to message, - "redirect" to redirect - ) - - return model + model["title"] = title.ifEmpty { "页面" } + model["message"] = message.ifEmpty { "未知的页面" } + model["redirect"] = redirect.ifEmpty { "/" } + return "error" } } diff --git a/src/main/kotlin/team8/fruitable/controller/page/Pages.kt b/src/main/kotlin/team8/fruitable/controller/page/Pages.kt index 2abdd83..7b10700 100644 --- a/src/main/kotlin/team8/fruitable/controller/page/Pages.kt +++ b/src/main/kotlin/team8/fruitable/controller/page/Pages.kt @@ -5,8 +5,6 @@ import org.springframework.ui.Model import org.springframework.ui.set import org.springframework.web.bind.annotation.CookieValue import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.servlet.ModelAndView import team8.fruitable.datebase.entity.User import team8.fruitable.datebase.repository.AccountRepository diff --git a/src/main/resources/templates/edit.mustache b/src/main/resources/templates/edit.mustache index f318cf6..adabd0a 100644 --- a/src/main/resources/templates/edit.mustache +++ b/src/main/resources/templates/edit.mustache @@ -1,3 +1,28 @@ + + +
+ +