fix model validation and preloading

This commit is contained in:
Ben
2021-07-28 23:16:13 +02:00
parent 79bd7fed9c
commit 8ae1f7edcf
4 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ func (h *Handler) DeleteCName(c echo.Context) (err error) {
}
cname := &model.CName{}
if err = h.DB.First(cname, id).Error; err != nil {
if err = h.DB.Preload("Target").First(cname, id).Error; err != nil {
return c.JSON(http.StatusBadRequest, &Error{err.Error()})
}
-1
View File
@@ -292,7 +292,6 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
}
func (h *Handler) checkUniqueHostname(hostname, domain string) error {
fmt.Println(hostname, domain)
hosts := new([]model.Host)
if err := h.DB.Where(&model.Host{Hostname: hostname, Domain: domain}).Find(hosts).Error; err != nil {
return err