:card_box: Add more fields into product
This commit is contained in:
parent
9c3eb0a3f4
commit
2de4f3a606
@ -8,9 +8,11 @@ import (
|
|||||||
type Product struct {
|
type Product struct {
|
||||||
cruda.BaseModel
|
cruda.BaseModel
|
||||||
|
|
||||||
|
Icon string `json:"icon"` // random id of atttachment
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Alias string `json:"alias" gorm:"uniqueIndex"`
|
Alias string `json:"alias" gorm:"uniqueIndex"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
Previews datatypes.JSONSlice[string] `json:"previews"` // random id of attachments
|
||||||
Tags datatypes.JSONSlice[string] `json:"tags"`
|
Tags datatypes.JSONSlice[string] `json:"tags"`
|
||||||
|
|
||||||
Meta ProductMeta `json:"meta" gorm:"foreignKey:ProductID"`
|
Meta ProductMeta `json:"meta" gorm:"foreignKey:ProductID"`
|
||||||
@ -22,7 +24,7 @@ type ProductMeta struct {
|
|||||||
cruda.BaseModel
|
cruda.BaseModel
|
||||||
|
|
||||||
Introduction string `json:"introduction"`
|
Introduction string `json:"introduction"`
|
||||||
Attachments datatypes.JSONSlice[string] `json:"attachments"`
|
Attachments datatypes.JSONSlice[string] `json:"attachments"` // random id of attachments
|
||||||
|
|
||||||
ProductID uint `json:"product_id"`
|
ProductID uint `json:"product_id"`
|
||||||
}
|
}
|
||||||
|
@ -121,11 +121,13 @@ func updateProduct(c *fiber.Ctx) error {
|
|||||||
user := c.Locals("nex_user").(*sec.UserInfo)
|
user := c.Locals("nex_user").(*sec.UserInfo)
|
||||||
|
|
||||||
var data struct {
|
var data struct {
|
||||||
|
Icon string `json:"icon"`
|
||||||
Name string `json:"name" validate:"required,max=256"`
|
Name string `json:"name" validate:"required,max=256"`
|
||||||
Description string `json:"description" validate:"max=4096"`
|
Description string `json:"description" validate:"max=4096"`
|
||||||
Introduction string `json:"introduction"`
|
Introduction string `json:"introduction"`
|
||||||
Alias string `json:"alias" validate:"required"`
|
Alias string `json:"alias" validate:"required"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
|
Previews []string `json:"previews"`
|
||||||
Attachments []string `json:"attachments"`
|
Attachments []string `json:"attachments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,9 +140,11 @@ func updateProduct(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
product.Icon = data.Icon
|
||||||
product.Name = data.Name
|
product.Name = data.Name
|
||||||
product.Description = data.Description
|
product.Description = data.Description
|
||||||
product.Tags = data.Tags
|
product.Tags = data.Tags
|
||||||
|
product.Previews = data.Previews
|
||||||
product.Meta.Introduction = data.Introduction
|
product.Meta.Introduction = data.Introduction
|
||||||
product.Meta.Attachments = data.Attachments
|
product.Meta.Attachments = data.Attachments
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user