소스 검색

refactor(waf): 修改 CC白名单入参字段名

- 将结构体字段名 Reason改为 Comment,以更好地反映其用途
- 相应地修改了处理函数和服务接口中的参数名
- 这个改动不影响功能,仅提高了代码的可读性和一致性
fusu 2 주 전
부모
커밋
7813413ebd
3개의 변경된 파일9개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      api/v1/ccIpList.go
  2. 2 2
      internal/handler/api/waf/cciplist.go
  3. 6 6
      internal/service/api/flexCdn/cciplist.go

+ 1 - 1
api/v1/ccIpList.go

@@ -12,7 +12,7 @@ type CcIpList struct {
 	Uid int64 `json:"uid" form:"uid" validate:"required"`
 	HostId int64 `json:"hostId" form:"hostId" validate:"required"`
 	WebId int64 `json:"webId" form:"webId" validate:"required"`
-	Reason string `json:"reason" form:"reason"`
+	Comment string `json:"comment" form:"comment"`
 }
 
 type DelCcIpList struct {

+ 2 - 2
internal/handler/api/waf/cciplist.go

@@ -43,7 +43,7 @@ func (h *CcIpListHandler) AddCcIpList(ctx *gin.Context) {
 		v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
 		return
 	}
-	err := h.ccIpListService.AddCcWhiteIp(ctx, req.WebId,req.NewIp,req.Reason)
+	err := h.ccIpListService.AddCcWhiteIp(ctx, req.WebId,req.NewIp,req.Comment)
 	if err != nil {
 		v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
 		return
@@ -72,7 +72,7 @@ func (h *CcIpListHandler) EditCcIpList(ctx *gin.Context) {
 		v1.HandleError(ctx, http.StatusBadRequest, v1.ErrBadRequest, err.Error())
 		return
 	}
-	err := h.ccIpListService.EditCcWhiteIp(ctx, req.WebId,req.OldIp,req.NewIp,req.Reason)
+	err := h.ccIpListService.EditCcWhiteIp(ctx, req.WebId,req.OldIp,req.NewIp,req.Comment)
 	if err != nil {
 		v1.HandleError(ctx, http.StatusInternalServerError, err, err.Error())
 		return

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

@@ -12,9 +12,9 @@ import (
 type CcIpListService interface {
 	GetCcIpList(ctx context.Context, webId int64) ([]string, error)
 	AddCcIpListPolicy(ctx context.Context, serverId int64,serverGroupId int64) error
-	AddCcWhiteIp(ctx context.Context, webId int64,ip string,reason string) error
+	AddCcWhiteIp(ctx context.Context, webId int64,ip string,comment string) error
 	DelCcWhiteIp(ctx context.Context, webId int64,ips []string) error
-	EditCcWhiteIp(ctx context.Context, webId int64,oldIp string,newIp string,reason string) error
+	EditCcWhiteIp(ctx context.Context, webId int64,oldIp string,newIp string,comment string) error
 
 }
 func NewCcIpListService(
@@ -94,7 +94,7 @@ func (s *ccIpListService) AddCcIpListPolicy(ctx context.Context, serverId int64,
 
 
 // 添加白名单
-func (s *ccIpListService) AddCcWhiteIp(ctx context.Context, webId int64,ip string,reason string) error {
+func (s *ccIpListService) AddCcWhiteIp(ctx context.Context, webId int64,ip string,comment string) error {
 	serverId, err := s.GetServerId(ctx, webId)
 	if err != nil {
 		return err
@@ -107,7 +107,7 @@ func (s *ccIpListService) AddCcWhiteIp(ctx context.Context, webId int64,ip strin
 	err = s.cdn.AddIpItem(ctx,v1.AddIpItem{
 		IpListId: ipListId,
 		Value: ip,
-		Reason: reason,
+		Reason: comment,
 		EventLevel: "notice",
 		SourceCategory: "cc",
 	})
@@ -117,7 +117,7 @@ func (s *ccIpListService) AddCcWhiteIp(ctx context.Context, webId int64,ip strin
 	return nil
 }
 
-func (s *ccIpListService) EditCcWhiteIp(ctx context.Context, webId int64,oldIp string,newIp string,reason string) error {
+func (s *ccIpListService) EditCcWhiteIp(ctx context.Context, webId int64,oldIp string,newIp string,comment string) error {
 	serverId, err := s.GetServerId(ctx, webId)
 	if err != nil {
 		return err
@@ -134,7 +134,7 @@ func (s *ccIpListService) EditCcWhiteIp(ctx context.Context, webId int64,oldIp s
 	err = s.cdn.EditIpItem(ctx,v1.AddIpItem{
 		IpItemId: ipItemId,
 		Value: newIp,
-		Reason: reason,
+		Reason: comment,
 		EventLevel: "notice",
 		SourceCategory: "cc",
 	})