فهرست منبع

feat(api): 增加 CC 白名单 IP 列表响应结构

- 新增 CcIpListResponse 结构体,用于 CC 白名单 IP 列表的响应数据
- 更新 CcIpListRepository 和 CcIpListService 接口,使用新的响应结构体
- 修改 GetCcIpList 方法,返回值改为 CcIpListResponse 列表
fusu 2 هفته پیش
والد
کامیت
c0b4454aa0
3فایلهای تغییر یافته به همراه13 افزوده شده و 6 حذف شده
  1. 6 0
      api/v1/ccIpList.go
  2. 5 4
      internal/repository/api/flexCdn/cciplist.go
  3. 2 2
      internal/service/api/flexCdn/cciplist.go

+ 6 - 0
api/v1/ccIpList.go

@@ -21,3 +21,9 @@ type DelCcIpList struct {
 	HostId int64 `json:"hostId" form:"hostId" validate:"required"`
 	WebId int64 `json:"webId" form:"webId" validate:"required"`
 }
+
+type CcIpListResponse struct {
+	Value string `json:"value" form:"value"`
+	Type string `json:"type" form:"type"`
+	Comment string `json:"comment" form:"comment" gorm:"column:reason"`
+}

+ 5 - 4
internal/repository/api/flexCdn/cciplist.go

@@ -2,11 +2,12 @@ package flexCdn
 
 import (
 	"context"
+	v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
 	"github.com/go-nunu/nunu-layout-advanced/internal/repository"
 )
 
 type CcIpListRepository interface {
-	GetCcIpList(ctx context.Context, serverId int64) ([]string, error)
+	GetCcIpList(ctx context.Context, serverId int64) ([]v1.CcIpListResponse, error)
 	GetHttpWebId(ctx context.Context, serverId int64) (int64, error)
 	GetIpListId(ctx context.Context, serverId int64,ipListType string) (int64,error)
 	GetIpId(ctx context.Context, ipListId int64,ip string,sourceCategory string) (int64,error)
@@ -26,13 +27,13 @@ type ccIpListRepository struct {
 	*repository.Repository
 }
 
-func (r *ccIpListRepository) GetCcIpList(ctx context.Context, serverId int64) ([]string, error) {
+func (r *ccIpListRepository) GetCcIpList(ctx context.Context, serverId int64) ([]v1.CcIpListResponse, error) {
+	var req []v1.CcIpListResponse
 	ipListId, err := r.GetIpListId(ctx, serverId,"white")
 	if err != nil {
 		return nil, err
 	}
-	var ips []string
-	return ips, r.DBWithName(ctx,"cdn").Table("cloud_ip_items").Where("listId = ? AND sourceCategory = ?", ipListId, "cc").Select("value").Scan(&ips).Error
+	return req, r.DBWithName(ctx,"cdn").Table("cloud_ip_items").Where("listId = ? AND sourceCategory = ?", ipListId, "cc").Select("value,type, reason").Scan(&req).Error
 }
 
 func (r *ccIpListRepository) GetHttpWebId(ctx context.Context, serverId int64) (int64, error) {

+ 2 - 2
internal/service/api/flexCdn/cciplist.go

@@ -10,7 +10,7 @@ import (
 )
 
 type CcIpListService interface {
-	GetCcIpList(ctx context.Context, webId int64) ([]string, error)
+	GetCcIpList(ctx context.Context, webId int64) ([]v1.CcIpListResponse, error)
 	AddCcIpListPolicy(ctx context.Context, serverId int64,serverGroupId int64) error
 	AddCcWhiteIp(ctx context.Context, webId int64,ip string,comment string) error
 	DelCcWhiteIp(ctx context.Context, webId int64,ips []string) error
@@ -46,7 +46,7 @@ func (s *ccIpListService) GetServerId(ctx context.Context, webId int64) (int64,
 	return int64(webData.CdnWebId), nil
 }
 
-func (s *ccIpListService) GetCcIpList(ctx context.Context, webId int64) ([]string, error) {
+func (s *ccIpListService) GetCcIpList(ctx context.Context, webId int64) ([]v1.CcIpListResponse, error) {
 	webData, err := s.webForwardingRep.GetWebForwarding(ctx, webId)
 	if err != nil {
 		return nil, err