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:
@@ -8,6 +8,8 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
"go.ipao.vip/gen/types"
|
||||
"gorm.io/gorm"
|
||||
@@ -17,25 +19,25 @@ const TableNameContent = "contents"
|
||||
|
||||
// Content mapped from table <contents>
|
||||
type Content struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
Title string `gorm:"column:title;type:character varying(255);not null" json:"title"`
|
||||
Description string `gorm:"column:description;type:text;not null" json:"description"`
|
||||
Status string `gorm:"column:status;type:character varying(32);default:draft" json:"status"`
|
||||
Visibility string `gorm:"column:visibility;type:character varying(32);default:tenant_only" json:"visibility"`
|
||||
PreviewSeconds int32 `gorm:"column:preview_seconds;type:integer;default:60" json:"preview_seconds"`
|
||||
PreviewDownloadable bool `gorm:"column:preview_downloadable;type:boolean" json:"preview_downloadable"`
|
||||
PublishedAt time.Time `gorm:"column:published_at;type:timestamp with time zone" json:"published_at"`
|
||||
Summary string `gorm:"column:summary;type:character varying(256)" json:"summary"`
|
||||
Tags types.JSON `gorm:"column:tags;type:jsonb;default:[]" json:"tags"`
|
||||
Body string `gorm:"column:body;type:text" json:"body"`
|
||||
Genre string `gorm:"column:genre;type:character varying(64)" json:"genre"`
|
||||
Views int32 `gorm:"column:views;type:integer" json:"views"`
|
||||
Likes int32 `gorm:"column:likes;type:integer" json:"likes"`
|
||||
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"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone" json:"deleted_at"`
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
Title string `gorm:"column:title;type:character varying(255);not null" json:"title"`
|
||||
Description string `gorm:"column:description;type:text;not null" json:"description"`
|
||||
Status consts.ContentStatus `gorm:"column:status;type:character varying(32);default:draft" json:"status"`
|
||||
Visibility consts.ContentVisibility `gorm:"column:visibility;type:character varying(32);default:tenant_only" json:"visibility"`
|
||||
PreviewSeconds int32 `gorm:"column:preview_seconds;type:integer;default:60" json:"preview_seconds"`
|
||||
PreviewDownloadable bool `gorm:"column:preview_downloadable;type:boolean" json:"preview_downloadable"`
|
||||
PublishedAt time.Time `gorm:"column:published_at;type:timestamp with time zone" json:"published_at"`
|
||||
Summary string `gorm:"column:summary;type:character varying(256)" json:"summary"`
|
||||
Tags types.JSON `gorm:"column:tags;type:jsonb;default:[]" json:"tags"`
|
||||
Body string `gorm:"column:body;type:text" json:"body"`
|
||||
Genre string `gorm:"column:genre;type:character varying(64)" json:"genre"`
|
||||
Views int32 `gorm:"column:views;type:integer" json:"views"`
|
||||
Likes int32 `gorm:"column:likes;type:integer" json:"likes"`
|
||||
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"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone" json:"deleted_at"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
Reference in New Issue
Block a user