feat: add description and sequence fields to Create and Update category functions

This commit is contained in:
Ardeman 2025-03-07 23:58:53 +08:00
parent 68f33d101b
commit c5eb6302ab
2 changed files with 7 additions and 5 deletions

View File

@ -12,6 +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,
}
if err := a.db.Create(&data).Error; err != nil {

View File

@ -10,8 +10,8 @@ import (
func (a *accessor) Update(spec categorydomain.Category) error {
if err := a.db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "id"}},
DoUpdates: clause.AssignmentColumns([]string{"name", "code", "updated_at"}),
}).Select("name", "code", "updated_at").Save(&spec).Error; err != nil {
DoUpdates: clause.AssignmentColumns([]string{"name", "code", "sequence", "description", "updated_at"}),
}).Select("name", "code", "sequence", "description", "updated_at").Save(&spec).Error; err != nil {
return fmt.Errorf("failed to update category: %v", err)
}