90 lines
3.0 KiB
Go
90 lines
3.0 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
|
|
v1 "git.5iot.com/iotlcm-public/iotlcm-app/api/app/v1"
|
|
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
|
)
|
|
|
|
func (c *ControllerV1) Captcha(ctx context.Context, req *v1.CaptchaReq) (res *v1.CaptchaRes, err error) {
|
|
captchaID, captchaImage, err := service.AppAuth().Captcha(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.CaptchaRes{
|
|
CaptchaID: captchaID,
|
|
CaptchaImage: captchaImage,
|
|
}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) SideCaptcha(ctx context.Context, req *v1.SideCaptchaReq) (res *v1.SideCaptchaRes, err error) {
|
|
captcha, err := service.AppAuth().SideCaptcha(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.SideCaptchaRes{AppSideCaptchaModel: *captcha}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) CheckSideCaptcha(ctx context.Context, req *v1.CheckSideCaptchaReq) (res *v1.CheckSideCaptchaRes, err error) {
|
|
if err = service.AppAuth().CheckSideCaptcha(ctx, &req.AppCheckSideCaptchaParam); err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.CheckSideCaptchaRes{Success: true}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) SendSms(ctx context.Context, req *v1.SendSmsReq) (res *v1.SendSmsRes, err error) {
|
|
sms, err := service.AppAuth().SendSms(ctx, &req.AppSendSmsParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.SendSmsRes{AppSendSmsModel: *sms}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) PhoneRegister(ctx context.Context, req *v1.PhoneRegisterReq) (res *v1.PhoneRegisterRes, err error) {
|
|
token, err := service.AppAuth().PhoneRegister(ctx, &req.AppPhoneRegisterParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.PhoneRegisterRes{AppAuthTokenModel: *token}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) PhoneLogin(ctx context.Context, req *v1.PhoneLoginReq) (res *v1.PhoneLoginRes, err error) {
|
|
token, err := service.AppAuth().PhoneLogin(ctx, &req.AppPhoneLoginParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.PhoneLoginRes{AppAuthTokenModel: *token}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) PhoneSmsLogin(ctx context.Context, req *v1.PhoneSmsLoginReq) (res *v1.PhoneSmsLoginRes, err error) {
|
|
token, err := service.AppAuth().PhoneSmsLogin(ctx, &req.AppPhoneSmsLoginParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.PhoneSmsLoginRes{AppAuthTokenModel: *token}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) WechatLogin(ctx context.Context, req *v1.WechatLoginReq) (res *v1.WechatLoginRes, err error) {
|
|
data, err := service.AppAuth().WechatLogin(ctx, &req.AppWechatLoginParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.WechatLoginRes{AppWechatLoginModel: *data}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) WechatBindPhone(ctx context.Context, req *v1.WechatBindPhoneReq) (res *v1.WechatBindPhoneRes, err error) {
|
|
data, err := service.AppAuth().WechatBindPhone(ctx, &req.AppWechatBindPhoneParam)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.WechatBindPhoneRes{AppWechatBindPhoneModel: *data}, nil
|
|
}
|
|
|
|
func (c *ControllerV1) ForgotPassword(ctx context.Context, req *v1.ForgotPasswordReq) (res *v1.ForgotPasswordRes, err error) {
|
|
if err = service.AppAuth().ForgotPassword(ctx, &req.AppForgotPasswordParam); err != nil {
|
|
return nil, err
|
|
}
|
|
return &v1.ForgotPasswordRes{Success: true}, nil
|
|
}
|