feat: add description and sequence fields to Category model and update request struct
This commit is contained in:
parent
479703dfd0
commit
68f33d101b
@ -5,14 +5,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Category struct {
|
type Category struct {
|
||||||
ID string `json:"id" gorm:"primaryKey"`
|
ID string `json:"id" gorm:"primaryKey"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
Description string `json:"description"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
Sequence int `json:"sequence"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CategoryReq struct {
|
type CategoryReq struct {
|
||||||
Name string `json:"name" validate:"required"`
|
Name string `json:"name" validate:"required"`
|
||||||
Code string `json:"code" validate:"required"`
|
Code string `json:"code" validate:"required"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Sequence int `json:"sequence"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,12 @@ import (
|
|||||||
|
|
||||||
func (i *impl) Update(categoryID string, spec categorydomain.CategoryReq) error {
|
func (i *impl) Update(categoryID string, spec categorydomain.CategoryReq) error {
|
||||||
updateData := categorydomain.Category{
|
updateData := categorydomain.Category{
|
||||||
ID: categoryID,
|
ID: categoryID,
|
||||||
Name: spec.Name,
|
Name: spec.Name,
|
||||||
Code: spec.Code,
|
Code: spec.Code,
|
||||||
UpdatedAt: timeutils.Now(),
|
Description: spec.Description,
|
||||||
|
Sequence: spec.Sequence,
|
||||||
|
UpdatedAt: timeutils.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := i.categoryRepo.Update(updateData); err != nil {
|
if err := i.categoryRepo.Update(updateData); err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user