本文整理汇总了Golang中github.com/astaxie/beego.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"
}
}
示例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
}
}
示例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
}
示例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()
}
示例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
}
示例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
}
}
示例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
}
示例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 初始化成功!")
}
示例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
}
示例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()
}
示例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
}
示例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
}
示例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")
}
示例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
}
示例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))
}