12345678910111213141516171819202122232425262728293031 |
- package Device
- import (
- "github.com/beego/beego/v2/adapter/orm"
- _ "github.com/go-sql-driver/mysql"
- )
- type DeviceSnOld struct {
- Id int `orm:"column(ID);size(11);auto;pk"`
- T_sn string `orm:"size(256);"` // 分类
- }
- func (t *DeviceSnOld) TableName() string {
- return "device_sn_old" // 数据库名称 // ************** 替换 DesignClass **************
- }
- func init() {
- //注册模型
- orm.RegisterModel(new(DeviceSnOld))
- }
- // ---------------- 特殊方法 -------------------
- // 添加
- func Add_DeviceSnOld(T_sn string) {
- o := orm.NewOrm()
- user := DeviceSnOld{T_sn: T_sn}
- // 三个返回参数依次为:是否新创建的,对象 Id 值,错误
- o.ReadOrCreate(&user, "T_sn")
- }
|