beegoDemo/beego_demo1/models/orm1.go
2021-07-13 17:33:56 +08:00

36 lines
813 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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))
*/
}