package model
|
|
import (
|
"aps_crm/pkg/mysqlx"
|
"gorm.io/gorm"
|
)
|
|
type (
|
// SalesReturnStatus 退货状态
|
SalesReturnStatus struct {
|
Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
|
Name string `json:"name" gorm:"column:name;type:varchar(255);comment:退货状态名称"`
|
}
|
|
SalesReturnStatusSearch struct {
|
SalesReturnStatus
|
Orm *gorm.DB
|
}
|
)
|
|
func (SalesReturnStatus) TableName() string {
|
return "sales_return_status"
|
}
|
|
func NewSalesReturnStatusSearch() *SalesReturnStatusSearch {
|
return &SalesReturnStatusSearch{
|
Orm: mysqlx.GetDB(),
|
}
|
}
|
|
func (slf *SalesReturnStatusSearch) build() *gorm.DB {
|
var db = slf.Orm.Model(&SalesReturnStatus{})
|
if slf.Id != 0 {
|
db = db.Where("id = ?", slf.Id)
|
}
|
if slf.Name != "" {
|
db = db.Where("name = ?", slf.Name)
|
}
|
|
return db
|
}
|
|
func (slf *SalesReturnStatusSearch) Create(record *SalesReturnStatus) error {
|
var db = slf.build()
|
return db.Create(record).Error
|
}
|
|
func (slf *SalesReturnStatusSearch) Delete() error {
|
var db = slf.build()
|
return db.Delete(&SalesReturnStatus{}).Error
|
}
|
|
func (slf *SalesReturnStatusSearch) Update(record *SalesReturnStatus) error {
|
var db = slf.build()
|
return db.Updates(record).Error
|
}
|
|
func (slf *SalesReturnStatusSearch) Find() (*SalesReturnStatus, error) {
|
var db = slf.build()
|
var record = new(SalesReturnStatus)
|
err := db.First(record).Error
|
return record, err
|
}
|
|
func (slf *SalesReturnStatusSearch) FindAll() ([]*SalesReturnStatus, error) {
|
var db = slf.build()
|
var records = make([]*SalesReturnStatus, 0)
|
err := db.Find(&records).Error
|
return records, err
|
}
|
|
func (slf *SalesReturnStatusSearch) SetId(id int) *SalesReturnStatusSearch {
|
slf.Id = id
|
return slf
|
}
|
|
func (slf *SalesReturnStatusSearch) SetName(name string) *SalesReturnStatusSearch {
|
slf.Name = name
|
return slf
|
}
|
|
func (slf *SalesReturnStatusSearch) Updates(data map[string]interface{}) error {
|
var db = slf.build()
|
return db.Updates(data).Error
|
}
|