func NewExporteFile(ep Exporter) *ExporteFile { return &ExporteFile{ Exporter: ep, filename: Getfilename(), fullpath: utils.GetConf().String("upload::root") + utils.GetConf().String("upload::export"), } }
func connectDB() { orm.RegisterDriver("mysql", orm.DR_MySQL) name := utils.GetConf().String("db::name") user := utils.GetConf().String("db::user") pass := utils.GetConf().String("db::pass") host := utils.GetConf().String("db::host") port := utils.GetConf().String("db::port") //data source name // dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", user, pass, host, port, name) dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&loc=Local", user, pass, host, port, name) orm.RegisterDataBase("default", "mysql", dsn) orm.RegisterModel(new(User), new(Project), new(ProjectLog)) orm.RegisterModel(new(Company), new(Job), new(Progress)) orm.RegisterModel(new(File), new(JobComplaint), new(JobProgress)) orm.RegisterModel(new(JobValid), new(JobClaim), new(JobSubmit)) orm.RegisterModel(new(UserLogin), new(JobAssign)) orm.RegisterModel(new(JobHistory), new(JobComplaintReply)) orm.RegisterModel(new(Require)) db = orm.NewOrm() setMaxIdleConns() }
func initStatic() error { uploadPath := utils.GetConf().String("upload::root") err := utils.EnsurePath(uploadPath) if err != nil { return err } jobPath := uploadPath + utils.GetConf().String("upload::job") err = utils.EnsurePath(jobPath) if err != nil { return err } exportPath := uploadPath + utils.GetConf().String("upload::export") err = utils.EnsurePath(exportPath) if err != nil { return err } beego.DirectoryIndex = true beego.StaticDir["/public"] = "public/" beego.SetStaticPath("/img", "public/img") beego.SetStaticPath("/export", exportPath) beego.SetStaticPath("/"+controllers.StaticPathPhoto, uploadPath) return nil }
func NewUploadFile(request *http.Request, formName, confKey string) *UploadFile { return &UploadFile{ request: request, formName: formName, savePath: utils.GetConf().String("upload::root") + utils.GetConf().String("upload::"+confKey), url: path.Join(StaticPathPhoto, utils.GetConf().String("upload::"+confKey)), } }
func NewProjectExport() *ProjectExport { return &ProjectExport{ filename: GetFileName(), fullpath: utils.GetConf().String("upload::root") + utils.GetConf().String("upload::export"), } }
func (e *Email) IsEnable() bool { isEnable, _ := utils.GetConf().Bool("email::enable") return isEnable }
func getParams() { apiUser = utils.GetConf().String("email::api_user") apiKey = utils.GetConf().String("email::api_key") from = utils.GetConf().String("email::from") sendEmailByTempUrl = utils.GetConf().String("email::email_tmp_url") }
func setMaxIdleConns() { maxIdleConns, _ := utils.GetConf().Int("db::max_idle_conns") orm.SetMaxIdleConns("default", maxIdleConns) }
func initHTTP() { beego.HttpPort, _ = utils.GetConf().Int("app::httpport") beego.CopyRequestBody, _ = utils.GetConf().Bool("app:copyrequestbody") }