123456789101112131415161718192021222324252627282930313233343536 |
- package Device
- import (
- "github.com/beego/beego/v2/adapter/orm"
- _ "github.com/go-sql-driver/mysql"
- )
- // 设备类型: 1库房 2移动 。。。
- type DeviceType struct {
- Id int `orm:"column(ID);size(11);auto;pk"`
- T_name string `orm:"size(256);null"` // 标题
- T_text string `orm:"type(text);null"` // 详情
- T_view int `orm:"size(2);default(1)"` // 1 库房 2 移动
- T_State int `orm:"size(2);default(1)"` // 0 删除 1 正常
- }
- func (t *DeviceType) TableName() string {
- return "device_type" // 数据库名称 // ************** 替换 FormulaList **************
- }
- func init() {
- //注册模型
- orm.RegisterModel(new(DeviceType))
- }
- func Read_DeviceType_List_All() (r []DeviceType) {
- o := orm.NewOrm()
- // 也可以直接使用 Model 结构体作为表名
- qs := o.QueryTable(new(DeviceType))
- qs.Filter("T_State", 1).All(&r)
- return r
- }
|