✨ 完成基础脚手架
This commit is contained in:
19
model/cache/user.go
vendored
Normal file
19
model/cache/user.go
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package cache
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// UserInfo 登录用的用户信息结构体
|
||||
type UserInfo struct {
|
||||
UserType string `json:"userType"` // 用户类型
|
||||
RoleCodes string `json:"roleCodes"` // 角色代码
|
||||
UserId string `json:"userId"` // 用户Id
|
||||
}
|
||||
|
||||
// String 实现Stringer接口
|
||||
func (i UserInfo) String() (string, error) {
|
||||
b, err := json.Marshal(i)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
21
model/entity/user.go
Normal file
21
model/entity/user.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"ginDemo/common/types"
|
||||
)
|
||||
|
||||
// User 普通用户表
|
||||
type User struct {
|
||||
types.BaseDbModel
|
||||
Phone string `json:"phone" gorm:"type:varchar(255) not null comment '手机号'"`
|
||||
Password string `json:"password" gorm:"type:varchar(255) not null comment '密码'"`
|
||||
Nickname string `json:"nickname" gorm:"type:varchar(255) comment '昵称'"`
|
||||
Avatar string `json:"avatar" gorm:"type:varchar(255) comment '头像'"`
|
||||
Birthday *string `json:"birthday" gorm:"type:varchar(10); comment 生日"`
|
||||
LastLoginAt *types.DateTime `json:"last_login_at" gorm:"comment:'最后登录时间'"`
|
||||
LastLoginIp *string `json:"last_login_ip" gorm:"type:varchar(255) comment '最后登录ip'"`
|
||||
}
|
||||
|
||||
func (User) TableName() string {
|
||||
return "t_user"
|
||||
}
|
5
model/readme.md
Normal file
5
model/readme.md
Normal file
@@ -0,0 +1,5 @@
|
||||
## 系统定义的结构体都放在这个包下面
|
||||
|
||||
### 注意事项
|
||||
1. entity包对应的是数据库表结构
|
||||
2. 所有涉及param和entity转换的操作,都放在param里面去实现一个`ToEntity`函数和`FromEntity`函数,避免两个包交叉引用
|
Reference in New Issue
Block a user