feat: sale manager

This commit is contained in:
zzw
2026-08-28 10:49:09 +08:00
parent 97eba7ad48
commit 6f567319be
82 changed files with 4491 additions and 182 deletions
+12
View File
@@ -128,6 +128,11 @@ func (m Base) session() *gorm.DB {
return o
}
// Session returns the DB session for this model (honors WithTX).
func (m Base) Session() *gorm.DB {
return m.session()
}
// Create inserts a row.
func (m Base) Create(data interface{}) error {
return m.session().Create(data).Error
@@ -139,6 +144,13 @@ func (m Base) Edit(w Params, data interface{}) (int64, error) {
update := make(map[string]interface{})
jsonBytes, _ := jsoniter.Marshal(data)
_ = jsoniter.Unmarshal(jsonBytes, &update)
for k, v := range update {
if nested, ok := v.(map[string]interface{}); ok {
if b, err := jsoniter.Marshal(nested); err == nil {
update[k] = string(b)
}
}
}
ret := o.Updates(update)
return ret.RowsAffected, ignoreNotFound(ret.Error)
}