本文整理汇总了Golang中github.com/astaxie/beego.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetMediaList
// Get the media list
func (this *PmpMediaController) GetMediaList() {
params := "fields:" + this.GetString("fields") + " ******* page: " + this.GetString("page") + " ****** rows:" + this.GetString("rows") + " **** sort:" +
this.GetString("sort") + " ****** order:" + this.GetString("order") + " ****** name: " + this.GetString("name")
beego.Info(params)
name := this.GetString("name")
page, _ := this.GetInt64("page")
page_size, _ := this.GetInt64("rows")
sort := this.GetString("sort")
order := this.GetString("order")
if len(order) > 0 {
if order == "desc" {
sort = " " + sort
}
} else {
sort = "Id"
}
medias, count := models.GetMediaList(page, page_size, sort, name)
if this.IsAjax() {
this.Data["json"] = &map[string]interface{}{"total": count, "rows": &medias}
jsoncontent, _ := json.Marshal(this.Data["json"])
beego.Info("*********************" + string(jsoncontent) + "******************")
this.ServeJson()
return
} else {
//this.Data["json"] = &medias
if this.GetTemplatetype() != "easyui" {
this.Layout = this.GetTemplatetype() + "/public/layout.tpl"
}
this.TplNames = this.GetTemplatetype() + "/adspace/mediamanage.tpl"
}
}
开发者ID:wfnuser,项目名称:o2oadmin,代码行数:33,代码来源:pmp_media.go
示例2: UpdateDailyAllocation
func (this *PmpDemandPlatformDeskController) UpdateDailyAllocation() {
u := DemandVo{Day1: -1, Day2: -1, Day3: -1, Day4: -1, Day5: -1, Day6: -1, Day7: -1}
if err := this.ParseForm(&u); err != nil {
//handle error
this.Rsp(false, err.Error())
return
}
const layout = "2006-1-2"
startdate, _ := time.Parse(layout, u.Operation)
startdate = startdate.Local()
var imps []int
imps = append(imps, u.Day1)
imps = append(imps, u.Day2)
imps = append(imps, u.Day3)
imps = append(imps, u.Day4)
imps = append(imps, u.Day5)
imps = append(imps, u.Day6)
imps = append(imps, u.Day7)
var datestrs []string
for i := 0; i < 7; i++ {
tempdate := startdate.AddDate(0, 0, i)
datestrs = append(datestrs, tempdate.Format(layout))
}
beego.Info(" **** datestrs:", datestrs, " DemandAdspaceId: ", u.DemandAdspaceId, " imps: ", imps)
num, err := models.UpdateImpByDemandAdpaceIdAndAdDate(u.DemandAdspaceId, u.Proportion, datestrs, imps)
if err == nil {
beego.Info(" **** Number of rows updated: ", num)
this.Rsp(true, "Success")
return
} else {
this.Rsp(false, err.Error())
return
}
}
开发者ID:wfnuser,项目名称:o2oadmin,代码行数:35,代码来源:pmp_demand_platform_desk.go
示例3: Post
func (this *LoginController) Post() {
//get form info
uname := this.Input().Get("uname")
pwd := this.Input().Get("pwd")
admin := models.Admininfo{
Username: uname,
Password: pwd,
}
//check username and password
ok := models.CheckAdmin(&admin)
if ok {
beego.Info("user/pwd matched!")
this.SetSession("Admin", uname)
if models.UpdateAdminStatus(&admin) {
beego.Info("UpdateAdminStatus success!")
} else {
beego.Info("UpdateAdminStatus failed!")
}
beego.Info("Login success!")
this.Data["IsMatched"] = true
this.Redirect("/home", 301)
return
}
beego.Info("Login failed! Once again!")
this.Data["IsMatched"] = false
this.Redirect("/login", 302)
return
}
开发者ID:tcdog001,项目名称:szm_lss,代码行数:34,代码来源:login.go
示例4: Reg
func (this *UserController) Reg() {
beego.Info("register controller")
result := make(map[string]interface{})
result["succ"] = "succ"
email := this.GetString("email")
pwd := this.GetString("pwd")
beego.Info(email)
beego.Info(pwd)
u := new(models.User)
u.Email = email
u.Pwd = helper.MD5(pwd)
u.Reged = time.Now()
u.Uname = email
id, err := models.SaveUser(u)
if err != nil {
beego.Error(err)
result["succ"] = "err"
} else {
result["id"] = u.Pwd
result["email"] = email
}
this.SetSession("online_user", "u_"+strconv.FormatInt(id, 10))
this.SetSession("online_user_email", email)
this.Data["json"] = result
this.ServeJson()
}
开发者ID:javajian,项目名称:blog,代码行数:32,代码来源:userController.go
示例5: PagSql
//realiza una consulta en la base y devuelve el numero de filas
//para las paginaciones
func PagSql(tbl, pi, regxp string) (int, []orm.Params) {
o := orm.NewOrm()
o.Using("default")
var maps []orm.Params
var num int
if tbl == "proveedor" {
_, err := o.Raw(`SELECT SQL_CALC_FOUND_ROWS *
FROM proveedor LIMIT ` + pi + `,` + regxp).Values(&maps)
o.Raw(`SELECT FOUND_ROWS()`).QueryRow(&num)
if err != nil {
beego.Info(err)
}
} else if tbl == "articulos" {
//usamos una consulta join para poner datos en pagina
_, err := o.Raw(`SELECT articulos.id,articulos.id_proveedor,
articulos.ref_propia,articulos.descripcion,categoria.categoria
FROM articulos JOIN categoria WHERE articulos.id_categoria=
categoria.id ORDER BY articulos.id LIMIT ` + pi + `,` + regxp).Values(&maps)
o.Raw(`SELECT FOUND_ROWS()`).QueryRow(&num)
if err != nil {
beego.Info(err)
}
}
return num, maps
}
开发者ID:carlosjml4,项目名称:artyprovee,代码行数:28,代码来源:util.go
示例6: Post
func (this *ImportController) Post() {
//check islogin
session := this.GetSession("Admin")
if session == nil {
beego.Trace("session verify failed!")
this.Redirect("/", 302)
return
}
saveFileName := "temp" + strconv.FormatInt(int64(time.Now().UnixNano()), 10) + ".xlsx"
beego.Debug("saveFileName=", saveFileName)
this.SaveToFile("file", saveFileName)
devices := make([]models.Deviceinfo, 0)
xlFile, err := xlsx.OpenFile(saveFileName)
if err != nil {
beego.Error("Open excel file!", err)
}
for _, sheet := range xlFile.Sheets {
for _, row := range sheet.Rows {
for _, cell := range row.Cells {
device := models.Deviceinfo{
Mac: cell.String(),
ImportTime: time.Now(),
InvalidTime: time.Now().Add(3 * 30 * 24 * time.Hour),
}
//check mac address format
if !CheckMacFormat(device.Mac) {
beego.Info(device.Mac, "not a mac address!")
continue
}
//if the mac address had existed,skip it
if models.ImportDeviceCheck(&device) {
beego.Info(device.Mac, "had been imported!")
continue
}
devices = append(devices, device)
}
}
}
//delete used file
err = os.Remove(saveFileName)
if err != nil {
beego.Error("Remove temp excel file failed!", err)
}
ok := models.ImportDevices(&devices)
if ok {
beego.Info("ImportDevices success!")
this.Redirect("/home", 301)
this.Data["IsImported"] = true
return
} else {
beego.Info("ImportDevices failed! once again")
this.Redirect("/import", 302)
return
}
}
开发者ID:tcdog001,项目名称:szm_lss,代码行数:60,代码来源:import.go
示例7: http_call
func http_call(req *http.Request, v interface{}) (bool, error) {
if req.Method == "POST" {
if req.Header.Get("Content-Type") == "" {
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
}
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
beego.Info("fetch url %s %s", req.RequestURI, err)
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
d := json.NewDecoder(resp.Body)
err = d.Decode(&v)
if err != nil {
panic(err)
}
return true, err
} else {
bytes, _ := ioutil.ReadAll(resp.Body)
beego.Info("Weibo API Error: " + string(bytes))
var e WeiboError
err = json.Unmarshal(bytes, &e)
if err != nil {
panic(err)
}
return false, e
}
return false, err
}
开发者ID:starchou,项目名称:workspace,代码行数:34,代码来源:weibo.go
示例8: init
func init() {
//读取配置文件
getConfig()
//初始化postgres数据库
DbConn()
if Orm.Ping() != nil {
beego.Error("业务数据库连接不正常")
} else {
beego.Info("业务数据库连接正常")
}
if WorldOrm.Ping() != nil {
beego.Error("用户中心数据库连接不正常")
} else {
beego.Info("用户中心数据库连接正常")
}
//创建表
Orm.CreateTables(new(GameUser))
//用户中心数据库控制表
WorldOrm.CreateTables(new(UserControl), new(BizConfig), new(ErrorCode))
WorldOrm.CreateTables(new(SystemConfig), new(ServList))
InitSession = Orm.NewSession()
err := InitSession.Begin()
if err != nil {
beego.Error("开启事务失败")
}
beego.Info("ORM 初始化成功!")
}
开发者ID:sunvim,项目名称:codelab,代码行数:28,代码来源:models.go
示例9: ApplyServList
//申请服务器列表
func (this *BusiData) ApplyServList() {
beego.Info("ApplyServList ==> begin")
worldSession := models.WorldOrm.NewSession()
defer worldSession.Close()
err := worldSession.Begin()
if err != nil {
beego.Error("开启事务失败:=>", err)
}
defer worldSession.Commit()
var servList []models.ServList
err = worldSession.Where("status='0' and serv_type='online'").Find(&servList)
if err != nil {
beego.Error("获取服务器列表失败=>", err)
this.Response.Set("retCode", ERR_QUERY)
return
}
busiInfo := gjson.New()
var srvList []*gjson.Json
for _, v := range servList {
tempNode := gjson.New()
tempNode.Set("servAddr", v.ServAddr)
tempNode.Set("servPort", v.ServPort)
tempNode.Set("servIndex", v.ServIndex)
tempNode.Set("servDesc", v.ServDesc)
srvList = append(srvList, tempNode)
}
busiInfo.Set("servList", srvList)
this.Response.Set("busiInfo", busiInfo)
this.Response.Set("retCode", RET_SUCC)
beego.Info("ApplyServList ==> end")
return
}
开发者ID:sunvim,项目名称:codelab,代码行数:33,代码来源:busiPool.go
示例10: main
func main() {
setting.Initialize()
beego.SetLogFuncCall(true)
beego.SetViewsPath("views")
if setting.IsProMode {
beego.Info(setting.PostgresMigrateConnection)
//auto migrate db
//todo: we may want to disable this later
//dbMigrate()
} else {
beego.Info("Develment mode enabled")
}
dbMigrate()
beego.Info(beego.BConfig.AppName, setting.APP_VER, setting.AppUrl)
testOnly() //todo:remove this
//dev directory listing
if !setting.IsProMode {
beego.SetStaticPath("/assets", "static/dist/assets")
beego.BConfig.WebConfig.DirectoryIndex = true
}
orm.RegisterDriver("postgres", orm.DRPostgres)
orm.RegisterDataBase("default", "postgres", setting.PostgresConnection)
services.Register()
orm.RunCommand()
orm.Debug = true
controllers.RegisterControllers()
if beego.BConfig.RunMode == "dev" {
// beego.Router("/test/:tmpl(mail/.*)", new(base.TestRouter))
}
beego.Run()
}
开发者ID:thanzen,项目名称:identity,代码行数:35,代码来源:main.go
示例11: GetPostHttpRequestData
/**
* 获取http请求结果,只支持post,返回结构自定义
* url:请求地址
* params:post参数
* data:返回数据
*/
func GetPostHttpRequestData(url string, params map[string]string, respData interface{}) (err error) {
defer func() {
if x := recover(); x != nil {
errStr := fmt.Sprintf("get post fail: params-%v , err-%v", params, x)
err = errors.New(errStr)
}
}()
begin := time.Now().UnixNano()
req := httplib.Post(url).SetTimeout(CONNECT_TIME_OUT, READ_WRITE_TIME_OUT).Header("Content-Type", "application/x-www-form-urlencoded")
beego.Info("Request url:", url, params)
if params != nil && len(params) > 0 {
for key, value := range params {
req.Param(key, value)
}
}
err = req.ToJson(respData)
if err != nil {
return
}
end := time.Now().UnixNano()
beego.Info("Http response:", respData, ", cost:", end-begin)
return
}
开发者ID:NotBadPad,项目名称:go-learn,代码行数:31,代码来源:httpHelper.go
示例12: AddDGMessage
///添加讨论组消息
func AddDGMessage(dg_msg message.DGMessage) int {
client := &Client{}
url := Config_Data_URL //"http://10.1.9.102/fbddc/api/api.php"
json, _ := json.Marshal(dg_msg)
beego.Info("web req is ", string(json))
b := strings.NewReader(string(json))
req, err := NewRequest("POST", url, b)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("UU-REQUEST-MODULE", "messaging")
req.Header.Add("UU-REQUEST-ACTION", "add_discussion_messages")
req.Header.Add("UU-AUTH-TYPE", "2")
if err != nil {
//return nil
fmt.Println(err)
}
response, err := client.Do(req)
if err != nil {
beego.Info("add_dgmsg error", err)
return 500
}
beego.Info("web response is ", response)
status := response.Header.Get("UU-Response-RC")
if response.StatusCode == 200 && status == "0" {
return 200
}
return 500
}
开发者ID:ilahsa,项目名称:go,代码行数:34,代码来源:web_client.go
示例13: StopInterval
func (c *Collector) StopInterval(app *models.MonitorApp) {
beego.Info("StopInterval invoke start" + strconv.Itoa(app.Id))
if err := gm.StopLoopGoroutine(strconv.Itoa(app.Id)); err != nil {
beego.Error(err)
}
beego.Info("StopInterval invoke end")
}
开发者ID:souche-open,项目名称:smoni,代码行数:7,代码来源:appsCollector.go
示例14: Post
func (this *AttachController) Post() {
var (
attachment string
fileExist string
)
// 获取文件名
_, fh, err := this.GetFile("updatePack")
if err != nil {
beego.Error(err)
}
if fh != nil {
//验证文件是否已存在
attachment = fh.Filename
fileExist = path.Join("updatePack", attachment)
beego.Info("filePath: ", fileExist)
if _, err = os.Stat(fileExist); err == nil {
this.Ctx.Output.Body([]byte("文件已存在"))
beego.Info("上传文件已存在")
return
}
// 保存文件
err = this.SaveToFile("updatePack", fileExist)
if err != nil {
beego.Error(err)
}
}
this.Ctx.Output.Body([]byte("OK"))
//解压缩并生成更新列表
go UnzipUpdatePack(attachment)
return
}
开发者ID:sunvim,项目名称:codelab,代码行数:31,代码来源:attch.go
示例15: Post
func (this *HeartBeatController) Post() {
ret := HeartData{}
//用户认证
uname, pwd, ok := this.Ctx.Request.BasicAuth()
if !ok {
beego.Info("get client Request.BasicAuth failed!")
ret.Code = -1
writeContent, _ := json.Marshal(ret)
this.Ctx.WriteString(string(writeContent))
return
}
user := models.Userinfo{
Username: uname,
Password: pwd,
}
ok = models.CheckAccount(&user)
if !ok {
beego.Info("user/pwd not matched!")
ret.Code = -1
writeContent, _ := json.Marshal(ret)
this.Ctx.WriteString(string(writeContent))
return
}
beego.Info("user/pwd matched!")
//接收请求信息
beego.Debug("requestBody=", string(this.Ctx.Input.RequestBody))
deviceinfo := models.Deviceinfo{}
err := json.Unmarshal(this.Ctx.Input.RequestBody, &deviceinfo)
beego.Debug("deviceinfo=", deviceinfo)
if err != nil {
beego.Error(err)
ret.Code = -2
writeContent, _ := json.Marshal(ret)
this.Ctx.WriteString(string(writeContent))
return
}
//心跳接收成功,更新设备状态
deviceinfo.State = 1
deviceinfo.LastKeepaliveTime = time.Now()
if !models.UpdateDeviceStatus(&deviceinfo) {
ret.Code = -2
writeContent, _ := json.Marshal(ret)
this.Ctx.WriteString(string(writeContent))
return
}
//插入Listener中
device := DeviceListener{
State: 1,
LastAliveTime: time.Now(),
}
Listener[deviceinfo.Mac] = device
//返回给设备处理结果
ret.Code = 0
writeContent, _ := json.Marshal(ret)
this.Ctx.WriteString(string(writeContent))
}
开发者ID:tcdog001,项目名称:LMS,代码行数:60,代码来源:heartbeat.go
示例16: Delete
/**
* Delete the user, by their id, if that user's available.
*/
func (manage *ManageController) Delete() {
manage.Layout = "basic-layout.tpl"
manage.LayoutSections = make(map[string]string)
manage.LayoutSections["Header"] = "header.tpl"
manage.LayoutSections["Footer"] = "footer.tpl"
manage.TplNames = "manage/home.tpl"
// convert the string value to an int
articleId, _ := strconv.Atoi(manage.Ctx.Input.Param(":id"))
o := orm.NewOrm()
o.Using("default")
article := models.Article{}
// Check if the article exists first
if exist := o.QueryTable(article.TableName()).Filter("Id", articleId).Exist(); exist {
if num, err := o.Delete(&models.Article{Id: articleId}); err == nil {
beego.Info("Record Deleted. ", num)
} else {
beego.Error("Record couldn't be deleted. Reason: ", err)
}
} else {
beego.Info("Record Doesn't exist.")
}
}
开发者ID:dw250100785,项目名称:Learning-Beego,代码行数:29,代码来源:manage.go
示例17: Post
func (this *MainController) Post() {
body, err := ioutil.ReadAll(this.Ctx.Request.Body)
if err != nil {
beego.Error(err)
this.Ctx.ResponseWriter.WriteHeader(500)
return
}
beego.Info(string(body))
var wreq *Request
if wreq, err = DecodeRequest(body); err != nil {
beego.Error(err)
this.Ctx.ResponseWriter.WriteHeader(500)
return
}
beego.Info(wreq.Content)
wresp, err := dealwith(wreq)
if err != nil {
beego.Error(err)
this.Ctx.ResponseWriter.WriteHeader(500)
return
}
data, err := wresp.Encode()
if err != nil {
beego.Error(err)
this.Ctx.ResponseWriter.WriteHeader(500)
return
}
this.Ctx.WriteString(string(data))
return
}
开发者ID:qinglong1983,项目名称:weixin,代码行数:30,代码来源:default.go
示例18: FileAdd
func (this *TopicController) FileAdd() {
this.Ctx.Request.ParseMultipartForm(32 << 20)
file, _, err := this.Ctx.Request.FormFile("file")
if err != nil {
beego.Error("[上传文件错误]" + err.Error())
}
defer file.Close()
datas, err := ioutil.ReadAll(file)
fmt.Println("fmt", datas)
if err != nil {
beego.Error("[读取文件错误]" + err.Error())
}
beego.Info(string(datas) + "[datas]")
a := string(datas)
result := string(blackfriday.MarkdownBasic(datas))
result = strings.Replace(result, "<code>", "<code class=\"go\">", -1)
// this.Ctx.WriteString(string(datas)) 为什么这里不输出
beego.Info(a)
this.Data["json"] = result
this.ServeJson()
}
开发者ID:xmvper,项目名称:golang-blog,代码行数:25,代码来源:topic.go
示例19: Reset
// Reset reset all migration
// run all migration's down function
func Reset() error {
sm := sortMap(migrationMap)
i := 0
for j := len(sm) - 1; j >= 0; j-- {
v := sm[j]
if isRollBack(v.name) {
beego.Info("skip the", v.name)
time.Sleep(1 * time.Second)
continue
}
beego.Info("start reset:", v.name)
v.m.Reset()
v.m.Down()
err := v.m.Exec(v.name, "down")
if err != nil {
beego.Error("execute error:", err)
time.Sleep(2 * time.Second)
return err
}
i++
beego.Info("end reset:", v.name)
}
beego.Info("total success reset:", i, " migration")
time.Sleep(2 * time.Second)
return nil
}
开发者ID:ngaut,项目名称:beego,代码行数:28,代码来源:migration.go
示例20: Post
func (this *LoginController) Post() {
//获取表单内容
uname := this.Input().Get("uname")
pwd := this.Input().Get("pwd")
admin := models.Admininfo{
Username: uname,
Password: pwd,
}
//在数据库中做匹配
ok := models.CheckAdmin(&admin)
if ok {
beego.Info("user/pwd matched!")
this.SetSession("Admin", uname)
if models.UpdateAdminStatus(&admin) {
beego.Info("UpdateAdminStatus success!")
} else {
beego.Info("UpdateAdminStatus failed!")
}
beego.Info("Login success!")
//登录成功,重定向到主页面
this.Data["IsMatched"] = true
path := "/home?CurUser=" + uname
this.Redirect(path, 301)
return
}
//登录失败,重定向到登录页面
beego.Info("Login failed! Once again!")
this.Data["IsMatched"] = false
this.Redirect("/login/?ShowError=true", 302)
return
}
开发者ID:tcdog001,项目名称:szm_lms,代码行数:35,代码来源:login.go
注:本文中的github.com/astaxie/beego.Info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论