feat usn 类型改成int64
This commit is contained in:
@@ -16,7 +16,7 @@ const TableNameUser = "users"
|
||||
// User mapped from table <users>
|
||||
type User struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
||||
Sn string `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
|
||||
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
|
||||
Name string `gorm:"column:name;not null" json:"name"`
|
||||
Phone string `gorm:"column:phone" json:"phone"`
|
||||
WxUnionID string `gorm:"column:wx_union_id;comment:微信用户唯一标识" json:"wx_union_id"` // 微信用户唯一标识
|
||||
@@ -33,8 +33,8 @@ func (*User) TableName() string {
|
||||
|
||||
// Auto sn
|
||||
func (m *User) BeforeCreate(_ *gorm.DB) error {
|
||||
if m.Sn == "" {
|
||||
m.Sn = utils.SnowflakeInstance().Generate().String()
|
||||
if m.Sn == 0 {
|
||||
m.Sn = utils.SnowflakeInstance().Generate().Int64()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
||||
tableName := _user.userDo.TableName()
|
||||
_user.ALL = field.NewAsterisk(tableName)
|
||||
_user.ID = field.NewUint64(tableName, "id")
|
||||
_user.Sn = field.NewString(tableName, "sn")
|
||||
_user.Sn = field.NewInt64(tableName, "sn")
|
||||
_user.Name = field.NewString(tableName, "name")
|
||||
_user.Phone = field.NewString(tableName, "phone")
|
||||
_user.WxUnionID = field.NewString(tableName, "wx_union_id")
|
||||
@@ -47,7 +47,7 @@ type user struct {
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
Sn field.String // 业务唯一编号
|
||||
Sn field.Int64 // 业务唯一编号
|
||||
Name field.String
|
||||
Phone field.String
|
||||
WxUnionID field.String // 微信用户唯一标识
|
||||
@@ -72,7 +72,7 @@ func (u user) As(alias string) *user {
|
||||
func (u *user) updateTableName(table string) *user {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewUint64(table, "id")
|
||||
u.Sn = field.NewString(table, "sn")
|
||||
u.Sn = field.NewInt64(table, "sn")
|
||||
u.Name = field.NewString(table, "name")
|
||||
u.Phone = field.NewString(table, "phone")
|
||||
u.WxUnionID = field.NewString(table, "wx_union_id")
|
||||
|
||||
Reference in New Issue
Block a user