From 6a350ac9fb23647cbf702fbc0a3140c463dc2b9b Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Tue, 13 Dec 2016 12:43:51 +0100 Subject: [PATCH] select domain id --- modul/host/apidomain.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modul/host/apidomain.go b/modul/host/apidomain.go index 21c01ca..2d32b4c 100644 --- a/modul/host/apidomain.go +++ b/modul/host/apidomain.go @@ -24,17 +24,21 @@ func getDomain(ctx context.Context, w http.ResponseWriter) (domain Domain, retur w.WriteHeader(http.StatusBadRequest) return } - fmt.Println(id) + domain = Domain{ID: id} + if login.Superadmin { - dbconnection.Where(map[string]int64{"ID": id}).Find(&domain) + dbconnection.Find(&domain) } else { - dbconnection.Where(map[string]int64{"ID": id, "profil": profil.ID}).Find(&domain) + dbconnection.Where(map[string]int64{"profil": profil.ID}).Find(&domain) } if domain.ID <= 0 { returnerr = &libapi.ErrorResult{Fields: []string{"domain"}, Message: "not found"} w.WriteHeader(http.StatusNotFound) } + if id != domain.ID { + fmt.Printf("want %d, get %d", id, domain.ID) + } return } @@ -56,7 +60,7 @@ func domainList(ctx context.Context, w http.ResponseWriter, r *http.Request) (re func domainShow(ctx context.Context, w http.ResponseWriter, r *http.Request) (returndata interface{}, returnerr *libapi.ErrorResult) { returndata = false - logger := log.GetLog(r, "domainlist") + logger := log.GetLog(r, "domainshow") domain, returnerr := getDomain(ctx, w) if returnerr != nil { logger.Info("not found")