解决部分

This commit is contained in:
eson
2023-07-20 15:21:03 +08:00
parent 3e1d4d2e4f
commit 8c7884bcc3
8 changed files with 210 additions and 174 deletions

View File

@@ -27,9 +27,9 @@ func NewUserGetTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserG
func (l *UserGetTypeLogic) UserGetType(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
if userinfo.GetIdType() != auth.IDTYPE_User {
return resp.SetStatus(basic.CodeUnAuth)
}
// if userinfo.GetIdType() != auth.IDTYPE_User {
// return resp.SetStatus(basic.CodeUnAuth)
// }
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
data, err := l.svcCtx.AllModels.FsCanteenType.FindAllGetType(l.ctx)

View File

@@ -35,6 +35,16 @@ func NewUserGoogleLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U
}
}
func (l *UserGoogleLoginLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
log.Println(r, w)
}
func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
log.Println(resp.Message)
http.Redirect(w, r, "http://localhost:9900/?token="+resp.Message, http.StatusMovedPermanently)
// log.Println(r, w)
}
func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
@@ -77,11 +87,13 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us
log.Println(r.Json())
googleId := r.Json().Get("id").Int()
return resp.Set(304, "21321321")
user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId)
log.Println(user)
if err != nil {
if err != gorm.ErrRecordNotFound {
logx.Error(err)
return resp.SetStatus(basic.CodeDbSqlErr)
}