Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions backend/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,9 @@
},
"id": {
"type": "string"
},
"prompt": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -2464,6 +2467,12 @@
},
"domain.RegisterReq": {
"type": "object",
"required": [
"code",
"email",
"password",
"username"
],
"properties": {
"code": {
"description": "邀请码",
Expand All @@ -2476,6 +2485,10 @@
"password": {
"description": "密码",
"type": "string"
},
"username": {
"description": "用户名",
"type": "string"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions backend/domain/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (c *CompletionRecord) From(e *db.Task) *CompletionRecord {

type CompletionInfo struct {
ID string `json:"id"`
Prompt string `json:"prompt"`
Content string `json:"content"`
CreatedAt int64 `json:"created_at"`
}
Expand All @@ -96,6 +97,7 @@ func (c *CompletionInfo) From(e *db.Task) *CompletionInfo {
return c
}
c.ID = e.TaskID
c.Prompt = e.Prompt
c.Content = e.Completion
c.CreatedAt = e.CreatedAt.Unix()
return c
Expand Down
7 changes: 4 additions & 3 deletions backend/domain/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ type ListReq struct {
}

type RegisterReq struct {
Email string `json:"email"` // 邮箱
Password string `json:"password"` // 密码
Code string `json:"code"` // 邀请码
Username string `json:"username" validate:"required"` // 用户名
Email string `json:"email" validate:"required"` // 邮箱
Password string `json:"password" validate:"required"` // 密码
Code string `json:"code" validate:"required"` // 邀请码
}

type ListLoginHistoryResp struct {
Expand Down
1 change: 1 addition & 0 deletions backend/internal/user/repo/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (r *UserRepo) CreateUser(ctx context.Context, user *db.User) (*db.User, err
SetEmail(user.Email).
SetPassword(user.Password).
SetStatus(user.Status).
SetPlatform(user.Platform).
Save(ctx)
}

Expand Down
9 changes: 3 additions & 6 deletions backend/internal/user/usecase/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"log/slog"
"net/url"
"strings"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -136,14 +135,12 @@ func (u *UserUsecase) Register(ctx context.Context, req *domain.RegisterReq) (*d
if err != nil {
return nil, err
}
parts := strings.Split(req.Email, "@")
if len(parts) != 2 {
return nil, errcode.ErrEmailInvalid
}
user := &db.User{
Username: parts[0],
Username: req.Username,
Email: req.Email,
Password: string(hash),
Status: consts.UserStatusActive,
Platform: consts.UserPlatformEmail,
}
n, err := u.repo.CreateUser(ctx, user)
if err != nil {
Expand Down
Loading