當前位置: 首頁>>代碼示例>>Golang>>正文


Golang info.NewRe函數代碼示例

本文整理匯總了Golang中github.com/nosqldb/zhujian/app/info.NewRe函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewRe函數的具體用法?Golang NewRe怎麽用?Golang NewRe使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewRe函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ListCateLatest

// 顯示分類的最近博客, jsonp
func (c Blog) ListCateLatest(notebookId, callback string) revel.Result {
	if notebookId == "" {
		return c.e404("")
	}
	// 自定義域名
	hasDomain, userBlog := c.domain()
	userId := ""
	if hasDomain {
		userId = userBlog.UserId.Hex()
	}

	var notebook info.Notebook
	notebook = notebookService.GetNotebookById(notebookId)
	if !notebook.IsBlog {
		return c.e404(userBlog.ThemePath)
	}
	if userId != "" && userId != notebook.UserId.Hex() {
		return c.e404(userBlog.ThemePath)
	}
	userId = notebook.UserId.Hex()

	var ok = false
	if ok, userBlog = c.blogCommon(userId, userBlog, info.User{}); !ok {
		return c.e404(userBlog.ThemePath)
	}

	// 分頁的話, 需要分頁信息, totalPage, curPage
	page := 1
	_, blogs := blogService.ListUserBlogs(userId, notebookId, page, 5, userBlog.SortField, userBlog.IsAsc)
	re := info.NewRe()
	re.Ok = true
	re.List = blogs
	return c.RenderJsonP(callback, re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:35,代碼來源:BlogController.go

示例2: CopyHttpImage

// 複製外網的圖片, 成公共圖片 放在/upload下
// 都要好好的計算大小
func (c File) CopyHttpImage(src string) revel.Result {
	re := info.NewRe()
	fileUrlPath := "upload/" + c.GetUserId() + "/images"
	dir := revel.BasePath + "/public/" + fileUrlPath
	err := os.MkdirAll(dir, 0755)
	if err != nil {
		return c.RenderJson(re)
	}
	filesize, filename, _, ok := netutil.WriteUrl(src, dir)

	if !ok {
		re.Msg = "copy error"
		return c.RenderJson(re)
	}

	// File
	fileInfo := info.File{Name: filename,
		Title: filename,
		Path:  fileUrlPath + "/" + filename,
		Size:  filesize}

	id := bson.NewObjectId()
	fileInfo.FileId = id

	re.Id = id.Hex()
	re.Item = fileInfo.Path
	re.Ok, re.Msg = fileService.AddImage(fileInfo, "", c.GetUserId(), true)

	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:32,代碼來源:FileController.go

示例3: GetTplContent

// 得到文件內容
func (c MemberBlog) GetTplContent(themeId string, filename string) revel.Result {
	re := info.NewRe()
	re.Ok = true
	re.Item = themeService.GetTplContent(c.GetUserId(), themeId, filename)

	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:8,代碼來源:MemberBlogController.go

示例4: LikeComment

// jsonp
func (c Blog) LikeComment(commentId string, callback string) revel.Result {
	re := info.NewRe()
	ok, isILikeIt, num := blogService.LikeComment(commentId, c.GetUserId())
	re.Ok = ok
	re.Item = bson.M{"IsILikeIt": isILikeIt, "Num": num}
	return c.RenderJsonP(callback, re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:8,代碼來源:BlogController.go

示例5: AuthInterceptor

func AuthInterceptor(c *revel.Controller) revel.Result {
	// 全部變成首字大寫
	/*
		var controller = strings.Title(c.Name)
		var method = strings.Title(c.MethodName)
		// 是否需要驗證?
		if !needValidate(controller, method) {
			return nil
		}
	*/

	// 驗證是否已登錄
	// 必須是管理員
	if username, ok := c.Session["Username"]; ok && username == configService.GetAdminUsername() {
		return nil // 已登錄
	}

	// 沒有登錄, 判斷是否是ajax操作
	if c.Request.Header.Get("X-Requested-With") == "XMLHttpRequest" {
		re := info.NewRe()
		re.Msg = "NOTLOGIN"
		return c.RenderJson(re)
	}

	return c.Redirect("/login")
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:26,代碼來源:init.go

示例6: GetLikesAndComments

func (c Blog) GetLikesAndComments(noteId, callback string) revel.Result {
	userId := c.GetUserId()
	result := map[string]interface{}{}

	// 我也點過?
	isILikeIt := false
	if userId != "" {
		isILikeIt = blogService.IsILikeIt(noteId, userId)
		result["visitUserInfo"] = userService.GetUserAndBlog(userId)
	}

	// 點讚用戶列表
	likedUsers, hasMoreLikedUser := blogService.ListLikedUsers(noteId, false)
	// 評論
	page := c.GetPage()
	pageInfo, comments, commentUserInfo := blogService.ListComments(userId, noteId, page, 15)

	re := info.NewRe()
	re.Ok = true
	result["isILikeIt"] = isILikeIt
	result["likedUsers"] = likedUsers
	result["hasMoreLikedUser"] = hasMoreLikedUser
	result["pageInfo"] = pageInfo
	result["comments"] = comments
	result["commentUserInfo"] = commentUserInfo
	re.Item = result
	return c.RenderJsonP(callback, re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:28,代碼來源:BlogController.go

示例7: GetPostStat

// 得到博客統計信息
func (c Blog) GetPostStat(noteId string) revel.Result {
	re := info.NewRe()
	re.Ok = true
	statInfo := blogService.GetBlogStat(noteId)
	re.Item = statInfo
	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:8,代碼來源:BlogController.go

示例8: DoResetPwd

func (c AdminUser) DoResetPwd(userId, pwd string) revel.Result {
	re := info.NewRe()
	if re.Ok, re.Msg = Vd("password", pwd); !re.Ok {
		return c.RenderRe(re)
	}
	re.Ok, re.Msg = userService.ResetPwd(c.GetUserId(), userId, pwd)
	return c.RenderRe(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:8,代碼來源:AdminUserController.go

示例9: UpdateTheme

// 更新主題
func (c User) UpdateTheme(theme string) revel.Result {
	re := info.NewRe()
	re.Ok = userService.UpdateTheme(c.GetUserId(), theme)
	if re.Ok {
		c.UpdateSession("Theme", theme)
	}
	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:9,代碼來源:UserController.go

示例10: SendRegisterEmail

// 發送邀請鏈接
func (c User) SendRegisterEmail(content, toEmail string) revel.Result {
	re := info.NewRe()
	if content == "" || !IsEmail(toEmail) {
		return c.RenderJson(re)
	}

	re.Ok = emailService.SendInviteEmail(c.GetUserInfo(), toEmail, content)
	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:10,代碼來源:UserController.go

示例11: ListThemeImages

func (c MemberBlog) ListThemeImages(themeId string) revel.Result {
	re := info.NewRe()
	userId := c.GetUserId()
	path := themeService.GetThemeAbsolutePath(userId, themeId) + "/images"
	os.MkdirAll(path, 0755)
	images := ListDir(path)
	re.List = images
	re.Ok = true
	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:10,代碼來源:MemberBlogController.go

示例12: FindPasswordUpdate

// 找回密碼修改密碼
func (c Auth) FindPasswordUpdate(token, pwd string) revel.Result {
	re := info.NewRe()

	if re.Ok, re.Msg = Vd("password", pwd); !re.Ok {
		return c.RenderRe(re)
	}

	// 修改之
	re.Ok, re.Msg = pwdService.UpdatePwd(token, pwd)
	return c.RenderRe(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:12,代碼來源:AuthController.go

示例13: AddUser

// 添加用戶
func (c MemberGroup) AddUser(groupId, email string) revel.Result {
	re := info.NewRe()
	userInfo := userService.GetUserInfoByAny(email)
	if userInfo.UserId == "" {
		re.Msg = "userNotExists"
	} else {
		re.Ok, re.Msg = groupService.AddUser(c.GetUserId(), groupId, userInfo.UserId.Hex())
		re.Item = userInfo
	}
	return c.RenderRe(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:12,代碼來源:MemberGroupController.go

示例14: Suggestion

// 建議
func (c Index) Suggestion(addr, suggestion string) revel.Result {
	re := info.NewRe()
	re.Ok = suggestionService.AddSuggestion(info.Suggestion{Addr: addr, UserId: c.GetObjectUserId(), Suggestion: suggestion})

	// 發給我
	go func() {
		emailService.SendEmail("[email protected]", "建議", "UserId: "+c.GetUserId()+" <br /> Suggestions: "+suggestion)
	}()

	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:12,代碼來源:IndexController.go

示例15: UpdateColumnWidth

//-----------------
// 用戶偏愛
func (c User) UpdateColumnWidth(notebookWidth, noteListWidth, mdEditorWidth int) revel.Result {
	re := info.NewRe()
	re.Ok = userService.UpdateColumnWidth(c.GetUserId(), notebookWidth, noteListWidth, mdEditorWidth)
	if re.Ok {
		c.UpdateSession("NotebookWidth", strconv.Itoa(notebookWidth))
		c.UpdateSession("NoteListWidth", strconv.Itoa(noteListWidth))
		c.UpdateSession("MdEditorWidth", strconv.Itoa(mdEditorWidth))

		LogJ(c.Session)
	}
	return c.RenderJson(re)
}
開發者ID:nosqldb,項目名稱:zhujian,代碼行數:14,代碼來源:UserController.go


注:本文中的github.com/nosqldb/zhujian/app/info.NewRe函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。