fusenapi/model/gmodel/fs_user_material_logic.go

16 lines
375 B
Go
Raw Normal View History

2023-08-02 10:14:53 +00:00
package gmodel
import "context"
// TODO: 使用model的属性做你想做的
func (p *FsUserMaterialModel) CreateOrUpdate(ctx context.Context, req *FsUserMaterial) (resp *FsUserMaterial, err error) {
rowBuilder := p.db.Table(p.name).WithContext(ctx)
if req.Id > 0 {
err = rowBuilder.Save(req).Error
} else {
err = rowBuilder.Create(req).Error
}
return req, err
}