[web] first page try
This commit is contained in:
parent
baf722a95e
commit
e6cf99db85
|
@ -64,7 +64,7 @@ func handlerfunc(w http.ResponseWriter, r *http.Request) {
|
|||
logger = logger.WithField("hID", website.ID)
|
||||
|
||||
var menus []*modul.Menu
|
||||
dbconnection.Where("website = ?", website.ID).Preload("Menu").Find(&menus)
|
||||
dbconnection.Where("website = ?", website.ID).Preload("Menu").Order("position").Find(&menus)
|
||||
var menu *modul.Menu
|
||||
for _, item := range menus {
|
||||
if item.Shorturl == "" && menu == nil {
|
||||
|
|
|
@ -44,9 +44,11 @@ func NewAPI(config *libconfig.Config, sessions *session.Manager, dbconnection *g
|
|||
router.POST(prefix+"/website/:websiteid/domain/:domain", InvolveWebsiteHandler(api.DomainAdd, sessions, dbconnection))
|
||||
router.DELETE(prefix+"/website/:websiteid/domain/:domain", InvolveWebsiteHandler(api.DomainDelete, sessions, dbconnection))
|
||||
router.GET(prefix+"/website/:websiteid/menu", InvolveWebsiteHandler(api.MenuTree, sessions, dbconnection))
|
||||
router.GET(prefix+"/website/:websiteid/menu/list", InvolveWebsiteHandler(api.MenuList, sessions, dbconnection))
|
||||
router.POST(prefix+"/website/:websiteid/menu", InvolveWebsiteHandler(api.MenuAdd, sessions, dbconnection))
|
||||
router.PUT(prefix+"/website/:websiteid/menu/:menuid", InvolveWebsiteHandler(api.MenuEdit, sessions, dbconnection))
|
||||
router.DELETE(prefix+"/website/:websiteid/menu/:menuid", InvolveWebsiteHandler(api.MenuDelete, sessions, dbconnection))
|
||||
router.GET(prefix+"/website/:websiteid/page", InvolveWebsiteHandler(api.PageList, sessions, dbconnection))
|
||||
}
|
||||
|
||||
// Involve to get Website where loggend in user has privilegs
|
||||
|
|
|
@ -23,6 +23,17 @@ func (api *API) MenuTree(w http.ResponseWriter, r *http.Request, _ httprouter.Pa
|
|||
return
|
||||
}
|
||||
|
||||
// MenuList give all menu entries of a website
|
||||
func (api *API) MenuList(w http.ResponseWriter, r *http.Request, _ httprouter.Params, sess session.Session, login *libsystem.Login, websiteid int64) (returndata interface{}, returnerr *libapi.ErrorResult) {
|
||||
returndata = false
|
||||
logger := api.log.GetLog(r, "menulist")
|
||||
var menus []*Menu
|
||||
api.dbconnection.Where("website = ?", websiteid).Preload("Menu").Order("position").Find(&menus)
|
||||
returndata = menus
|
||||
logger.Info("done")
|
||||
return
|
||||
}
|
||||
|
||||
// MenuAdd to add a new menu entry
|
||||
func (api *API) MenuAdd(w http.ResponseWriter, r *http.Request, ps httprouter.Params, sess session.Session, login *libsystem.Login, websiteid int64) (returndata interface{}, returnerr *libapi.ErrorResult) {
|
||||
returndata = false
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/astaxie/session"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
libapi "dev.sum7.de/sum7/warehost/lib/api"
|
||||
libsystem "dev.sum7.de/sum7/warehost/system"
|
||||
)
|
||||
|
||||
// PageList give all pages of a website
|
||||
func (api *API) PageList(w http.ResponseWriter, r *http.Request, _ httprouter.Params, sess session.Session, login *libsystem.Login, websiteid int64) (returndata interface{}, returnerr *libapi.ErrorResult) {
|
||||
returndata = false
|
||||
logger := api.log.GetLog(r, "pagelist")
|
||||
var pages []*Page
|
||||
api.dbconnection.Where("website = ?", websiteid).Preload("Page").Find(&pages)
|
||||
returndata = pages
|
||||
logger.Info("done")
|
||||
return
|
||||
}
|
Reference in New Issue