Upstream sync
This commit is contained in:
18
models/buyer.go
Normal file
18
models/buyer.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
import "github.com/jinzhu/gorm"
|
||||
|
||||
type Buyer struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
}
|
||||
|
||||
func (Buyer) Update() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (Buyer) Create() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (Buyer) Delete() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
31
models/json_type.go
Normal file
31
models/json_type.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type JSON json.RawMessage
|
||||
|
||||
// Scan scan value into Jsonb, implements sql.Scanner interface
|
||||
func (j *JSON) Scan(value interface{}) error {
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
|
||||
}
|
||||
|
||||
result := json.RawMessage{}
|
||||
err := json.Unmarshal(bytes, &result)
|
||||
*j = JSON(result)
|
||||
return err
|
||||
}
|
||||
|
||||
// Value return json value, implement driver.Valuer interface
|
||||
func (j JSON) Value() (driver.Value, error) {
|
||||
if len(j) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return json.RawMessage(j).MarshalJSON()
|
||||
}
|
||||
20
models/product_template.go
Normal file
20
models/product_template.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package models
|
||||
|
||||
import "github.com/jinzhu/gorm"
|
||||
|
||||
type ProductTemplate struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
ProductTemplateConfig map[string]interface{} `json:",omitempty" sql:"-"`
|
||||
Config JSON `json:"-" gorm:"embedded"`
|
||||
}
|
||||
|
||||
func (ProductTemplate) Update() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (ProductTemplate) Create() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (ProductTemplate) Delete() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
18
models/text_template.go
Normal file
18
models/text_template.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
import "github.com/jinzhu/gorm"
|
||||
|
||||
type TextTemplate struct {
|
||||
gorm.Model
|
||||
Value string
|
||||
}
|
||||
|
||||
func (TextTemplate) Update() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (TextTemplate) Create() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
func (TextTemplate) Delete() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
Reference in New Issue
Block a user