This commit is contained in:
@@ -255,7 +255,7 @@ func (s *Service) GetCardByICCID(ctx context.Context, iccid string) (*model.IotC
|
|||||||
|
|
||||||
// AllocateDevices 批量分配设备
|
// AllocateDevices 批量分配设备
|
||||||
func (s *Service) AllocateDevices(ctx context.Context, req *dto.AllocateDevicesRequest, operatorID uint, operatorShopID *uint) (*dto.AllocateDevicesResponse, error) {
|
func (s *Service) AllocateDevices(ctx context.Context, req *dto.AllocateDevicesRequest, operatorID uint, operatorShopID *uint) (*dto.AllocateDevicesResponse, error) {
|
||||||
// 验证目标店铺是否为直属下级
|
// 代理仅可分配给直属下级;平台/超级管理员可跨级分配
|
||||||
if err := s.validateDirectSubordinate(ctx, operatorShopID, req.TargetShopID); err != nil {
|
if err := s.validateDirectSubordinate(ctx, operatorShopID, req.TargetShopID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -470,14 +470,14 @@ func (s *Service) validateDirectSubordinate(ctx context.Context, operatorShopID
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 平台/超级管理员可跨级分配到任意店铺(前置已校验目标店铺存在)
|
||||||
if operatorShopID == nil {
|
if operatorShopID == nil {
|
||||||
if targetShop.ParentID != nil {
|
return nil
|
||||||
return errors.ErrNotDirectSubordinate
|
}
|
||||||
}
|
|
||||||
} else {
|
// 代理仅允许分配给直属下级店铺
|
||||||
if targetShop.ParentID == nil || *targetShop.ParentID != *operatorShopID {
|
if targetShop.ParentID == nil || *targetShop.ParentID != *operatorShopID {
|
||||||
return errors.ErrNotDirectSubordinate
|
return errors.ErrNotDirectSubordinate
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -613,14 +613,14 @@ func (s *Service) validateDirectSubordinate(ctx context.Context, operatorShopID
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 平台/超级管理员可跨级分配到任意店铺(前置已校验目标店铺存在)
|
||||||
if operatorShopID == nil {
|
if operatorShopID == nil {
|
||||||
if targetShop.ParentID != nil {
|
return nil
|
||||||
return errors.ErrNotDirectSubordinate
|
}
|
||||||
}
|
|
||||||
} else {
|
// 代理仅允许分配给直属下级店铺
|
||||||
if targetShop.ParentID == nil || *targetShop.ParentID != *operatorShopID {
|
if targetShop.ParentID == nil || *targetShop.ParentID != *operatorShopID {
|
||||||
return errors.ErrNotDirectSubordinate
|
return errors.ErrNotDirectSubordinate
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user