@@ -2,14 +2,15 @@ package domain
22
33import (
44 "context"
5+ "strings"
56 "time"
67
78 "github.com/google/uuid"
89
10+ "github.com/chaitin/MonkeyCode/backend/consts"
911 "github.com/chaitin/MonkeyCode/backend/db"
12+ "github.com/chaitin/MonkeyCode/backend/errcode"
1013 "github.com/chaitin/MonkeyCode/backend/pkg/cvt"
11-
12- "github.com/chaitin/MonkeyCode/backend/consts"
1314)
1415
1516type UserUsecase interface {
@@ -41,13 +42,13 @@ type UserActiveRepo interface {
4142}
4243
4344type User struct {
44- ID uuid.UUID `json:"id"`
45- Name string `json:"name"`
46- AvatarURL string `json:"avatar_url"`
47- Email string `json:"email"`
48- Role consts.UserRole `json:"role"`
49- Status consts.UserStatus `json:"status"`
50- IsBlocked bool `json:"is_blocked"`
45+ ID uuid.UUID `json:"id"`
46+ Name string `json:"name"`
47+ AvatarURL string `json:"avatar_url"`
48+ Email string `json:"email"`
49+ Role consts.UserRole `json:"role"`
50+ Status consts.UserStatus `json:"status"`
51+ IsBlocked bool `json:"is_blocked"`
5152 Token string `json:"token,omitempty"`
5253 Identities []* UserIdentity `json:"identities"`
5354 Team * Team `json:"team,omitempty"`
@@ -143,16 +144,35 @@ type GetAccountInfoReq struct {
143144
144145// ResetUserPasswordReq 修改密码请求
145146type ResetUserPasswordReq struct {
146- NewPassword string `json:"new_password" validate:"required,min=8,max=32 "`
147+ NewPassword string `json:"new_password" validate:"required"`
147148 Token string `json:"token" validate:"required"`
148149}
149150
151+ func (r * ResetUserPasswordReq ) Validate () error {
152+ if len (r .NewPassword ) < 8 || len (r .NewPassword ) > 32 {
153+ return errcode .ErrPasswordLength
154+ }
155+ return nil
156+ }
157+
150158// ResetUserPasswordEmailReq 发送重置密码邮件请求
151159type ResetUserPasswordEmailReq struct {
152160 Emails []string `json:"emails" validate:"required"`
153161 CaptchaToken string `json:"captcha_token"`
154162}
155163
164+ func (r * ResetUserPasswordEmailReq ) Validate () error {
165+ if len (r .Emails ) == 0 {
166+ return errcode .ErrEmailRequired
167+ }
168+ for _ , email := range r .Emails {
169+ if strings .TrimSpace (email ) == "" {
170+ return errcode .ErrEmailRequired
171+ }
172+ }
173+ return nil
174+ }
175+
156176// TeamMembersResp 团队成员列表响应
157177type TeamMembersResp []* User
158178
0 commit comments