Пример #1
0
// read general setting
//
//  in  : nil
//  out : {
//          "general":*SettingGeneral
//        }
//
func (_ *SettingApi) ReadGeneral(v interface{}) *Res {
	generalSettings, err := model.GetSettings("title", "subtitle", "desc", "keyword", "baseurl")
	if err != nil {
		return Fail(err)
	}
	general := &SettingGeneral{
		Title:    generalSettings["title"],
		Subtitle: generalSettings["subtitle"],
		Desc:     generalSettings["desc"],
		Keyword:  generalSettings["keyword"],
		BaseUrl:  generalSettings["baseurl"],
	}
	return Success(map[string]interface{}{
		"general": general,
	})
}
Пример #2
0
// read media setting
//
//  in  : nil
//  out : {
//          "media":*SettingMedia
//        }
//
func (_ *SettingApi) ReadMedia(v interface{}) *Res {
	settings, err := model.GetSettings("media_maxsize",
		"media_imageext",
		"media_fileexit",
		"media_nameformat")
	if err != nil {
		return Fail(err)
	}
	mediaSetting := &SettingMedia{
		ImageExt:   settings["media_imageext"],
		FileExt:    settings["media_fileext"],
		NameFormat: settings["media_nameformat"],
	}
	mediaSetting.MaxSize, _ = strconv.ParseInt(settings["media_maxsize"], 10, 64)
	prepareMediaSetting(mediaSetting)
	return Success(map[string]interface{}{
		"media": mediaSetting,
	})
}