feat: sale manager
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user