feat(user): 生成用户查询接口并优化模型
- 在 model/user.go 中添加 Querier 接口,定义了 GetByEmail 方法- 在 query/users.gen.go 中实现 Querier 接口的 GetByEmail 方法 - 修改 gen.go以使用新的 Querier 接口和 User 模型生成代码 - 将 users.gen.go 中的 ID 类型从 Int64 改为 Uint
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
import (
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Email string `gorm:"uniqueIndex;type:varchar(255) not null"`
|
||||
PasswordHashed string `gorm:"type:varchar(255) not null"`
|
||||
}
|
||||
|
||||
type Querier interface {
|
||||
// GetByEmail get user by email
|
||||
//
|
||||
// SELECT * FROM @@table WHERE email = @email
|
||||
GetByEmail(email string) (*gen.T, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user