diff --git a/src/main/kotlin/team8/fruitable/controller/action/editor/ItemEditorAction.kt b/src/main/kotlin/team8/fruitable/controller/action/editor/ItemEditorAction.kt index a2266e6..bd9b0c1 100644 --- a/src/main/kotlin/team8/fruitable/controller/action/editor/ItemEditorAction.kt +++ b/src/main/kotlin/team8/fruitable/controller/action/editor/ItemEditorAction.kt @@ -56,7 +56,7 @@ class ItemEditorAction( } private fun autoCreateTag(tags: String?): MutableList { - return this.autoCreateTag(tags?.split(" ")) + return this.autoCreateTag(tags?.split(" ")?.filter { it.isEmpty() }) } private fun uploadPicture(file: MultipartFile?): String? { diff --git a/src/main/kotlin/team8/fruitable/controller/page/Pages.kt b/src/main/kotlin/team8/fruitable/controller/page/Pages.kt index 92bda9c..0f3ec3c 100644 --- a/src/main/kotlin/team8/fruitable/controller/page/Pages.kt +++ b/src/main/kotlin/team8/fruitable/controller/page/Pages.kt @@ -17,7 +17,8 @@ class Pages( private val cartRepository: CartRepository, private val itemRepository: ItemRepository, private val bannerRepository: BannerRepository, - private val recommendRepository: RecommendRepository + private val recommendRepository: RecommendRepository, + private val tagRepository: TagRepository ) { private fun getCurrentUser(token: String?): User? { return token?.let(accountRepository::findByToken) @@ -81,6 +82,24 @@ class Pages( ): String { model["isItems"] = true this.getCurrentUser(token)?.let { model["user"] = it } + model["items"] = itemRepository.findAll().filter { !it.isRevoked } + model["tags"] = tagRepository.findAll() + return "items" + } + + @RequestMapping("/items/{tag_id}") + fun items( + model: Model, + attributes: RedirectAttributes, + @CookieValue("TOKEN", required = false) token: String?, + @PathVariable("tag_id") id: Long + ): String { + model["isItems"] = true + this.getCurrentUser(token)?.let { model["user"] = it } + val tag = + tagRepository.findById(id).orElse(null) ?: return error(attributes, "查找物品", "未知的标签", "/items") + model["items"] = tag.items.filter { !it.isRevoked } + model["tags"] = tagRepository.findAll() return "items" } diff --git a/src/main/resources/static/styles/base.less b/src/main/resources/static/styles/base.less index 60d30b1..9f48c3e 100644 --- a/src/main/resources/static/styles/base.less +++ b/src/main/resources/static/styles/base.less @@ -33,9 +33,3 @@ div { color: wheat; font-family: "Normal", system-ui; } - -@media (min-width: 640px) { - #Contents { - width: 640px; - } -} diff --git a/src/main/resources/static/styles/cart.less b/src/main/resources/static/styles/cart.less index 73e6d1b..5c9fd13 100644 --- a/src/main/resources/static/styles/cart.less +++ b/src/main/resources/static/styles/cart.less @@ -52,3 +52,9 @@ } } } + +@media (min-width: 640px) { + #Contents { + width: 640px; + } +} diff --git a/src/main/resources/static/styles/items.less b/src/main/resources/static/styles/items.less new file mode 100644 index 0000000..6f60b4a --- /dev/null +++ b/src/main/resources/static/styles/items.less @@ -0,0 +1,145 @@ +@color_1: rgba(21, 255, 172, 0.8); +@color_2: rgba(0, 225, 145, 0.8); +@color_3: rgb(220, 220, 255); +@color_4: red; +@color_5: grey; +@color_6: gold; +@color_7: rgb(175, 175, 255); +@font_family_1: "Normal", system-ui; +@background_color_1: rgba(0, 60, 130, 0.8); +@background_color_2: rgba(0, 84, 181, 0.8); +@background_color_3: rgba(40, 150, 40, 0.2); + +.Taber { + flex-direction: column; + margin: 10px; + padding: 5px; + height: 80px; + width: 100%; + background-color: teal; + border: 3px @color_1 solid; + border-radius: 15px; + + > .Tab { + flex-direction: row; + overflow: hidden; + + > .TabTitle { + flex: 1; + align-items: center; + justify-content: center; + font-size: 16px; + font-weight: bold; + } + + > .Tags { + flex: 9; + flex-wrap: wrap; + + > .Tag { + margin: 4px 5px; + padding: 2px 5px; + border: 2px @color_2 solid; + border-radius: 10px; + background-color: @background_color_1; + color: wheat; + } + } + } +} + +.Items { + flex-direction: row; + align-items: center; + justify-content: center; + flex-wrap: wrap; + + > .Item { + flex: 0 0 32%; + flex-direction: row; + margin: 5px; + background-color: @background_color_1; + border-radius: 15px; + height: 110px; + + > .Picture { + align-items: center; + justify-content: center; + height: 110px; + width: 110px; + + > img { + max-width: 100px; + max-height: 100px; + object-fit: cover; + margin: 5px; + border-radius: 10px; + } + } + + > .Descriptions { + flex: 1 0; + flex-direction: column; + padding: 5px; + + > span { + font-family: @font_family_1; + } + + > .TitlePrices { + justify-content: space-between; + height: 30px; + + > .Title { + color: @color_3; + font-size: 20px; + overflow: hidden; + text-overflow: ellipsis; + } + + > .Price { + color: @color_4; + font-size: 18px; + font-weight: bold; + } + } + + > .Description { + color: @color_7; + font-size: 16px; + overflow: hidden; + text-overflow: ellipsis; + } + } + + > .Buttons { + padding-left: 10px; + padding-right: 10px; + flex-direction: column; + justify-content: space-around; + + > .Button { + width: 40px; + height: 40px; + background-repeat: no-repeat; + background-color: @background_color_3; + border: 1px solid rgba(100, 255, 100, 0.8); + border-radius: 15px; + } + + > .AddToCart { + background-image: url("../images/add_to_cart.svg"); + } + + > .PlaceAnOrder { + background-image: url("../images/place_an_order.svg"); + } + } + } +} + +@media (min-width: 1280px) { + #Contents { + width: 1280px; + } +} diff --git a/src/main/resources/static/styles/order.less b/src/main/resources/static/styles/order.less index 8257c83..bfbc6fa 100644 --- a/src/main/resources/static/styles/order.less +++ b/src/main/resources/static/styles/order.less @@ -37,3 +37,9 @@ } } } + +@media (min-width: 640px) { + #Contents { + width: 640px; + } +} diff --git a/src/main/resources/templates/header.mustache b/src/main/resources/templates/header.mustache index 59fb135..4b44c00 100644 --- a/src/main/resources/templates/header.mustache +++ b/src/main/resources/templates/header.mustache @@ -4,7 +4,7 @@ -