DeviceType.go 876 B

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