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(),
|
||||
Name: spec.Name,
|
||||
Code: spec.Code,
|
||||
Description: spec.Description,
|
||||
Sequence: spec.Sequence,
|
||||
Description: *spec.Description,
|
||||
Sequence: *spec.Sequence,
|
||||
}
|
||||
|
||||
if err := a.db.Create(&data).Error; err != nil {
|
||||
|
||||
@ -8,15 +8,15 @@ type Category struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description"`
|
||||
Sequence int `json:"sequence"`
|
||||
Description *string `json:"description"`
|
||||
Sequence *int `json:"sequence"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CategoryReq struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Code string `json:"code" validate:"required"`
|
||||
Description string `json:"description"`
|
||||
Sequence int `json:"sequence"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Code string `json:"code" validate:"required"`
|
||||
Description *string `json:"description"`
|
||||
Sequence *int `json:"sequence"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user