fix version 1
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
// 获取支付方式配置
|
||||
func GetPayment(ctx context.Context, in *pb.IdentRequest) (reply *pb.ConfigsReply, err error) {
|
||||
// parse authorization meta.
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -22,11 +22,21 @@ func GetPayment(ctx context.Context, in *pb.IdentRequest) (reply *pb.ConfigsRepl
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// 只能读取当前登录者所属店铺的配置
|
||||
owner, _ := auth.Owner.(map[string]any)
|
||||
storeIdentity, _ := owner["store_identity"].(string)
|
||||
|
||||
sotre := models.MallStore{}
|
||||
if err := impl.DBService.Model(&models.MallStore{}).Select("pay_configs").Where("id=? or identity=?", in.GetId(), in.GetIdentity()).Find(&sotre).Error; err != nil {
|
||||
print(err.Error())
|
||||
tx := impl.DBService.Model(&models.MallStore{}).Select("pay_configs").
|
||||
Where("id=? or identity=?", in.GetId(), in.GetIdentity()).
|
||||
Where("identity = ?", storeIdentity).Find(&sotre)
|
||||
if tx.Error != nil {
|
||||
print(tx.Error.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
if storeIdentity == "" || tx.RowsAffected == 0 {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
|
||||
return &pb.ConfigsReply{Configs: sotre.PayConfigs}, nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user