|
|
@@ -278,9 +278,25 @@ func (s *Server) handleCreateBinding(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
func (s *Server) handleDeleteBinding(c *gin.Context) {
|
|
|
- _ = c.Param("id")
|
|
|
- // TODO: Convert to uint and delete
|
|
|
- c.JSON(http.StatusOK, gin.H{"message": "Binding deleted"})
|
|
|
+ id := c.Param("id")
|
|
|
+ if id == "" {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": "ID is required"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // Delete from database
|
|
|
+ result := s.db.Where("id = ?", id).Delete(&db.DHCPStaticBinding{})
|
|
|
+ if result.Error != nil {
|
|
|
+ c.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error()})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if result.RowsAffected == 0 {
|
|
|
+ c.JSON(http.StatusNotFound, gin.H{"error": "Binding not found"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ c.JSON(http.StatusOK, gin.H{"message": "Binding deleted successfully"})
|
|
|
}
|
|
|
|
|
|
func (s *Server) handleEvictClient(c *gin.Context) {
|
|
|
@@ -338,9 +354,25 @@ func (s *Server) handleCreateRecord(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
func (s *Server) handleDeleteRecord(c *gin.Context) {
|
|
|
- _ = c.Param("id")
|
|
|
- // TODO: Convert to uint and delete
|
|
|
- c.JSON(http.StatusOK, gin.H{"message": "Record deleted"})
|
|
|
+ id := c.Param("id")
|
|
|
+ if id == "" {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"error": "ID is required"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // Delete from database
|
|
|
+ result := s.db.Where("id = ?", id).Delete(&db.DNSRecord{})
|
|
|
+ if result.Error != nil {
|
|
|
+ c.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error()})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if result.RowsAffected == 0 {
|
|
|
+ c.JSON(http.StatusNotFound, gin.H{"error": "Record not found"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ c.JSON(http.StatusOK, gin.H{"message": "Record deleted successfully"})
|
|
|
}
|
|
|
|
|
|
func (s *Server) handleGetLogs(c *gin.Context) {
|