sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0

select domain id

This commit is contained in:
Martin Geno 2016-12-13 12:43:51 +01:00
parent 39d35857a1
commit 6a350ac9fb
1 changed files with 8 additions and 4 deletions

View File

@ -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")