feat: analysis user auth and ws
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/rpcclient"
|
||||
"lone-services/pkg/utils"
|
||||
storepb "lone-services/rpc/store/pb"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func fetchStoreById(ctx context.Context, storeSvcName string, storeId int64) (*storepb.InfoResponse, error) {
|
||||
if storeSvcName == utils.StringEmpty || storeId < utils.NumberOne {
|
||||
return nil, nil
|
||||
}
|
||||
cli, err := rpcclient.Get(storeSvcName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, err := storepb.NewStoreClient(cli.Conn()).GetInfoById(ctx, &storepb.IdRequest{Id: storeId})
|
||||
if err != nil {
|
||||
if st, ok := status.FromError(err); ok &&
|
||||
(st.Code() == codes.NotFound || st.Message() == utils.ErrorNotFund.Msg) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if data == nil || data.Id < utils.NumberOne {
|
||||
return nil, nil
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
Reference in New Issue
Block a user