fix: gorm fields && syncUserinfo dubplicate insertion

This commit is contained in:
lab
2021-11-10 03:02:48 +08:00
parent d0b8e93b80
commit f06ca4b247
5 changed files with 134 additions and 21 deletions

View File

@@ -53,7 +53,7 @@ func (srv Service) PublishEvent(ctx context.Context, subject string, message int
return nil
}
func (srv Service) GetAuthCodeURL(ctx context.Context, req *pb.GetCodeURLRequest) (*pb.GetCodeURLResponse, error) {
func (srv Service) GetCodeURL(ctx context.Context, req *pb.GetCodeURLRequest) (*pb.GetCodeURLResponse, error) {
resp := srv.client.GetCodeURL(req.RedirectUrl, req.State, mpauth.Scope(req.Scope.String()))
return &pb.GetCodeURLResponse{
@@ -163,7 +163,7 @@ func (srv Service) SyncUserinfo(ctx context.Context, req *pb.SyncUserinfoRequest
return nil, status.Errorf(codes.Internal, errors.Wrap(err, "get userinfo token from weixin failed").Error())
}
userinfo = Userinfo{Userinfo: *resp}
userinfo.Userinfo = *resp
if err := srv.db.Save(&userinfo).Error; err != nil {
return nil, status.Errorf(codes.Internal, errors.Wrap(err, "sync userinfo and save to database failed").Error())
}