Beispiel #1
0
func apiSetList(c *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error) {

	views.SetCache(w, 60*60)

	type setList struct {
		SetName string `db:"setName"  json:"setName"`
	}

	data := []setList{}
	err := c.Db.Select(&data, `SELECT setName FROM items GROUP BY setName ORDER BY setName ASC`)
	if err != nil {
		return http.StatusInternalServerError, err
	}

	encoder := json.NewEncoder(w)
	encoder.Encode(data)

	return 200, nil
}
Beispiel #2
0
func apiItemTypeList(c *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error) {

	views.SetCache(w, 60*60)

	type itemList struct {
		ItemType     int64  `db:"itemType" json:"itemType"`
		ItemTypeName string `db:"itemTypeName" json:"itemTypeName"`
	}

	data := []itemList{}
	err := c.Db.Select(&data, `SELECT itemType, itemTypeName FROM itemTypes `)
	if err != nil {
		return http.StatusInternalServerError, err
	}

	encoder := json.NewEncoder(w)
	encoder.Encode(data)

	return 200, nil
}
Beispiel #3
0
func apiPrograms(c *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error) {

	views.SetCache(w, 60*60)

	type setList struct {
		ProgramName    string `db:"programName"  json:"programName"`
		ProgramVersion string `db:"programVersion"  json:"programVersion"`
	}

	data := []setList{}
	err := c.Db.Select(&data, `SELECT programName, programVersion FROM programs ORDER BY programName ASC`)
	if err != nil {
		return http.StatusInternalServerError, err
	}

	encoder := json.NewEncoder(w)
	encoder.Encode(data)

	return 200, nil
}
Beispiel #4
0
func apiServerList(c *appcontext.AppContext, w http.ResponseWriter, r *http.Request) (int, error) {

	views.SetCache(w, 60*60)

	type serverList struct {
		ServerID   int64  `db:"serverID" json:"serverID"`
		ServerName string `db:"serverName" json:"serverName"`
		Path       string `db:"path" json:"path"`
	}

	data := []serverList{}
	err := c.Db.Select(&data, `SELECT serverID, serverName, path FROM servers`)
	if err != nil {
		return http.StatusInternalServerError, err
	}

	encoder := json.NewEncoder(w)
	encoder.Encode(data)

	return 200, nil
}