|
@@ -15,7 +15,7 @@ type TcpforwardingService interface {
|
|
|
GetTcpforwarding(ctx context.Context, req v1.GetForwardingRequest) (v1.TcpForwardingDataRequest, error)
|
|
|
AddTcpForwarding(ctx context.Context, req *v1.TcpForwardingRequest) error
|
|
|
EditTcpForwarding(ctx context.Context, req *v1.TcpForwardingRequest) error
|
|
|
- DeleteTcpForwarding(ctx context.Context, Id int) error
|
|
|
+ DeleteTcpForwarding(ctx context.Context, req v1.DeleteTcpForwardingRequest) error
|
|
|
}
|
|
|
|
|
|
func NewTcpforwardingService(
|
|
@@ -69,7 +69,7 @@ func (s *tcpforwardingService) GetTcpforwarding(ctx context.Context, req v1.GetF
|
|
|
})
|
|
|
|
|
|
g.Go(func() error {
|
|
|
- res, e := s.tcpforwardingRepository.GetTcpForwardingByID(gCtx, req.Id)
|
|
|
+ res, e := s.tcpforwardingRepository.GetTcpForwardingIpsByID(gCtx, req.Id)
|
|
|
if e != nil {
|
|
|
return fmt.Errorf("GetTcpforwardingIps failed: %w", e)
|
|
|
}
|
|
@@ -259,19 +259,24 @@ func (s *tcpforwardingService) EditTcpForwarding(ctx context.Context, req *v1.Tc
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (s *tcpforwardingService) DeleteTcpForwarding(ctx context.Context, Id int) error {
|
|
|
- wafTcpId, err := s.tcpforwardingRepository.GetTcpforwardingWafTcpIdById(ctx, Id)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- _, err = s.crawler.DeleteRule(ctx, wafTcpId, "admin/delete/waf_tcp?page=1&__pageSize=10&__sort=waf_tcp_id&__sort_type=desc")
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+func (s *tcpforwardingService) DeleteTcpForwarding(ctx context.Context, req v1.DeleteTcpForwardingRequest) error {
|
|
|
+ for _, Id := range req.Ids {
|
|
|
+ wafTcpId, err := s.tcpforwardingRepository.GetTcpforwardingWafTcpIdById(ctx, Id)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ _, err = s.crawler.DeleteRule(ctx, wafTcpId, "admin/delete/waf_tcp?page=1&__pageSize=1000000&__sort=waf_tcp_id&__sort_type=desc")
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
|
|
|
- if err = s.tcpforwardingRepository.DeleteTcpforwarding(ctx, int64(Id)); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+ if err = s.tcpforwardingRepository.DeleteTcpforwarding(ctx, int64(Id)); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
|
|
|
+ if err = s.tcpforwardingRepository.DeleteTcpForwardingIpsById(ctx, Id); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
return nil
|
|
|
}
|