| | |
| | | package models |
| | | |
| | | type Program struct { |
| | | Name string `gorm:"column:name;primary_key;unique;not null;default:''" json:"name"` //程序名字 |
| | | Version string `gorm:"column:version;not null;default:''" json:"version"` //程序版本 |
| | | Md5sum string `gorm:"column:md5sum;not null;default:'';" json:"md5sum"` //md5 |
| | | Type string `gorm:"column:type;not null;default:'';" json:"type"` //程序类型 |
| | | } |
| | | |
| | | func (Program) TableName() string { |
| | | return "t_programs" |
| | | } |
| | | |
| | | func (a *Program) FindAll() (rows []Program, err error) { |
| | | if err := db.Table(a.TableName()).Find(&rows).Error; err != nil { |
| | | return nil, err |
| | | } |
| | | |
| | | return rows, nil |
| | | } |
| | | package models
|
| | |
|
| | | type Program struct {
|
| | | Name string `gorm:"column:name;primary_key;unique;not null;default:''" json:"name"` //程序名字
|
| | | Version string `gorm:"column:version;not null;default:''" json:"version"` //程序版本
|
| | | Md5sum string `gorm:"column:md5sum;not null;default:'';" json:"md5sum"` //md5
|
| | | Type string `gorm:"column:type;not null;default:'';" json:"type"` //程序类型
|
| | | }
|
| | |
|
| | | func (Program) TableName() string {
|
| | | return "t_programs"
|
| | | }
|
| | |
|
| | | func (a *Program) FindAll() (rows []Program, err error) {
|
| | | if err := db.Table(a.TableName()).Find(&rows).Error; err != nil {
|
| | | return nil, err
|
| | | }
|
| | |
|
| | | return rows, nil
|
| | | }
|