mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	变更版本
This commit is contained in:
		@@ -35,7 +35,7 @@ func (this *BaseService) ValidateAdminAndUser(ctx context.Context, requireAdminI
 | 
			
		||||
	switch reqUserType {
 | 
			
		||||
	case rpcutils.UserTypeAdmin:
 | 
			
		||||
		adminId = reqUserId
 | 
			
		||||
		if adminId <= 0 {
 | 
			
		||||
		if adminId < 0 { // 允许AdminId = 0
 | 
			
		||||
			err = errors.New("invalid 'adminId'")
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,10 @@ package services
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/db/models"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/errors"
 | 
			
		||||
	rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"net"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// IP条目相关服务
 | 
			
		||||
@@ -20,6 +22,22 @@ func (this *IPItemService) CreateIPItem(ctx context.Context, req *pb.CreateIPIte
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(req.IpFrom) == 0 {
 | 
			
		||||
		return nil, errors.New("'ipFrom' should not be empty")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ipFrom := net.ParseIP(req.IpFrom)
 | 
			
		||||
	if ipFrom == nil {
 | 
			
		||||
		return nil, errors.New("invalid 'ipFrom'")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(req.IpTo) > 0 {
 | 
			
		||||
		ipTo := net.ParseIP(req.IpTo)
 | 
			
		||||
		if ipTo == nil {
 | 
			
		||||
			return nil, errors.New("invalid 'ipTo'")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	if userId > 0 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user