mirror of
https://github.com/AuxXxilium/docker-ddns-server.git
synced 2024-11-23 23:00:59 +07:00
Merge pull request #9 from benjaminbear/fix_cname_delete
fix model validation and preloading
This commit is contained in:
commit
56c46933a6
10
.travis.yml
10
.travis.yml
@ -1,18 +1,18 @@
|
|||||||
dist: bionic
|
|
||||||
|
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
env: GO111MODULE=on
|
env: GO111MODULE=on
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.15.x
|
- 1.13.x
|
||||||
- 1.16.x
|
- 1.14.x
|
||||||
|
|
||||||
git:
|
git:
|
||||||
depth: 1
|
depth: 1
|
||||||
|
|
||||||
script:
|
before_script:
|
||||||
- cd dyndns
|
- cd dyndns
|
||||||
|
|
||||||
|
script:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
- go build ./...
|
- go build ./...
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func (h *Handler) DeleteCName(c echo.Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cname := &model.CName{}
|
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()})
|
return c.JSON(http.StatusBadRequest, &Error{err.Error()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +292,6 @@ func (h *Handler) UpdateIP(c echo.Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) checkUniqueHostname(hostname, domain string) error {
|
func (h *Handler) checkUniqueHostname(hostname, domain string) error {
|
||||||
fmt.Println(hostname, domain)
|
|
||||||
hosts := new([]model.Host)
|
hosts := new([]model.Host)
|
||||||
if err := h.DB.Where(&model.Host{Hostname: hostname, Domain: domain}).Find(hosts).Error; err != nil {
|
if err := h.DB.Where(&model.Host{Hostname: hostname, Domain: domain}).Find(hosts).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
type Host struct {
|
type Host struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Hostname string `gorm:"unique_index:idx_host_domain;not null" form:"hostname" validate:"required,hostname"`
|
Hostname string `gorm:"unique_index:idx_host_domain;not null" form:"hostname" validate:"required,hostname"`
|
||||||
Domain string `gorm:"unique_index:idx_host_domain;not null" validate:"required,hostname"`
|
Domain string `gorm:"unique_index:idx_host_domain;not null" form:"domain" validate:"required,hostname"`
|
||||||
Ip string `form:"ip" validate:"omitempty,ipv4"`
|
Ip string `form:"ip" validate:"omitempty,ipv4"`
|
||||||
Ttl int `form:"ttl" validate:"required,min=20,max=86400"`
|
Ttl int `form:"ttl" validate:"required,min=20,max=86400"`
|
||||||
LastUpdate time.Time `form:"lastupdate"`
|
LastUpdate time.Time `form:"lastupdate"`
|
||||||
|
Loading…
Reference in New Issue
Block a user