update editor page, fix many bug
Signed-off-by: Puqns67 <me@puqns67.icu>
This commit is contained in:
parent
a5c0f4c35c
commit
ccadbd8160
Before Width: | Height: | Size: 937 B After Width: | Height: | Size: 937 B |
@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes
|
||||
import team8.fruitable.controller.util.Util.Companion.error
|
||||
import team8.fruitable.controller.util.error
|
||||
import team8.fruitable.datebase.entity.User
|
||||
import team8.fruitable.datebase.repository.AccountRepository
|
||||
|
||||
|
@ -5,15 +5,16 @@ import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes
|
||||
import team8.fruitable.controller.util.Util.Companion.error
|
||||
import team8.fruitable.controller.util.error
|
||||
import team8.fruitable.datebase.entity.Item
|
||||
import team8.fruitable.datebase.entity.Tag
|
||||
import team8.fruitable.datebase.entity.User
|
||||
import team8.fruitable.datebase.repository.AccountRepository
|
||||
import team8.fruitable.datebase.repository.ItemRepository
|
||||
import team8.fruitable.datebase.repository.TagRepository
|
||||
import team8.fruitable.util.hash
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.io.path.Path
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/action/edit/item")
|
||||
@ -39,12 +40,12 @@ class ItemEditor(
|
||||
|
||||
private fun autoCreateTag(tags: List<String>): MutableList<Tag> {
|
||||
val result: MutableList<Tag> = mutableListOf()
|
||||
for (i in tags) {
|
||||
val oldTag = tagRepository.findByName(i);
|
||||
tags.forEach {
|
||||
val oldTag = tagRepository.findByName(it)
|
||||
if (oldTag != null) {
|
||||
result.add(oldTag)
|
||||
} else {
|
||||
val newTag = Tag(i)
|
||||
val newTag = Tag(it)
|
||||
tagRepository.save(newTag)
|
||||
result.add(newTag)
|
||||
}
|
||||
@ -56,10 +57,11 @@ class ItemEditor(
|
||||
return this.autoCreateTag(tags.split(" "))
|
||||
}
|
||||
|
||||
private fun uploadPicture(file: MultipartFile): String {
|
||||
val uuid = UUID.randomUUID().toString()
|
||||
file.transferTo(File("${pictureUploadPath}${File.separator}${uuid}"))
|
||||
return uuid
|
||||
private fun uploadPicture(file: MultipartFile): String? {
|
||||
if (file.isEmpty) return null
|
||||
val hash = hash(file)
|
||||
file.transferTo(Path("${pictureUploadPath}${File.separator}${hash}"))
|
||||
return hash
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@ -74,8 +76,9 @@ class ItemEditor(
|
||||
@RequestParam("redirect", required = false) redirect: String?
|
||||
): String {
|
||||
if (!this.hasAdminPermissions(token)) return error(attributes, "创建商品", "账户无权限")
|
||||
if (name.isBlank()) return error(attributes, "更新商品", "商品名不能为空")
|
||||
if (price == 0.0) return error(attributes, "更新商品", "商品价格不能为0")
|
||||
if (name.isBlank()) return error(attributes, "创建商品", "商品名不能为空")
|
||||
if (price == 0.0) return error(attributes, "创建商品", "商品价格不能为0")
|
||||
if (picture.isEmpty) return error(attributes, "创建商品", "必须上传商品图片")
|
||||
itemRepository.save(Item(name, price, description, uploadPicture(picture), tag?.let { this.autoCreateTag(it) }))
|
||||
redirect?.let { return "redirect:/${it}" }
|
||||
return "redirect:/editor?use=item"
|
||||
@ -97,7 +100,12 @@ class ItemEditor(
|
||||
if (name.isBlank()) return error(attributes, "更新商品", "商品名不能为空")
|
||||
if (price == 0.0) return error(attributes, "更新商品", "商品价格不能为0")
|
||||
val item = itemRepository.findById(id).orElse(null) ?: return error(attributes, "更新商品", "未找到目标商品")
|
||||
item.update(name, price, description, picture?.let { uploadPicture(it) }, tag?.let { this.autoCreateTag(it) })
|
||||
item.update(
|
||||
name,
|
||||
price,
|
||||
description,
|
||||
picture?.let { this.uploadPicture(it) },
|
||||
tag?.let { this.autoCreateTag(it) })
|
||||
itemRepository.save(item)
|
||||
redirect?.let { return "redirect:/${it}" }
|
||||
return "redirect:/editor?use=item"
|
||||
|
@ -5,7 +5,7 @@ import jakarta.servlet.http.HttpServletResponse
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes
|
||||
import team8.fruitable.controller.util.Util.Companion.error
|
||||
import team8.fruitable.controller.util.error
|
||||
import team8.fruitable.datebase.entity.User
|
||||
import team8.fruitable.datebase.repository.AccountRepository
|
||||
|
||||
@ -64,8 +64,14 @@ class UserEditor(private val accountRepository: AccountRepository) {
|
||||
): String {
|
||||
val currentUser = this.getCurrentUser(token) ?: return error(attributes, "更新用户", "账户未登录")
|
||||
if (!this.hasAdminPermissions(currentUser)) return error(attributes, "更新用户", "账户无权限")
|
||||
val user = accountRepository.findById(id).orElse(null) ?: return error(attributes, "更新用户", "未找到此用户", "/editor?use=user")
|
||||
val user = accountRepository.findById(id).orElse(null) ?: return error(
|
||||
attributes,
|
||||
"更新用户",
|
||||
"未找到此用户",
|
||||
"/editor?use=user"
|
||||
)
|
||||
user.update(name, password, age, gender, phone, email, address, isAdmin)
|
||||
accountRepository.save(user)
|
||||
if (currentUser.id == id) {
|
||||
val cookie = Cookie("TOKEN", user.token)
|
||||
cookie.path = "/"
|
||||
@ -86,7 +92,12 @@ class UserEditor(private val accountRepository: AccountRepository) {
|
||||
val currentUser = this.getCurrentUser(token) ?: return error(attributes, "删除用户", "账户未登录")
|
||||
if (!this.hasAdminPermissions(currentUser)) return error(attributes, "删除用户", "账户无权限")
|
||||
if (currentUser.id == id) return error(attributes, "删除用户", "无法删除当前使用的账户", "/editor?use=user")
|
||||
val user = accountRepository.findById(id).orElse(null) ?: return error(attributes, "删除用户", "未找到此用户", "/editor?use=user")
|
||||
val user = accountRepository.findById(id).orElse(null) ?: return error(
|
||||
attributes,
|
||||
"删除用户",
|
||||
"未找到此用户",
|
||||
"/editor?use=user"
|
||||
)
|
||||
accountRepository.delete(user)
|
||||
redirect?.let { return "redirect:/${it}" }
|
||||
return "redirect:/editor?use=user"
|
||||
|
@ -8,7 +8,7 @@ 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.mvc.support.RedirectAttributes
|
||||
import team8.fruitable.controller.util.Util
|
||||
import team8.fruitable.controller.util.error
|
||||
import team8.fruitable.datebase.entity.User
|
||||
import team8.fruitable.datebase.repository.AccountRepository
|
||||
import team8.fruitable.datebase.repository.ItemRepository
|
||||
@ -20,8 +20,8 @@ import team8.fruitable.datebase.repository.PagebleItemRepository
|
||||
class Editor(
|
||||
private val accountRepository: AccountRepository,
|
||||
private val itemRepository: ItemRepository,
|
||||
private val pagebleAccountRepository: PagebleAccountRepository,
|
||||
private val pagebleItemRepository: PagebleItemRepository
|
||||
private val pagingAccountRepository: PagebleAccountRepository,
|
||||
private val pagingItemRepository: PagebleItemRepository
|
||||
) {
|
||||
private fun getCurrentUser(token: String?): User? {
|
||||
return token?.let(accountRepository::findByToken)
|
||||
@ -74,15 +74,17 @@ class Editor(
|
||||
@RequestParam("search_content", required = false) searchContent: String?,
|
||||
@RequestParam("page", required = false) page: Int?,
|
||||
): String {
|
||||
val user = this.getCurrentUser(token) ?: return Util.error(attributes, "更新", "账户未登录", "/login")
|
||||
if (!this.hasAdminPermissions(user)) return Util.error(attributes, "编辑", "账户无权限编辑网站")
|
||||
val user = this.getCurrentUser(token) ?: return error(attributes, "编辑", "账户未登录", "/login")
|
||||
if (!this.hasAdminPermissions(user)) return error(attributes, "编辑", "账户无权限编辑网站")
|
||||
model["isEditor"] = true
|
||||
model["user"] = user
|
||||
model["using"] = use
|
||||
model["tabs"] = editorTabs
|
||||
if (searchContent != null) model["searching"] = searchContent
|
||||
val pageRequested = PageRequest.of(page ?: 0, 15)
|
||||
val data = when (use) {
|
||||
"item" -> pagebleItemRepository.findAll(pageRequested)
|
||||
else -> pagebleAccountRepository.findAll(pageRequested)
|
||||
"item" -> pagingItemRepository.findAll(pageRequested)
|
||||
else -> pagingAccountRepository.findAll(pageRequested)
|
||||
}
|
||||
model["data"] = data
|
||||
model["pages"] = (page ?: 0).let {
|
||||
@ -115,15 +117,15 @@ class Editor(
|
||||
"item" -> {
|
||||
target?.let {
|
||||
itemRepository.findById(it)
|
||||
.orElse(null) ?: return Util.error(attributes, "编辑", "无法找到目标商品")
|
||||
} ?: return Util.error(attributes, "编辑", "目标商品为空")
|
||||
.orElse(null) ?: return error(attributes, "编辑", "无法找到目标商品")
|
||||
} ?: return error(attributes, "编辑", "目标商品为空")
|
||||
}
|
||||
|
||||
else -> {
|
||||
val targetUser = target?.let {
|
||||
accountRepository.findById(it)
|
||||
.orElse(null) ?: return Util.error(attributes, "编辑", "无法找到目标用户")
|
||||
} ?: return Util.error(attributes, "编辑", "目标用户为空")
|
||||
.orElse(null) ?: return error(attributes, "编辑", "无法找到目标用户")
|
||||
} ?: return error(attributes, "编辑", "目标用户为空")
|
||||
if (action == "updating") when (targetUser.gender) {
|
||||
"M" -> model["isGenderAsMale"] = true
|
||||
"F" -> model["isGenderAsFemale"] = true
|
||||
|
@ -6,7 +6,7 @@ import org.springframework.ui.set
|
||||
import org.springframework.web.bind.annotation.CookieValue
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes
|
||||
import team8.fruitable.controller.util.Util.Companion.error
|
||||
import team8.fruitable.controller.util.error
|
||||
import team8.fruitable.datebase.entity.User
|
||||
import team8.fruitable.datebase.repository.AccountRepository
|
||||
|
||||
|
@ -2,18 +2,14 @@ package team8.fruitable.controller.util
|
||||
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes
|
||||
|
||||
class Util {
|
||||
companion object {
|
||||
fun error(
|
||||
redirectAttributes: RedirectAttributes,
|
||||
title: String,
|
||||
message: String,
|
||||
redirect: String = "/"
|
||||
): String {
|
||||
redirectAttributes.addFlashAttribute("title", title)
|
||||
redirectAttributes.addFlashAttribute("message", message)
|
||||
redirectAttributes.addFlashAttribute("redirect", redirect)
|
||||
return "redirect:/error"
|
||||
}
|
||||
}
|
||||
fun error(
|
||||
redirectAttributes: RedirectAttributes,
|
||||
title: String,
|
||||
message: String,
|
||||
redirect: String = "/"
|
||||
): String {
|
||||
redirectAttributes.addFlashAttribute("title", title)
|
||||
redirectAttributes.addFlashAttribute("message", message)
|
||||
redirectAttributes.addFlashAttribute("redirect", redirect)
|
||||
return "redirect:/error"
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package team8.fruitable.datebase.entity
|
||||
|
||||
import jakarta.persistence.*
|
||||
import org.springframework.context.annotation.Bean
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Entity
|
||||
@ -26,7 +27,7 @@ class Item(
|
||||
@Column(name = "description", length = 320, nullable = true)
|
||||
var description: String? = null,
|
||||
|
||||
@Column(name = "picture", length = 36, nullable = true)
|
||||
@Column(name = "picture", length = 64, nullable = true)
|
||||
var picture: String? = null,
|
||||
|
||||
@Column(name = "is_removed", nullable = false)
|
||||
@ -36,11 +37,20 @@ class Item(
|
||||
@JoinColumn(name = "carts")
|
||||
var carted: User? = null,
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "items")
|
||||
var ordered: Order? = null,
|
||||
@ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "orders_to_items",
|
||||
joinColumns = [JoinColumn(name = "item_id", nullable = false)],
|
||||
inverseJoinColumns = [JoinColumn(name = "order_id", nullable = false)]
|
||||
)
|
||||
var orders: MutableList<Order> = mutableListOf(),
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.LAZY, mappedBy = "tagedItem")
|
||||
@ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "items_to_tags",
|
||||
joinColumns = [JoinColumn(name = "item_id")],
|
||||
inverseJoinColumns = [JoinColumn(name = "tag_id")]
|
||||
)
|
||||
var tags: MutableList<Tag> = mutableListOf(),
|
||||
|
||||
@OneToOne(mappedBy = "item")
|
||||
@ -77,7 +87,7 @@ class Item(
|
||||
this.price = price?.let { if (it <= 0) null else it }
|
||||
if (!description.isNullOrBlank()) this.description = description
|
||||
if (!picture.isNullOrBlank()) this.picture = picture
|
||||
tags?.let { this.tags.addAll(it) }
|
||||
tags?.let { this.tags = it }
|
||||
isRemoved?.let { this.isRemoved = it }
|
||||
this.updateEditTime()
|
||||
}
|
||||
@ -85,4 +95,14 @@ class Item(
|
||||
fun updateEditTime() {
|
||||
this.editTime = LocalDateTime.now()
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun getTagPretty(): String {
|
||||
return this.tags.joinToString(", ")
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun getTagString(): String {
|
||||
return this.tags.joinToString(" ")
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ class Order(
|
||||
@Column(name = "address", length = 64, nullable = false)
|
||||
var address: String? = null,
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "pay_type")
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "order_id")
|
||||
var payType: PayType? = null,
|
||||
|
||||
@Column(name = "pay_status", nullable = false)
|
||||
@ -37,6 +37,11 @@ class Order(
|
||||
@Column(name = "price", nullable = false)
|
||||
var priceSum: Double = .0,
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.LAZY, mappedBy = "ordered")
|
||||
var items: MutableList<Item> = mutableListOf<Item>()
|
||||
@ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "orders_to_items",
|
||||
joinColumns = [JoinColumn(name = "order_id", nullable = false)],
|
||||
inverseJoinColumns = [JoinColumn(name = "item_id", nullable = false)]
|
||||
)
|
||||
var items: MutableList<Item> = mutableListOf()
|
||||
)
|
||||
|
@ -0,0 +1,23 @@
|
||||
package team8.fruitable.datebase.entity
|
||||
|
||||
import jakarta.persistence.*
|
||||
|
||||
@Entity
|
||||
@Table(name = "orders_to_items")
|
||||
class OrderedItem(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
var id: Long? = null,
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "order_id")
|
||||
var order: Order? = null,
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "item_id")
|
||||
var item: Item? = null,
|
||||
|
||||
@Column(name = "number", nullable = false)
|
||||
var number: Int? = 0
|
||||
)
|
@ -13,6 +13,7 @@ class PayType(
|
||||
@Column(name = "NAME", length = 16, nullable = false)
|
||||
var name: String? = null,
|
||||
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.LAZY, mappedBy = "payType")
|
||||
var orders: MutableList<Order> = mutableListOf<Order>()
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "pay_type", nullable = false)
|
||||
var orders: MutableList<Order> = mutableListOf()
|
||||
)
|
||||
|
@ -13,11 +13,19 @@ class Tag(
|
||||
@Column(name = "name", length = 16, nullable = false)
|
||||
var name: String? = null,
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "taged")
|
||||
var tagedItem: Item? = null
|
||||
@ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "items_to_tags",
|
||||
joinColumns = [JoinColumn(name = "tag_id", referencedColumnName = "id")],
|
||||
inverseJoinColumns = [JoinColumn(name = "item_id", referencedColumnName = "id")]
|
||||
)
|
||||
var items: MutableList<Item> = mutableListOf()
|
||||
) {
|
||||
constructor(name: String) : this() {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return this.name ?: super.toString()
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package team8.fruitable.datebase.entity
|
||||
|
||||
import jakarta.persistence.*
|
||||
import team8.fruitable.util.Util
|
||||
import org.springframework.context.annotation.Bean
|
||||
import team8.fruitable.util.hash
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
|
||||
@ -76,7 +77,7 @@ class User(
|
||||
}
|
||||
|
||||
private final fun genPassword(password: String): String {
|
||||
return Util.hash(password)
|
||||
return hash(password)
|
||||
}
|
||||
|
||||
fun update(
|
||||
@ -93,15 +94,16 @@ class User(
|
||||
if (!password.isNullOrBlank()) this.updatePassword(password)
|
||||
this.age = age?.let { if (it <= 0) null else it }
|
||||
if (!gender.isNullOrBlank()) this.gender = gender
|
||||
if (!phone.isNullOrBlank()) this.phone = phone
|
||||
if (!email.isNullOrBlank()) this.email = email
|
||||
if (!address.isNullOrBlank()) this.address = address
|
||||
this.phone = phone?.ifBlank { null }
|
||||
println("email: ${email?.ifBlank { "null" } ?: "null"}")
|
||||
this.email = email?.ifBlank { null }
|
||||
this.address = address?.ifBlank { null }
|
||||
isAdmin?.let { this.isAdmin = it }
|
||||
this.updateToken()
|
||||
}
|
||||
|
||||
fun testPassword(password: String): Boolean {
|
||||
return Util.hash(password) == this.password
|
||||
return hash(password) == this.password
|
||||
}
|
||||
|
||||
fun updatePassword(password: String) {
|
||||
@ -115,4 +117,13 @@ class User(
|
||||
fun updateToken() {
|
||||
this.token = UUID.randomUUID().toString()
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun getGenderPretty(): String {
|
||||
return when (this.gender) {
|
||||
"F" -> "女性"
|
||||
"M" -> "男性"
|
||||
else -> "未知"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,17 @@
|
||||
package team8.fruitable.util
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import java.security.MessageDigest
|
||||
|
||||
class Util {
|
||||
companion object {
|
||||
fun hash(input: String, algorithm: String = "SHA-256"): String {
|
||||
return MessageDigest.getInstance(algorithm).digest(input.toByteArray())
|
||||
.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
}
|
||||
fun hash(bytes: ByteArray, algorithm: String = "SHA-256"): String {
|
||||
return MessageDigest.getInstance(algorithm).digest(bytes)
|
||||
.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
fun hash(string: String, algorithm: String = "SHA-256"): String {
|
||||
return hash(string.toByteArray(), algorithm)
|
||||
}
|
||||
|
||||
fun hash(multipartFile: MultipartFile, algorithm: String = "SHA-256"): String {
|
||||
return hash(multipartFile.bytes, algorithm)
|
||||
}
|
||||
|
@ -49,17 +49,22 @@ div {
|
||||
|
||||
> .ResultPanel {
|
||||
flex: 2 auto;
|
||||
align-items: start;
|
||||
|
||||
td {
|
||||
border: 1px solid cornflowerblue;
|
||||
}
|
||||
> .Result {
|
||||
flex-grow: 1;
|
||||
|
||||
> thead {
|
||||
background-color: #044488;
|
||||
}
|
||||
> thead {
|
||||
background-color: #044488;
|
||||
}
|
||||
|
||||
> tbody {
|
||||
background-color: #008080;
|
||||
> tbody {
|
||||
background-color: #008080;
|
||||
}
|
||||
|
||||
td {
|
||||
border: 1px solid cornflowerblue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
.TabForm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.TabForm > .TabTitle {
|
||||
margin: 20px 0px;
|
||||
font-weight: bold;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.TabForm > .TabFormItems {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.TabForm > .TabFormItems > .TabFormItem {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.TabForm > .TabFormItems > .TabFormItem > .ItemName {
|
||||
flex: 1 0 0;
|
||||
}
|
||||
|
||||
.TabForm > .TabFormItems > .TabFormItem > .ItemInput {
|
||||
flex: 1 0 0;
|
||||
margin-left: 20px;
|
||||
border-radius: 10px;
|
||||
border: 3px solid skyblue;
|
||||
}
|
||||
|
||||
.TabForm > .TabButtons > .TabButton {
|
||||
flex: 1;
|
||||
margin: 20px 15px;
|
||||
padding: 8px 0px;
|
||||
border: 3px solid skyblue;
|
||||
border-radius: 10px;
|
||||
font-size: 18px;
|
||||
background: unset;
|
||||
}
|
||||
|
||||
.TabForm > .TabButtons > .TabButton[type="reset"] {
|
||||
background: cornflowerblue;
|
||||
}
|
||||
|
||||
.TabForm > .TabButtons > .TabButton[type="submit"] {
|
||||
background: aqua;
|
||||
}
|
53
src/main/resources/static/styles/form.less
Normal file
53
src/main/resources/static/styles/form.less
Normal file
@ -0,0 +1,53 @@
|
||||
.TabForm {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
> .TabTitle {
|
||||
margin: 20px 0;
|
||||
font-weight: bold;
|
||||
font-size: 32px;
|
||||
|
||||
&[lowSize] {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
> .TabFormItems {
|
||||
flex-direction: column;
|
||||
|
||||
> .TabFormItem {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
> .ItemName {
|
||||
flex: 1 0 0;
|
||||
}
|
||||
|
||||
> .ItemInput {
|
||||
flex: 1 0 0;
|
||||
margin-left: 20px;
|
||||
border-radius: 10px;
|
||||
border: 3px solid skyblue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> .TabButtons > .TabButton {
|
||||
flex: 1;
|
||||
margin: 20px 15px;
|
||||
padding: 8px 0;
|
||||
border: 3px solid skyblue;
|
||||
border-radius: 10px;
|
||||
font-size: 18px;
|
||||
background: unset;
|
||||
|
||||
&[type="reset"] {
|
||||
background: cornflowerblue;
|
||||
}
|
||||
|
||||
&[type="submit"] {
|
||||
background: aqua;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,9 +12,11 @@
|
||||
<link type="text/css" rel="stylesheet" href="/styles/clock.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/top.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/footer.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/form.css">
|
||||
<link type="text/css" rel="stylesheet/less" href="/styles/form.less">
|
||||
<!-- 页面特定的样式表 -->
|
||||
<link type="text/css" rel="stylesheet" href="/styles/user.css">
|
||||
<!-- 外部小组件 -->
|
||||
<script src="/scripts/lib/less.min.js"></script>
|
||||
<script src="/scripts/lib/anime.min.js"></script>
|
||||
<script async src="/scripts/lib/explosion.min.js"></script>
|
||||
</head>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<link type="text/css" rel="stylesheet" href="/styles/clock.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/top.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/footer.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/form.css">
|
||||
<link type="text/css" rel="stylesheet/less" href="/styles/form.less">
|
||||
<!-- 页面特定的样式表 -->
|
||||
<link type="text/css" rel="stylesheet/less" href="/styles/edit.less">
|
||||
<!-- 外部小组件 -->
|
||||
|
@ -1,40 +1,44 @@
|
||||
<table class="ResultPanel">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>商品名</td>
|
||||
<td>创建时间</td>
|
||||
<td>更新时间</td>
|
||||
<td>价格</td>
|
||||
<td>标签</td>
|
||||
<td>操作</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#data}}
|
||||
<tr id="{{id}}">
|
||||
<td>{{id}}</td>
|
||||
<td>{{name}}</td>
|
||||
<td>{{createTime}}</td>
|
||||
<td>{{editTime}}</td>
|
||||
<td>{{price}}</td>
|
||||
<td>{{tags}}</td>
|
||||
<td>
|
||||
<button class="update">编辑</button>
|
||||
<button class="remove">删除</button>
|
||||
</td>
|
||||
<div class="ResultPanel">
|
||||
<table class="Result">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>商品名</td>
|
||||
<td>创建时间</td>
|
||||
<td>更新时间</td>
|
||||
<td>价格</td>
|
||||
<td>标签</td>
|
||||
<td>操作</td>
|
||||
</tr>
|
||||
{{/data}}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#data}}
|
||||
<tr id="{{id}}">
|
||||
<td>{{id}}</td>
|
||||
<td>{{name}}</td>
|
||||
<td>{{createTime}}</td>
|
||||
<td>{{editTime}}</td>
|
||||
<td>{{price}}</td>
|
||||
<td>{{tagPretty}}</td>
|
||||
<td>
|
||||
<button class="update">编辑</button>
|
||||
<button class="remove">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/data}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="EditPanel">
|
||||
{{#isNothing}}
|
||||
<form class="TabForm" action="/editor" method="post">
|
||||
<h2>请在左侧列表中选择需要进行的操作!</h2>
|
||||
<input type="hidden" name="use" value="item"/>
|
||||
<input type="hidden" name="action" value="creating"/>
|
||||
<button type="submit">或者点击此处新建一个商品!</button>
|
||||
<div class="TabTitle" lowSize>请在左侧列表中选择需要进行的操作!</div>
|
||||
<div class="TabButtons">
|
||||
<button class="TabButton" type="submit">或者点击此处新建一个项目!</button>
|
||||
</div>
|
||||
</form>
|
||||
{{/isNothing}}
|
||||
|
||||
@ -50,7 +54,8 @@
|
||||
|
||||
<div class="TabFormItem">
|
||||
<label class="ItemName" for="price">价格</label>
|
||||
<input class="ItemInput" id="price" type="number" name="price" placeholder="请输入价格" required/>
|
||||
<input class="ItemInput" id="price" type="number" name="price" step="0.01" placeholder="请输入价格"
|
||||
required/>
|
||||
</div>
|
||||
|
||||
<div class="TabFormItem">
|
||||
@ -77,7 +82,8 @@
|
||||
{{/isCreating}}
|
||||
|
||||
{{#isUpdating}}
|
||||
<form class="TabForm" action="/action/edit/item/update/{{target.id}}" method="post" enctype="multipart/form-data">
|
||||
<form class="TabForm" action="/action/edit/item/update/{{target.id}}" method="post"
|
||||
enctype="multipart/form-data">
|
||||
<div class="TabTitle">更新商品详情</div>
|
||||
|
||||
<div class="TabFormItems">
|
||||
@ -89,7 +95,7 @@
|
||||
|
||||
<div class="TabFormItem">
|
||||
<label class="ItemName" for="price">价格</label>
|
||||
<input class="ItemInput" id="price" type="number" name="price" placeholder="请输入价格"
|
||||
<input class="ItemInput" id="price" type="number" name="price" step="0.01" placeholder="请输入价格"
|
||||
{{#target.price}}value="{{target.price}}"{{/target.price}} required/>
|
||||
</div>
|
||||
|
||||
@ -102,7 +108,7 @@
|
||||
<div class="TabFormItem">
|
||||
<label class="ItemName" for="tag">标签</label>
|
||||
<input class="ItemInput" id="tag" type="text" name="tag" placeholder="请输入标签,以空格隔开!"
|
||||
{{#target.tags}}value="{{target.tags}}"{{/target.tags}}/>
|
||||
{{#target.tags}}value="{{target.tagString}}"{{/target.tags}}/>
|
||||
</div>
|
||||
|
||||
<div class="TabFormItem">
|
||||
|
@ -1,48 +1,52 @@
|
||||
<table class="ResultPanel">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>用户名</td>
|
||||
<td>帐户创建时间</td>
|
||||
<td>最后登录时间</td>
|
||||
<td>年龄</td>
|
||||
<td>性别</td>
|
||||
<td>手机号码</td>
|
||||
<td>邮箱</td>
|
||||
<td>地址</td>
|
||||
<td>管理员</td>
|
||||
<td>操作</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#data}}
|
||||
<tr id="{{id}}">
|
||||
<td>{{id}}</td>
|
||||
<td>{{name}}</td>
|
||||
<td>{{createTime}}</td>
|
||||
<td>{{loginTime}}</td>
|
||||
<td>{{#age}}{{age}}{{/age}}</td>
|
||||
<td>{{#gender}}{{gender}}{{/gender}}</td>
|
||||
<td>{{#phone}}{{phone}}{{/phone}}</td>
|
||||
<td>{{#email}}{{email}}{{/email}}</td>
|
||||
<td>{{#address}}{{address}}{{/address}}</td>
|
||||
<td>{{#isAdmin}}是{{/isAdmin}}{{^isAdmin}}否{{/isAdmin}}</td>
|
||||
<td>
|
||||
<button class="update">编辑</button>
|
||||
<button class="remove">删除</button>
|
||||
</td>
|
||||
<div class="ResultPanel">
|
||||
<table class="Result">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>用户名</td>
|
||||
<td>帐户创建时间</td>
|
||||
<td>最后登录时间</td>
|
||||
<td>年龄</td>
|
||||
<td>性别</td>
|
||||
<td>手机号码</td>
|
||||
<td>邮箱</td>
|
||||
<td>地址</td>
|
||||
<td>管理员</td>
|
||||
<td>操作</td>
|
||||
</tr>
|
||||
{{/data}}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#data}}
|
||||
<tr id="{{id}}">
|
||||
<td>{{id}}</td>
|
||||
<td>{{name}}</td>
|
||||
<td>{{createTime}}</td>
|
||||
<td>{{loginTime}}</td>
|
||||
<td>{{#age}}{{age}}{{/age}}</td>
|
||||
<td>{{genderPretty}}</td>
|
||||
<td>{{#phone}}{{phone}}{{/phone}}</td>
|
||||
<td>{{#email}}{{email}}{{/email}}</td>
|
||||
<td>{{#address}}{{address}}{{/address}}</td>
|
||||
<td>{{#isAdmin}}是{{/isAdmin}}{{^isAdmin}}否{{/isAdmin}}</td>
|
||||
<td>
|
||||
<button class="update">编辑</button>
|
||||
<button class="remove">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/data}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="EditPanel">
|
||||
{{#isNothing}}
|
||||
<form class="TabForm" action="/editor" method="post">
|
||||
<h2>请在左侧列表中选择需要进行的操作!</h2>
|
||||
<input type="hidden" name="use" value="user"/>
|
||||
<input type="hidden" name="action" value="creating"/>
|
||||
<button type="submit">或者点击此处新建一个用户!</button>
|
||||
<div class="TabTitle" lowSize>请在左侧列表中选择需要进行的操作!</div>
|
||||
<div class="TabButtons">
|
||||
<button class="TabButton" type="submit">或者点击此处新建一个项目!</button>
|
||||
</div>
|
||||
</form>
|
||||
{{/isNothing}}
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
<link type="text/css" rel="stylesheet" href="/styles/clock.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/top.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/footer.css">
|
||||
<link type="text/css" rel="stylesheet" href=/"styles/loading.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/form.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/loading.css">
|
||||
<link type="text/css" rel="stylesheet/less" href="/styles/form.less">
|
||||
<!-- 页面特定的样式表 -->
|
||||
<link type="text/css" rel="stylesheet" href="/styles/user.css">
|
||||
<!-- 外部小组件 -->
|
||||
<script src="/scripts/lib/less.min.js"></script>
|
||||
<script src="/scripts/lib/anime.min.js"></script>
|
||||
<script async src="/scripts/lib/explosion.min.js"></script>
|
||||
</head>
|
||||
|
@ -9,17 +9,18 @@
|
||||
<script type="module" src="/scripts/resources.js"></script>
|
||||
<script type="module" src="/scripts/items.js"></script>
|
||||
<script type="module" src="/scripts/index.js"></script>
|
||||
<link type="image/x-icon" rel="icon" href="images/favicon.ico">
|
||||
<link type="image/x-icon" rel="icon" href="/images/favicon.ico">
|
||||
<!-- 页面公共的样式表 -->
|
||||
<link type="text/css" rel="stylesheet" href="/styles/header.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/clock.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/top.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/footer.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/loading.css">
|
||||
<link type="text/css" rel="stylesheet" href="/styles/form.css">
|
||||
<link type="text/css" rel="stylesheet/less" href="/styles/form.less">
|
||||
<!-- 页面特定的样式表 -->
|
||||
<link type="text/css" rel="stylesheet" href="/styles/user.css">
|
||||
<!-- 外部小组件 -->
|
||||
<script src="/scripts/lib/less.min.js"></script>
|
||||
<script src="/scripts/lib/anime.min.js"></script>
|
||||
<script async src="/scripts/lib/explosion.min.js"></script>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user