type SupplierInterface interface{
CreateSupplier(ctx context.Context, info *supplier_po.TSupplier)error}func(s *SupplierClass)CreateSupplier(ctx context.Context, info *supplier_po.TSupplier)error{
return s.DB.WithContext(ctx).Create(info).Error
}
插入或更新数据
type OrderInterface interface{
UpdateOrInsert(context.Context,*order_po.Order)error}func(o *OrderClass)UpdateOrInsert(ctx context.Context, param *order_po.Order)(err error){
client := o.DB.WithContext(ctx).Table(order_po.Order{
}.TableName())if param.Id ==0{
err = client.Create(param).Error
return}
err = client.Select("*").Omit("created_at").Updates(param).Error
return}type Order struct{
Id