feat: update Category model and request struct to use pointers for description and sequence fields
This commit is contained in:
parent
c5eb6302ab
commit
a47b7b7d3d
@ -12,8 +12,8 @@ func (a *accessor) CreateModel(spec categorydomain.CategoryReq) error {
|
|||||||
ID: uuid.NewString(),
|
ID: uuid.NewString(),
|
||||||
Name: spec.Name,
|
Name: spec.Name,
|
||||||
Code: spec.Code,
|
Code: spec.Code,
|
||||||
Description: spec.Description,
|
Description: *spec.Description,
|
||||||
Sequence: spec.Sequence,
|
Sequence: *spec.Sequence,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.db.Create(&data).Error; err != nil {
|
if err := a.db.Create(&data).Error; err != nil {
|
||||||
|
|||||||
@ -8,8 +8,8 @@ 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"`
|
||||||
Description string `json:"description"`
|
Description *string `json:"description"`
|
||||||
Sequence int `json:"sequence"`
|
Sequence *int `json:"sequence"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
@ -17,6 +17,6 @@ type Category struct {
|
|||||||
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"`
|
Description *string `json:"description"`
|
||||||
Sequence int `json:"sequence"`
|
Sequence *int `json:"sequence"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user