This commit is contained in:
34
backend_v1/app/http/auth.go
Normal file
34
backend_v1/app/http/auth.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type auth struct{}
|
||||
|
||||
// Phone
|
||||
//
|
||||
// @Summary 手机验证
|
||||
// @Tags Auth
|
||||
// @Produce json
|
||||
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
|
||||
// @Router /v1/auth/:phone [post]
|
||||
// @Bind phone path
|
||||
func (ctl *posts) Phone(ctx fiber.Ctx, phone string) error {
|
||||
_, err := services.Users.FindByPhone(ctx, phone)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return errors.New("手机号未注册,请联系管理员开通")
|
||||
}
|
||||
return err
|
||||
}
|
||||
// TODO: send sms
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user