36 lines
813 B
Go
36 lines
813 B
Go
|
package models
|
|||
|
|
|||
|
import "github.com/astaxie/beego/orm"
|
|||
|
|
|||
|
/**
|
|||
|
代表忽略 : `orm:"-"`
|
|||
|
*/
|
|||
|
type User struct {
|
|||
|
Id int `json:"id" orm:"pk"`
|
|||
|
Name string `json:"name" orm:"column(name)"`
|
|||
|
Age int `json:"age" orm:"column(age)"`
|
|||
|
Addr string `json:"addr" orm:"column(addr)"`
|
|||
|
Class string `json:"clazz" orm:"column(clazz)"`
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
1、默认表面以大写字母分割,中间加下划线,首字母的大写只转换为小写,前面不加下划线
|
|||
|
SysUser -> sys_user
|
|||
|
DBUser -> d_b_user
|
|||
|
Sys_User -> sys__user
|
|||
|
重写表名
|
|||
|
*/
|
|||
|
//func (u * User) TableName() string {
|
|||
|
// return "sys_user"
|
|||
|
//}
|
|||
|
func init() {
|
|||
|
//需要放在init下 注册models
|
|||
|
orm.RegisterModel(new(User))
|
|||
|
/*
|
|||
|
//前缀
|
|||
|
orm.RegisterModelWithPrefix("sys",new(User))
|
|||
|
//后缀
|
|||
|
orm.RegisterModelWithSuffix("sys",new(User))
|
|||
|
*/
|
|||
|
}
|