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:
2025-01-22 13:44:26 +08:00
parent 500f5b3339
commit 83d9bbb530
3 changed files with 41 additions and 10 deletions
+11 -1
View File
@@ -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)
}