fix version 1
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
// 设置支付方式配置
|
||||
func SetPayment(ctx context.Context, in *pb.SettingRequest) (reply *pb.IdentityStatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -23,10 +23,21 @@ func SetPayment(ctx context.Context, in *pb.SettingRequest) (reply *pb.IdentityS
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
if err := impl.DBService.Model(&models.MallStore{}).Where("identity = ?", in.GetIdentity()).Update("pay_configs", in.GetConfigs()).Error; err != nil {
|
||||
printer.Error(err.Error())
|
||||
// 只能修改当前登录者所属店铺的配置
|
||||
owner, _ := auth.Owner.(map[string]any)
|
||||
storeIdentity, _ := owner["store_identity"].(string)
|
||||
if storeIdentity == "" || in.GetIdentity() != storeIdentity {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
|
||||
tx := impl.DBService.Model(&models.MallStore{}).Where("identity = ?", in.GetIdentity()).Update("pay_configs", in.GetConfigs())
|
||||
if tx.Error != nil {
|
||||
printer.Error(tx.Error.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
if tx.RowsAffected == 0 {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
|
||||
return &pb.IdentityStatusReply{
|
||||
Code: 0,
|
||||
|
||||
Reference in New Issue
Block a user