初始化项目框架,完成部分接口开发
This commit is contained in:
5
internal/controller/auth/auth.go
Normal file
5
internal/controller/auth/auth.go
Normal file
@ -0,0 +1,5 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package auth
|
||||
15
internal/controller/auth/auth_new.go
Normal file
15
internal/controller/auth/auth_new.go
Normal file
@ -0,0 +1,15 @@
|
||||
// =================================================================================
|
||||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
// =================================================================================
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
"server/api/auth"
|
||||
)
|
||||
|
||||
type ControllerV1 struct{}
|
||||
|
||||
func NewV1() auth.IAuthV1 {
|
||||
return &ControllerV1{}
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_admin_login.go
Normal file
17
internal/controller/auth/auth_v1_admin_login.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AdminLogin(ctx context.Context, req *v1.AdminLoginReq) (res *v1.AdminLoginRes, err error) {
|
||||
out, err := service.Admin().Login(ctx, &model.AdminLoginIn{Username: req.Username, Password: req.Password})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AdminLoginRes{Token: out.Token}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_user_code.go
Normal file
17
internal/controller/auth/auth_v1_user_code.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserCode(ctx context.Context, req *v1.UserCodeReq) (res *v1.UserCodeRes, err error) {
|
||||
out, err := service.User().Code(ctx, &model.UserCodeIn{Email: req.Email})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserCodeRes{Success: out.Success}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_user_edit_pass.go
Normal file
17
internal/controller/auth/auth_v1_user_edit_pass.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserEditPass(ctx context.Context, req *v1.UserEditPassReq) (res *v1.UserEditPassRes, err error) {
|
||||
out, err := service.User().EditPass(ctx, &model.UserEditPassIn{Email: req.Email, Password: req.Password, Password2: req.Password2, Sign: req.Sign})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserEditPassRes{Success: out.Success}, nil
|
||||
}
|
||||
18
internal/controller/auth/auth_v1_user_login.go
Normal file
18
internal/controller/auth/auth_v1_user_login.go
Normal file
@ -0,0 +1,18 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserLogin(ctx context.Context, req *v1.UserLoginReq) (res *v1.UserLoginRes, err error) {
|
||||
out, err := service.User().Login(ctx, &model.UserLoginIn{Email: req.Email, Password: req.Password})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &v1.UserLoginRes{Token: out.Token}, nil
|
||||
}
|
||||
17
internal/controller/auth/auth_v1_user_register.go
Normal file
17
internal/controller/auth/auth_v1_user_register.go
Normal file
@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) UserRegister(ctx context.Context, req *v1.UserRegisterReq) (res *v1.UserRegisterRes, err error) {
|
||||
out, err := service.User().Register(ctx, &model.UserRegisterIn{Email: req.Email, Password: req.Password, Password2: req.Password2})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UserRegisterRes{Success: out.Success}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user