feat(user): implement OTP login, user creation, and profile management

- Added SendOTP method for simulating OTP sending.
- Implemented LoginWithOTP method for user login/registration via OTP, including user creation if not found.
- Added Me method to retrieve current user information.
- Implemented Update method for updating user profile details.
- Added RealName method for real-name verification.
- Implemented GetNotifications method to fetch user notifications.
- Created user_test.go for comprehensive unit tests covering login, profile retrieval, updates, real-name verification, and notifications.
- Updated database models to use appropriate consts for fields like gender, status, and roles.
This commit is contained in:
2025-12-29 10:55:13 +08:00
parent bc2064639f
commit b78f1e1c84
17 changed files with 497 additions and 120 deletions

View File

@@ -8,6 +8,8 @@ import (
"context"
"time"
"quyun/v2/pkg/consts"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
)
@@ -16,16 +18,16 @@ const TableNameTenant = "tenants"
// Tenant mapped from table <tenants>
type Tenant struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Code string `gorm:"column:code;type:character varying(64);not null" json:"code"`
UUID types.UUID `gorm:"column:uuid;type:uuid;not null" json:"uuid"`
Name string `gorm:"column:name;type:character varying(128);not null" json:"name"`
Status string `gorm:"column:status;type:character varying(64);not null" json:"status"`
Config types.JSON `gorm:"column:config;type:jsonb;default:{}" json:"config"`
ExpiredAt time.Time `gorm:"column:expired_at;type:timestamp with time zone" json:"expired_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Code string `gorm:"column:code;type:character varying(64);not null" json:"code"`
UUID types.UUID `gorm:"column:uuid;type:uuid;not null" json:"uuid"`
Name string `gorm:"column:name;type:character varying(128);not null" json:"name"`
Status consts.TenantStatus `gorm:"column:status;type:character varying(64);not null" json:"status"`
Config types.JSON `gorm:"column:config;type:jsonb;default:{}" json:"config"`
ExpiredAt time.Time `gorm:"column:expired_at;type:timestamp with time zone" json:"expired_at"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
}
// Quick operations without importing query package