mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-04 07:43:28 +08:00
@@ -2008,6 +2008,9 @@
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"prompt": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2464,6 +2467,12 @@
|
||||
},
|
||||
"domain.RegisterReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"code",
|
||||
"email",
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"description": "邀请码",
|
||||
@@ -2476,6 +2485,10 @@
|
||||
"password": {
|
||||
"description": "密码",
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"description": "用户名",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user