You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: SysController.go
    path of file: ./repos/DocHub/controllers/AdminControllers
    
    the code of the file until where you have to start completion: package AdminControllers

import (
	"net/http"
	"strings"

	"io/ioutil"
	"time"

	"path/filepath"

	"os"

	"github.com/TruthHun/DocHub/helper"
	"github.com/TruthHun/DocHub/models"
	"github.com/astaxie/beego/orm"
)

type SysController struct {
	BaseController
}

type logFile struct {
	Path    string
	ModTime time.Time
	Size    int
}

//系统配置管理
func (this *SysController) Get() {
	tab := helper.ConfigCate(strings.ToLower(this.GetString("tab")))
	var err error
	switch tab {
	case models.ConfigCateEmail, models.ConfigCateDepend, models.ConfigCateElasticSearch, models.ConfigCateLog:
	default:
		tab = "default"
	}
	if this.Ctx.Request.Method == http.MethodPost {
		defer func() {
			models.NewSys().UpdateGlobalConfig()
			models.NewConfig().UpdateGlobalConfig()
		}()
		if tab == "default" {
			var sys models.Sys
			this.ParseForm(&sys)
			_, err := orm.NewOrm().Update(&sys)
			if err != nil {
				helper.Logger.Error(err.Error())
				this.ResponseJson(false, err.Error())
			}
			this.ResponseJson(true, "更新成功")
		}

		var cfg interface{}
		cfg, err = models.NewConfig().ParseForm(tab, this.Ctx.Request.Form)
		if cfg != ni
    
func (this *SysController) Get() {
	tab := helper.ConfigCate(strings.ToLower(this.GetString("tab")))
	var err error
	switch tab {
	case models.ConfigCateEmail, models.ConfigCateDepend, models.ConfigCateElasticSearch, models.ConfigCateLog:
	default:
		tab = "default"
	}
	if this.Ctx.Request.Method == http.MethodPost {
		defer func() {
			models.NewSys().UpdateGlobalConfig()
			models.NewConfig().UpdateGlobalConfig()
		}()
		if tab == "default" {
			var sys models.Sys
			this.ParseForm(&sys)
			_, err := orm.NewOrm().Update(&sys)
			if err != nil {
				helper.Logger.Error(err.Error())
				this.ResponseJson(false, err.Error())
			}
			this.ResponseJson(true, "更新成功")
		}

		var cfg interface{}
		cfg, err = models.NewConfig().ParseForm(tab, this.Ctx.Request.Form)
		if cfg != nil {
			switch tab {
			case models.ConfigCateEmail:
				if err != nil {
					this.ResponseJson(false, err.Error())
				}
				modelEmail := cfg.(*models.ConfigEmail)
				err = modelEmail.SendMail(modelEmail.TestUserEmail, "测试邮件", "这是一封测试邮件，用于检测是否能正常发送邮件")
			case models.ConfigCateElasticSearch:
				modelES := cfg.(*models.ElasticSearchClient)
				if modelES.On {
					modelES.Host = strings.TrimRight(modelES.Host, "/") + "/"
					modelES.Type = "fulltext"
					modelES.Timeout = 5 * time.Second
					err = modelES.Init()
				}
			}
		}
		if err != nil {
			this.ResponseJson(false, err.Error(), cfg)
		}

		o := orm.NewOrm()
		o.Begin()
		defer func() {
			if err != nil {
				o.Rollback()
			} else {
				o.Commit()
			}
		}()

		for k, v := range this.Ctx.Request.Form {
			if _, err = o.QueryTable(models.GetTableConfig()).Filter("Category", tab).Filter("Key", k).Update(orm.Params{"Value": v[0]}); err != nil {
				helper.Logger.Error(err.Error())
				this.ResponseJson(false, "ElasticSearch初始化失败："+err.Error())
			}
		}

		this.ResponseJson(true, "更新成功")
	}

	this.Data["Tab"] = tab
	this.Data["Title"] = "系统管理"
	this.Data["IsSys"] = true
	this.Data["Store"] = this.GetString("store", string(models.StoreOss))
	if tab == "default" {
		this.Data["Sys"], _ = models.NewSys().Get()
	} else {
		this.Data["Configs"] = models.NewConfig().All()
		if tab == models.ConfigCateElasticSearch {
			count, errES := models.NewElasticSearchClient().Count()
			this.Data["Count"] = count
			if errES != nil {
				this.Data["ErrES"] = errES.Error()
			}
		} else if tab == "logs" {
			var logs []logFile
			if files, _ := ioutil.ReadDir("logs"); len(files) > 0 {
				for _, file := range files {
					if !file.IsDir() {
						logs = append(logs, logFile{
							Path:    "logs/" + file.Name(),
							ModTime: file.ModTime(),
							Size:    int(file.Size()),
						})
					}
				}
			}
			this.Data["Logs"] = logs
		}
	}
	this.TplName = "index.html"
}