update profile api (#16)

* update profile api

* rename

* fix realip assertion

* add waf api
This commit is contained in:
UUBulb authored and GitHub committed 2024-11-23 16:22:22 +08:00
1 parent 6db1a4b19d
commit e465134c11
7 files changed
+85 -7

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
package controller
import (
"github.com/gin-gonic/gin"
"github.com/naiba/nezha/model"
"github.com/naiba/nezha/service/singleton"
)
// List blocked addresses
// @Summary List blocked addresses
// @Security BearerAuth
// @Schemes
// @Description List server
// @Tags auth required
// @Produce json
// @Success 200 {object} model.CommonResponse[[]model.WAF]
// @Router /waf [get]
func listBlockedAddress(c *gin.Context) ([]*model.WAF, error) {
var waf []*model.WAF
if err := singleton.DB.Find(&waf).Error; err != nil {
return nil, err
}
return waf, nil
}
// Batch delete blocked addresses
// @Summary Edit server
// @Security BearerAuth
// @Schemes
// @Description Edit server
// @Tags auth required
// @Accept json
// @Param request body []string true "block list"
// @Produce json
// @Success 200 {object} model.CommonResponse[any]
// @Router /batch-delete/waf [patch]
func batchDeleteBlockedAddress(c *gin.Context) (any, error) {
var list []string
if err := c.ShouldBindJSON(&list); err != nil {
return nil, err
}
if err := model.BatchClearIP(singleton.DB, list); err != nil {
return nil, newGormError("%v", err)
}
return nil, nil
}