HFish/view/colony/view.go

45 lines
879 B
Go
Raw Normal View History

package colony
import (
"github.com/gin-gonic/gin"
"net/http"
2019-08-10 18:26:43 +08:00
"HFish/core/dbUtil"
"HFish/error"
2019-09-02 19:12:46 +08:00
"HFish/utils/log"
)
func Html(c *gin.Context) {
c.HTML(http.StatusOK, "colony.html", gin.H{})
}
2019-08-10 18:26:43 +08:00
2019-09-02 19:12:46 +08:00
// 获取蜜罐集群列表
2019-08-10 18:26:43 +08:00
func GetColony(c *gin.Context) {
2019-09-02 19:12:46 +08:00
result, err := dbUtil.DB().Table("hfish_colony").OrderBy("id desc").Get()
if err != nil {
log.Pr("HFish", "127.0.0.1", "获取蜜罐集群列表失败", err)
}
c.JSON(http.StatusOK, gin.H{
"code": error.ErrSuccessCode,
"msg": error.ErrSuccessMsg,
"data": result,
})
2019-08-10 18:26:43 +08:00
}
// 删除集群
func PostColonyDel(c *gin.Context) {
id := c.PostForm("id")
2019-09-02 19:12:46 +08:00
_, err := dbUtil.DB().Table("hfish_colony").Where("id", "=", id).Delete()
if err != nil {
log.Pr("HFish", "127.0.0.1", "删除集群失败", err)
}
2019-09-02 19:12:46 +08:00
c.JSON(http.StatusOK, gin.H{
"code": error.ErrSuccessCode,
"msg": error.ErrSuccessMsg,
})
}