mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
[dashboard 0.3.3] 添加计划任务可搜索服务器
This commit is contained in:
@@ -33,7 +33,7 @@ func (ma *memberAPI) serve() {
|
||||
Redirect: "/login",
|
||||
}))
|
||||
|
||||
mr.POST("/logout", ma.logout)
|
||||
mr.GET("/search-server", ma.searchServer)
|
||||
mr.POST("/server", ma.addOrEditServer)
|
||||
mr.POST("/monitor", ma.addOrEditMonitor)
|
||||
mr.POST("/cron", ma.addOrEditCron)
|
||||
@@ -41,6 +41,7 @@ func (ma *memberAPI) serve() {
|
||||
mr.POST("/alert-rule", ma.addOrEditAlertRule)
|
||||
mr.POST("/setting", ma.updateSetting)
|
||||
mr.DELETE("/:model/:id", ma.delete)
|
||||
mr.POST("/logout", ma.logout)
|
||||
}
|
||||
|
||||
func (ma *memberAPI) delete(c *gin.Context) {
|
||||
@@ -102,6 +103,33 @@ func (ma *memberAPI) delete(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
type searchResult struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Value uint64 `json:"value,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
func (ma *memberAPI) searchServer(c *gin.Context) {
|
||||
var servers []model.Server
|
||||
likeWord := "%" + c.Query("word") + "%"
|
||||
dao.DB.Select("id,name").Where("id = ? OR name LIKE ? OR tag LIKE ? OR note LIKE ?",
|
||||
c.Query("word"), likeWord, likeWord, likeWord).Find(&servers)
|
||||
|
||||
var resp []searchResult
|
||||
for i := 0; i < len(servers); i++ {
|
||||
resp = append(resp, searchResult{
|
||||
Value: servers[i].ID,
|
||||
Name: servers[i].Name,
|
||||
Text: servers[i].Name,
|
||||
})
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, map[string]interface{}{
|
||||
"success": true,
|
||||
"results": resp,
|
||||
})
|
||||
}
|
||||
|
||||
type serverForm struct {
|
||||
ID uint64
|
||||
Name string `binding:"required"`
|
||||
|
||||
Reference in New Issue
Block a user