logic

package
v0.0.0-...-2ae2b33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2023 License: BSD-3-Clause Imports: 63 Imported by: 0

Documentation

Overview

解析 http://www.reddit.com/r/golang 最新 Go 信息

Index

Constants

View Source
const (
	WsMsgNotify = iota // 通知消息
	WsMsgOnline        // 发送在线用户数(和需要时也发历史最高)
)
View Source
const CommentPerNum = 50
View Source
const GiteaAPIBaseUrl = "https://gitea.com/api/v1"
View Source
const GithubAPIBaseUrl = "https://api.github.com"
View Source
const (
	MaxImageSize = 5 << 20 // 5M
)
View Source
const MessageQueueLen = 3
View Source
const OsChinaDomain = "https://www.oschina.net"
View Source
const PerPage = 50

每页显示多少条

View Source
const ProjectLogoPrefix = "plogo"

ProjectLogoPrefix 开源项目 logo 前缀

Variables

View Source
var (
	NotModifyAuthorityErr = errors.New("没有修改权限")
	NotFoundErr           = errors.New("Not Found")
)
View Source
var (
	Authorities []*model.Authority

	RoleAuthorities map[int][]int

	Roles []*model.Role // 相应的 roleid-1 为索引

	// 节点信息
	AllNode []map[string]interface{}
	// 推荐节点
	AllRecommendNodes []map[string][]map[string]interface{}

	// 资源分类
	AllCategory []*model.ResourceCat

	WebsiteSetting = model.WebsiteSetting

	DefaultAvatars []string

	UserSetting map[string]int
)
View Source
var (
	ErrUsername = errors.New("用户名不存在")
	ErrPasswd   = errors.New("密码错误")
)
View Source
var Book = &book{users: make(map[int]*UserData), uids: make(map[int]struct{})}

TODO: 多机器部署,广播、在线注册用户信息没有同步

View Source
var DefaultAd = AdLogic{}
View Source
var DefaultArticle = ArticleLogic{}
View Source
var DefaultAuthority = AuthorityLogic{}
View Source
var DefaultAutoCrawl = AutoCrawlLogic{}
View Source
var DefaultComment = CommentLogic{}
View Source
var DefaultDownload = DownloadLogic{}
View Source
var DefaultDynamic = DynamicLogic{}
View Source
var DefaultEmail = EmailLogic{}
View Source
var DefaultFavorite = FavoriteLogic{}
View Source
var DefaultFeed = FeedLogic{}
View Source
var DefaultFriendLink = FriendLinkLogic{}
View Source
var DefaultGCTT = GCTTLogic{}
View Source
var DefaultGift = GiftLogic{}
View Source
var DefaultGithub = GithubLogic{}
View Source
var DefaultGoBook = GoBookLogic{}
View Source
var DefaultIndex = IndexLogic{}
View Source
var DefaultInstall = InstallLogic{}
View Source
var DefaultInterview = InterviewLogic{}
View Source
var DefaultLearningMaterial = LearningMaterialLogic{}
View Source
var DefaultLike = LikeLogic{}
View Source
var DefaultMessage = MessageLogic{}
View Source
var DefaultMission = MissionLogic{}
View Source
var DefaultNode = TopicNodeLogic{}
View Source
var DefaultProject = ProjectLogic{}
View Source
var DefaultRank = RankLogic{}
View Source
var DefaultReading = ReadingLogic{}
View Source
var DefaultReddit = newRedditLogic()
View Source
var DefaultResource = ResourceLogic{}
View Source
var DefaultRisk = RiskLogic{}
View Source
var DefaultRule = RuleLogic{}
View Source
var DefaultSearcher = SearcherLogic{/* contains filtered or unexported fields */}
View Source
var DefaultSetting = SettingLogic{}
View Source
var DefaultSubject = SubjectLogic{}
View Source
var DefaultThirdUser = ThirdUserLogic{}
View Source
var DefaultTopic = TopicLogic{}
View Source
var DefaultUploader = &UploaderLogic{}
View Source
var DefaultUser = UserLogic{}
View Source
var DefaultUserRich = UserRichLogic{}
View Source
var DefaultViewRecord = ViewRecordLogic{}
View Source
var DefaultViewSource = ViewSourceLogic{}
View Source
var DefaultWechat = WechatLogic{}
View Source
var DefaultWiki = WikiLogic{}
View Source
var PresetUids = config.ConfigFile.MustValueArray("crawl", "preset_uids", ",")
View Source
var PresetUsernames = config.ConfigFile.MustValueArray("crawl", "preset_users", ",")
View Source
var Views = newViews()

Functions

func CanEdit

func CanEdit(me *model.Me, curModel interface{}) bool

CanEdit 判断能否编辑

func CanPublish

func CanPublish(dauAuth, objtype int) bool

func GenNodes

func GenNodes() []map[string][]map[string]interface{}

将 node 组织成一定结构,方便前端展示

func GenSitemap

func GenSitemap()

func GetCategoryName

func GetCategoryName(catid int) string

获得分类名

func GetChildrenNode

func GetChildrenNode(parentId, num int) []interface{}

GetChildrenNode 获取某个父节点下最多 num 个子节点

func GetCurIndexNav

func GetCurIndexNav(tab string) *model.IndexNav

func GetLogger

func GetLogger(ctx context.Context) *logger.Logger

func GetNidByEname

func GetNidByEname(ename string) int

通过 ename 获得 nid

func GetNode

func GetNode(nid int) map[string]interface{}

获得单个节点信息

func GetNodeByEname

func GetNodeByEname(ename string) map[string]interface{}

通过 ename 获得单个节点

func GetNodeName

func GetNodeName(nid int) string

获得单个节点名

func GetNodesByNids

func GetNodesByNids(nids []int) map[int]*model.TopicNode

获得多个节点

func LoadAuthorities

func LoadAuthorities() error

将所有 权限 加载到内存中;后台修改权限时,重新加载一次

func LoadCategories

func LoadCategories() (err error)

将所有 资源分类信息 加载到内存中:后台修改节点时,重新加载一次

func LoadDefaultAvatar

func LoadDefaultAvatar() error

func LoadNodes

func LoadNodes() error

将所有 节点信息 加载到内存中:后台修改节点时,重新加载一次

func LoadRoleAuthorities

func LoadRoleAuthorities() error

将所有 角色拥有的权限 加载到内存中;后台修改时,重新加载一次

func LoadRoles

func LoadRoles() error

将所有 角色 加载到内存中;后台修改角色时,重新加载一次

func LoadUserSetting

func LoadUserSetting() error

func LoadWebsiteSetting

func LoadWebsiteSetting() error

func MaxOnlineNum

func MaxOnlineNum() int

获得历史最高在线人数

func NeedCaptcha

func NeedCaptcha(user *model.Me) bool

NeedCaptcha 是否需要验证码:

  • 新客注册后一段时间内需要
  • 发布内容太频繁(一天次数太多、间隔太快)

func RegisterCommentObject

func RegisterCommentObject(objtype int, commenter Commenter)

注册评论对象,使得某种类型(主题、博客等)被评论了可以回调

func RegisterLikeObject

func RegisterLikeObject(objtype int, liker Liker)

注册喜欢对象,使得某种类型(主题、博文等)被喜欢了可以回调

func SessionClone

func SessionClone(session *xorm.Session) *xorm.Session

func SpamRecord

func SpamRecord(ctx context.Context, user *model.Me, maxNum int)

SpamRecord 控制半夜 Spam 避免误判,只针对最近 3 天内注册的用户

Types

type AdLogic

type AdLogic struct{}

func (AdLogic) FindAll

func (AdLogic) FindAll(ctx context.Context, path string) map[string]*model.Advertisement

type ArticleComment

type ArticleComment struct{}

博文评论

func (ArticleComment) SetObjinfo

func (self ArticleComment) SetObjinfo(ids []int, commentMap map[int][]*model.Comment)

SetObjinfo 实现 CommentObjecter 接口

func (ArticleComment) String

func (self ArticleComment) String() string

func (ArticleComment) UpdateComment

func (self ArticleComment) UpdateComment(cid, objid, uid int, cmttime time.Time)

UpdateComment 更新该文章的评论信息 cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间

type ArticleLike

type ArticleLike struct{}

博文喜欢

func (ArticleLike) String

func (self ArticleLike) String() string

func (ArticleLike) UpdateLike

func (self ArticleLike) UpdateLike(objid, num int)

更新该文章的喜欢数 objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type ArticleLogic

type ArticleLogic struct{}

func (ArticleLogic) Count

func (ArticleLogic) Count(ctx context.Context, querystring string, args ...interface{}) int64

func (ArticleLogic) FindAll

func (self ArticleLogic) FindAll(ctx context.Context, paginator *Paginator, orderBy string, querystring string, args ...interface{}) []*model.Article

FindAll 支持多页翻看

func (ArticleLogic) FindArticleByPage

func (ArticleLogic) FindArticleByPage(ctx context.Context, conds map[string]string, curPage, limit int) ([]*model.Article, int)

获取抓取的文章列表(分页):后台用

func (ArticleLogic) FindArticleGCTT

func (ArticleLogic) FindArticleGCTT(ctx context.Context, article *model.Article) *model.ArticleGCTT

func (ArticleLogic) FindBy

func (self ArticleLogic) FindBy(ctx context.Context, limit int, lastIds ...int) []*model.Article

FindBy 获取抓取的文章列表(分页)

func (ArticleLogic) FindById

func (ArticleLogic) FindById(ctx context.Context, id interface{}) (*model.Article, error)

FindById 获取单条博文

func (ArticleLogic) FindByIdAndPreNext

func (ArticleLogic) FindByIdAndPreNext(ctx context.Context, id int) (curArticle *model.Article, prevNext []*model.Article, err error)

FindByIdAndPreNext 获取当前(id)博文以及前后博文

func (ArticleLogic) FindByIds

func (self ArticleLogic) FindByIds(ids []int) []*model.Article

FindByIds 获取多个文章详细信息

func (ArticleLogic) FindByUser

func (self ArticleLogic) FindByUser(ctx context.Context, username string, limit int) []*model.Article

func (ArticleLogic) FindLastList

func (ArticleLogic) FindLastList(beginTime string, limit int) ([]*model.Article, error)

func (ArticleLogic) FindTaGCTTArticles

func (self ArticleLogic) FindTaGCTTArticles(ctx context.Context, translator string) []*model.Article

func (ArticleLogic) Modify

func (ArticleLogic) Modify(ctx context.Context, user *model.Me, form url.Values) (errMsg string, err error)

Modify 修改文章信息

func (ArticleLogic) MoveToTopic

func (self ArticleLogic) MoveToTopic(ctx context.Context, id interface{}, me *model.Me) error

MoveToTopic 将该文章移到主题中 有些用户总是将问题放在文章中发布

func (ArticleLogic) ParseArticle

func (self ArticleLogic) ParseArticle(ctx context.Context, articleUrl string, auto bool) (*model.Article, error)

ParseArticle 获取 url 对应的文章并根据规则进行解析

func (ArticleLogic) ParseArticleByAccuracy

func (self ArticleLogic) ParseArticleByAccuracy(articleUrl string, tmpArticle *model.Article, auto bool) (*model.Article, error)

func (ArticleLogic) ParseZhihuArticle

func (self ArticleLogic) ParseZhihuArticle(ctx context.Context, articleUrl string, rule *model.CrawlRule) (*model.Article, error)

func (ArticleLogic) Publish

func (self ArticleLogic) Publish(ctx context.Context, me *model.Me, form url.Values) (int, error)

Publish 发布文章

func (ArticleLogic) PublishFromAdmin

func (self ArticleLogic) PublishFromAdmin(ctx context.Context, me *model.Me, form url.Values) error

func (ArticleLogic) SearchMyArticles

func (self ArticleLogic) SearchMyArticles(ctx context.Context, me *model.Me, sid int, kw string) []map[string]interface{}

func (ArticleLogic) Total

func (ArticleLogic) Total() int64

Total 博文总数

type AuthorityLogic

type AuthorityLogic struct{}

func (AuthorityLogic) Del

func (AuthorityLogic) Del(aid int) error

func (AuthorityLogic) FindAuthoritiesByPage

func (AuthorityLogic) FindAuthoritiesByPage(ctx context.Context, conds map[string]string, curPage, limit int) ([]*model.Authority, int)

func (AuthorityLogic) FindById

func (AuthorityLogic) FindById(ctx context.Context, aid int) *model.Authority

func (AuthorityLogic) GeneralAuthorities

func (AuthorityLogic) GeneralAuthorities() map[int][]*model.Authority

除了一级、二级菜单之外的权限(路由)

func (AuthorityLogic) GetMenus

func (AuthorityLogic) GetMenus() ([]*model.Authority, map[string][][]string)

获取整个菜单

func (AuthorityLogic) GetUserMenu

func (self AuthorityLogic) GetUserMenu(ctx context.Context, user *model.Me, uri string) ([]*model.Authority, map[int][]*model.Authority, int)

GetUserMenu 获取用户菜单

func (AuthorityLogic) HasAuthority

func (self AuthorityLogic) HasAuthority(user *model.Me, route string) bool

判断用户是否有某个权限

func (AuthorityLogic) Save

func (AuthorityLogic) Save(ctx context.Context, form url.Values, opUser string) (errMsg string, err error)

type AutoCrawlLogic

type AutoCrawlLogic struct{}

func (AutoCrawlLogic) CrawlWebsite

func (self AutoCrawlLogic) CrawlWebsite(website string, isAll bool) error

通过网站标识抓取

func (AutoCrawlLogic) DoCrawl

func (self AutoCrawlLogic) DoCrawl(isAll bool) error

type BookComment

type BookComment struct{}

图书评论

func (BookComment) SetObjinfo

func (self BookComment) SetObjinfo(ids []int, commentMap map[int][]*model.Comment)

SetObjinfo 实现 CommentObjecter 接口

func (BookComment) String

func (self BookComment) String() string

func (BookComment) UpdateComment

func (self BookComment) UpdateComment(cid, objid, uid int, cmttime time.Time)

UpdateComment 更新该图书的评论信息 cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间

type BookLike

type BookLike struct{}

图书推荐

func (BookLike) String

func (self BookLike) String() string

func (BookLike) UpdateLike

func (self BookLike) UpdateLike(objid, num int)

更新该图书的推荐数 objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type CommentLike

type CommentLike struct{}

回复赞(喜欢)

func (CommentLike) String

func (self CommentLike) String() string

func (CommentLike) UpdateLike

func (self CommentLike) UpdateLike(objid, num int)

更新该回复的赞 objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type CommentLogic

type CommentLogic struct{}

func (CommentLogic) Count

func (CommentLogic) Count(ctx context.Context, querystring string, args ...interface{}) int64

Count 获取用户全部评论数

func (CommentLogic) FindAll

func (self CommentLogic) FindAll(ctx context.Context, paginator *Paginator, orderBy string, querystring string, args ...interface{}) []*model.Comment

FindAll 支持多页翻看

func (CommentLogic) FindById

func (CommentLogic) FindById(cid int) (*model.Comment, error)

func (CommentLogic) FindComment

func (self CommentLogic) FindComment(ctx context.Context, cid, objid, objtype int) (*model.Comment, []*model.Comment)

FindComment 获得评论和额外两个评论

func (CommentLogic) FindObjComments

func (self CommentLogic) FindObjComments(ctx context.Context, objid, objtype int, owner, lastCommentUid int) (comments []map[string]interface{}, ownerUser, lastReplyUser *model.User)

FindObjComments 获得某个对象的所有评论 owner: 被评论对象属主 TODO:分页暂不做

func (CommentLogic) FindObjectComments

func (self CommentLogic) FindObjectComments(ctx context.Context, objid, objtype, p int) (commentList []*model.Comment, replyComments []*model.Comment, pageNum int, err error)

FindObjectComments 获得某个对象的所有评论(新版)

func (CommentLogic) FindRecent

func (self CommentLogic) FindRecent(ctx context.Context, uid, objtype, limit int) []*model.Comment

FindRecent 获得最近的评论 如果 uid!=0,表示获取某人的评论; 如果 objtype!=-1,表示获取某类型的评论;

func (CommentLogic) Modify

func (CommentLogic) Modify(ctx context.Context, cid int, content string) (errMsg string, err error)

Modify 修改评论信息

func (CommentLogic) Publish

func (self CommentLogic) Publish(ctx context.Context, uid, objid int, form url.Values) (*model.Comment, error)

Publish 发表评论(或回复)。 objid 注册的评论对象 uid 评论人

func (CommentLogic) Total

func (CommentLogic) Total(objtypes ...int) int64

Total 评论总数(objtypes[0] 取某一类型的评论总数)

type CommentObjecter

type CommentObjecter interface {
	// ids 是属主的主键 slice (comment 中的 objid)
	// commentMap 中的 key 是属主 id
	SetObjinfo(ids []int, commentMap map[int][]*model.Comment)
}

填充 Comment 对象的 Objinfo 成员接口 评论属主应该实现该接口(以便填充 Objinfo 成员)

type Commenter

type Commenter interface {
	fmt.Stringer
	// 评论回调接口,用于更新对象自身需要更新的数据
	UpdateComment(int, int, int, time.Time)
}

Commenter 评论接口

type ConcreteObservable

type ConcreteObservable struct {
	// contains filtered or unexported fields
}

func NewConcreteObservable

func NewConcreteObservable(action string) *ConcreteObservable

func (*ConcreteObservable) AddObserver

func (this *ConcreteObservable) AddObserver(o Observer)

func (*ConcreteObservable) NotifyObservers

func (this *ConcreteObservable) NotifyObservers(uid, objtype, objid int)

func (*ConcreteObservable) RemoveObserver

func (this *ConcreteObservable) RemoveObserver(o Observer)

type DownloadLogic

type DownloadLogic struct{}

func (DownloadLogic) AddNewDownload

func (DownloadLogic) AddNewDownload(ctx context.Context, version, selector string) error

func (DownloadLogic) FindAll

func (DownloadLogic) FindAll(ctx context.Context) []*model.Download

func (DownloadLogic) RecordDLTimes

func (DownloadLogic) RecordDLTimes(ctx context.Context, filename string) error

type DynamicLogic

type DynamicLogic struct{}

func (DynamicLogic) FindBy

func (DynamicLogic) FindBy(ctx context.Context, lastId int, limit int) []*model.Dynamic

FindBy 获取动态列表(分页)

type EmailLogic

type EmailLogic struct{}

func (EmailLogic) EmailNotice

func (self EmailLogic) EmailNotice()

订阅邮件通知

func (EmailLogic) GenUnsubscribeToken

func (EmailLogic) GenUnsubscribeToken(user *model.User) string

生成 退订 邮件的 token

func (EmailLogic) SendActivateMail

func (self EmailLogic) SendActivateMail(email, uuid string, isHttps ...bool)

SendActivateMail 发送激活邮件

func (EmailLogic) SendAuthMail

func (e EmailLogic) SendAuthMail(subject, content string, tos []string) error

SendAuthMail 发送验证电子邮件

func (EmailLogic) SendMail

func (e EmailLogic) SendMail(subject, content string, tos []string) (err error)

SendMail 发送普通(通知)电子邮件

func (EmailLogic) SendResetpwdMail

func (self EmailLogic) SendResetpwdMail(email, uuid string, isHttps ...bool)

SendResetpwdMail 发重置密码邮件

type FavoriteLogic

type FavoriteLogic struct{}

func (FavoriteLogic) Cancel

func (FavoriteLogic) Cancel(ctx context.Context, uid, objid, objtype int) error

func (FavoriteLogic) FindUserFavorites

func (FavoriteLogic) FindUserFavorites(ctx context.Context, uid, objtype, start, rows int) ([]*model.Favorite, int64)

func (FavoriteLogic) HadFavorite

func (FavoriteLogic) HadFavorite(ctx context.Context, uid, objid, objtype int) int

HadFavorite 某个用户是否已经收藏某个对象

func (FavoriteLogic) Save

func (FavoriteLogic) Save(ctx context.Context, uid, objid, objtype int) error

type FeedLogic

type FeedLogic struct{}

func (FeedLogic) AutoUpdateSeq

func (self FeedLogic) AutoUpdateSeq()

AutoUpdateSeq 自动更新动态的排序(校准)

func (FeedLogic) FindRecent

func (self FeedLogic) FindRecent(ctx context.Context, num int) []*model.Feed

func (FeedLogic) FindRecentWithPaginator

func (self FeedLogic) FindRecentWithPaginator(ctx context.Context, paginator *Paginator, tab string) []*model.Feed

func (FeedLogic) FindTop

func (self FeedLogic) FindTop(ctx context.Context) []*model.Feed

func (FeedLogic) GetTotalCount

func (self FeedLogic) GetTotalCount(ctx context.Context) int64

type FeedSeqObserver

type FeedSeqObserver struct{}

func (*FeedSeqObserver) Update

func (this *FeedSeqObserver) Update(action string, uid, objtype, objid int)

type FriendLinkLogic

type FriendLinkLogic struct{}

func (FriendLinkLogic) FindAll

func (FriendLinkLogic) FindAll(ctx context.Context, limits ...int) []*model.FriendLink

type GCTTLogic

type GCTTLogic struct{}

func (GCTTLogic) BindUser

func (self GCTTLogic) BindUser(ctx context.Context, gcttUser *model.GCTTUser, uid int, githubUser *model.BindUser) error

func (GCTTLogic) FindCoreUsers

func (self GCTTLogic) FindCoreUsers(ctx context.Context) []*model.GCTTUser

func (GCTTLogic) FindIssues

func (self GCTTLogic) FindIssues(ctx context.Context, paginator *Paginator, querysring string, args ...interface{}) []*model.GCTTIssue

func (GCTTLogic) FindNewestGit

func (self GCTTLogic) FindNewestGit(ctx context.Context) []*model.GCTTGit

func (GCTTLogic) FindOne

func (self GCTTLogic) FindOne(ctx context.Context, username string) *model.GCTTUser

func (GCTTLogic) FindTimeLines

func (self GCTTLogic) FindTimeLines(ctx context.Context) []*model.GCTTTimeLine

func (GCTTLogic) FindTranslator

func (self GCTTLogic) FindTranslator(ctx context.Context, me *model.Me) *model.GCTTUser

func (GCTTLogic) FindUnTranslateIssues

func (self GCTTLogic) FindUnTranslateIssues(ctx context.Context, limit int) []*model.GCTTIssue

func (GCTTLogic) FindUsers

func (self GCTTLogic) FindUsers(ctx context.Context) []*model.GCTTUser

func (GCTTLogic) IssueCount

func (self GCTTLogic) IssueCount(ctx context.Context, querystring string, args ...interface{}) int64

type GiftLogic

type GiftLogic struct{}

func (GiftLogic) Exchange

func (self GiftLogic) Exchange(ctx context.Context, me *model.Me, giftId int) error

func (GiftLogic) FindAllOnline

func (self GiftLogic) FindAllOnline(ctx context.Context) []*model.Gift

func (GiftLogic) FindExchangeRecords

func (self GiftLogic) FindExchangeRecords(ctx context.Context, me *model.Me) []*model.UserExchangeRecord

func (GiftLogic) UserCanExchange

func (self GiftLogic) UserCanExchange(ctx context.Context, me *model.Me, gifts []*model.Gift)

type GithubLogic

type GithubLogic struct{}

func (GithubLogic) IssueCommentEvent

func (self GithubLogic) IssueCommentEvent(ctx context.Context, body []byte) error

IssueCommentEvent 处理 issue Comment 的 GitHub 事件

func (GithubLogic) IssueEvent

func (self GithubLogic) IssueEvent(ctx context.Context, body []byte) error

IssueEvent 处理 issue 的 GitHub 事件

func (GithubLogic) PullPR

func (self GithubLogic) PullPR(repo string, isAll bool) error

func (GithubLogic) PullRequestEvent

func (self GithubLogic) PullRequestEvent(ctx context.Context, body []byte) error

func (GithubLogic) RemindTranslator

func (self GithubLogic) RemindTranslator() error

RemindTranslator 提醒译者注认领任的翻译进度,避免认领了长时间不翻译

func (GithubLogic) SyncIssues

func (self GithubLogic) SyncIssues(repo string, isAll bool) error

type GoBookLogic

type GoBookLogic struct{}

func (GoBookLogic) Count

func (GoBookLogic) Count(ctx context.Context) int64

func (GoBookLogic) FindAll

func (GoBookLogic) FindAll(ctx context.Context, paginator *Paginator, orderBy string) []*model.Book

FindAll 支持多页翻看

func (GoBookLogic) FindBy

func (GoBookLogic) FindBy(ctx context.Context, limit int, lastIds ...int) []*model.Book

FindBy 获取图书列表(分页)

func (GoBookLogic) FindById

func (GoBookLogic) FindById(ctx context.Context, id interface{}) (*model.Book, error)

FindById 获取一本图书信息

func (GoBookLogic) FindByIds

func (GoBookLogic) FindByIds(ids []int) []*model.Book

FindByIds 获取多个图书详细信息

func (GoBookLogic) Publish

func (self GoBookLogic) Publish(ctx context.Context, user *model.Me, form url.Values) (err error)

func (GoBookLogic) Total

func (GoBookLogic) Total() int64

Total 图书总数

type IndexLogic

type IndexLogic struct{}

func (IndexLogic) FindData

func (self IndexLogic) FindData(ctx context.Context, tab string, paginator *Paginator) map[string]interface{}

type InstallLogic

type InstallLogic struct{}

func (InstallLogic) CreateTable

func (InstallLogic) CreateTable(ctx context.Context) error

func (InstallLogic) HadRootUser

func (InstallLogic) HadRootUser(ctx context.Context) bool

HadRootUser 是否已经创建了超级用户

func (InstallLogic) InitTable

func (InstallLogic) InitTable(ctx context.Context) error

InitTable 初始化数据表

func (InstallLogic) IsTableExist

func (InstallLogic) IsTableExist(ctx context.Context) bool

type InterviewComment

type InterviewComment struct{}

面试题回复(评论)

func (InterviewComment) SetObjinfo

func (self InterviewComment) SetObjinfo(ids []int, commentMap map[int][]*model.Comment)

实现 CommentObjecter 接口

func (InterviewComment) String

func (self InterviewComment) String() string

func (InterviewComment) UpdateComment

func (self InterviewComment) UpdateComment(cid, objid, uid int, cmttime time.Time)

UpdateComment 更新该面试题的回复信息 cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间

type InterviewLike

type InterviewLike struct{}

面试题喜欢

func (InterviewLike) String

func (self InterviewLike) String() string

func (InterviewLike) UpdateLike

func (self InterviewLike) UpdateLike(objid, num int)

更新该面试题的喜欢数(赞数) objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type InterviewLogic

type InterviewLogic struct{}

func (InterviewLogic) FindOne

func (InterviewLogic) Publish

func (InterviewLogic) TodayQuestion

func (iq InterviewLogic) TodayQuestion(ctx context.Context) *model.InterviewQuestion

func (InterviewLogic) UpdateTodayQuestionID

func (InterviewLogic) UpdateTodayQuestionID()

type LearningMaterialLogic

type LearningMaterialLogic struct{}

func (LearningMaterialLogic) FindAll

type LikeLogic

type LikeLogic struct{}

func (LikeLogic) FindUserLikeObjects

func (LikeLogic) FindUserLikeObjects(ctx context.Context, uid, objtype int, objids ...int) (map[int]int, error)

FindUserLikeObjects 获取用户对一批对象是否喜欢的状态 objids 两个值

func (LikeLogic) FindUserRecentLikes

func (LikeLogic) FindUserRecentLikes(ctx context.Context, uid, limit int) (map[int]map[int]int, error)

FindUserRecentLikes 获取用户最近喜欢的对象(不过滤对象)

func (LikeLogic) HadLike

func (LikeLogic) HadLike(ctx context.Context, uid, objid, objtype int) int

HadLike 某个用户是否已经喜欢某个对象

func (LikeLogic) LikeObject

func (LikeLogic) LikeObject(ctx context.Context, uid, objid, objtype, likeFlag int) error

LikeObject 喜欢或取消喜欢 objid 注册的喜欢对象 uid 喜欢的人

type Liker

type Liker interface {
	fmt.Stringer
	// 喜欢 回调接口,用于更新对象自身需要更新的数据
	UpdateLike(int, int)
}

喜欢接口

type LoginUser

type LoginUser struct {
	Uid            int    `json:"uid"`
	LastAccessTime string `json:"last_access_time"`
	OnlineDuartion string `json:"online_duration"`
}

用于 expvar 统计信息

type LoginUserSlice

type LoginUserSlice []*LoginUser

func (LoginUserSlice) String

func (self LoginUserSlice) String() string

type Message

type Message struct {
	Type int         `json:"type"`
	Body interface{} `json:"body"`
}

func NewMessage

func NewMessage(msgType int, msgBody interface{}) *Message

type MessageLogic

type MessageLogic struct{}

func (MessageLogic) DeleteMessage

func (MessageLogic) DeleteMessage(ctx context.Context, id, msgtype string) bool

DeleteMessage 删除消息 msgtype -> system(系统消息)/inbox(outbox)(短消息)

func (MessageLogic) FindFromMsgsByUid

func (MessageLogic) FindFromMsgsByUid(ctx context.Context, uid int, paginator *Paginator) []map[string]interface{}

获取某人发送的消息

func (MessageLogic) FindMsgById

func (MessageLogic) FindMsgById(ctx context.Context, id string) *model.Message

func (MessageLogic) FindNotReadMsgNum

func (MessageLogic) FindNotReadMsgNum(ctx context.Context, uid int) int

FindNotReadMsgNum 获得某个用户未读消息数(系统消息和短消息)

func (MessageLogic) FindSysMsgsByUid

func (self MessageLogic) FindSysMsgsByUid(ctx context.Context, uid int, paginator *Paginator) []map[string]interface{}

FindSysMsgsByUid 获得某人的系统消息 系统消息类型不同,在ext中存放的字段也不一样,如下:

  model.MsgtypeTopicReply/MsgtypeResourceComment/MsgtypeWikiComment存放都为:
		{"uid":xxx,"objid":xxx}
  model.MsgtypeAtMe 为:{"uid":xxx,"cid":xxx,"objid":xxx,"objtype":xxx}
  model.MsgtypePulishAtMe 为:{"uid":xxx,"objid":xxx,"objtype":xxx}

func (MessageLogic) FindToMsgsByUid

func (self MessageLogic) FindToMsgsByUid(ctx context.Context, uid int, paginator *Paginator) []map[string]interface{}

获得发给某人的短消息(收件箱)

func (MessageLogic) FromMsgCount

func (MessageLogic) FromMsgCount(ctx context.Context, uid int) int64

func (MessageLogic) MarkHasRead

func (MessageLogic) MarkHasRead(ctx context.Context, ids []int, isSysMsg bool, uid int) bool

MarkHasRead 标记消息已读

func (MessageLogic) SendMessageTo

func (MessageLogic) SendMessageTo(ctx context.Context, from, to int, content string) bool

SendMessageTo from给to发短信息

func (MessageLogic) SendSysMsgAtUids

func (MessageLogic) SendSysMsgAtUids(ctx context.Context, uids string, ext map[string]interface{}, author int) bool

SendSysMsgAtUids 给被@的用户发系统消息 authors 是被评论对象的作者

func (MessageLogic) SendSysMsgAtUsernames

func (MessageLogic) SendSysMsgAtUsernames(ctx context.Context, usernames string, ext map[string]interface{}, author int) bool

SendSysMsgAtUsernames 给被@的用户发系统消息 ext 中可以指定 msgtype,没有指定,默认为 MsgtypeAtMe

func (MessageLogic) SendSystemMsgTo

func (MessageLogic) SendSystemMsgTo(ctx context.Context, to, msgtype int, ext map[string]interface{}) bool

SendSystemMsgTo 给某人发系统消息

func (MessageLogic) SysMsgCount

func (MessageLogic) SysMsgCount(ctx context.Context, uid int) int64

func (MessageLogic) ToMsgCount

func (MessageLogic) ToMsgCount(ctx context.Context, uid int) int64

type MissionLogic

type MissionLogic struct{}

func (MissionLogic) Complete

func (MissionLogic) Complete(ctx context.Context, me *model.Me, id string) error

Complete 完成任务(非每日任务)

func (MissionLogic) FindLoginMission

func (MissionLogic) FindLoginMission(ctx context.Context, me *model.Me) *model.UserLoginMission

func (MissionLogic) HasLoginMission

func (self MissionLogic) HasLoginMission(ctx context.Context, me *model.Me) bool

HasLoginMission 是否有今日登录奖励

func (MissionLogic) RedeemLoginAward

func (self MissionLogic) RedeemLoginAward(ctx context.Context, me *model.Me) error

RedeemLoginAward 领取登录奖励

type Observable

type Observable interface {
	// AddObserver 登记一个新的观察者
	AddObserver(o Observer)
	// Detach 删除一个已经登记过的观察者
	RemoveObserver(o Observer)
	// NotifyObservers 通知所有登记过的观察者
	NotifyObservers(uid, objtype, objid int)
}
var (
	ViewObservable Observable
)

type Observer

type Observer interface {
	Update(action string, uid, objtype, objid int)
}

type Paginator

type Paginator struct {
	// contains filtered or unexported fields
}

Paginator 分页器

func NewPaginator

func NewPaginator(curPage int) *Paginator

func NewPaginatorWithPerPage

func NewPaginatorWithPerPage(curPage, perPage int) *Paginator

func (*Paginator) GetPageHtml

func (this *Paginator) GetPageHtml(uri string, total ...int) string

GetPageHtml 构造分页html, uri 当前uri, total 记录总数

func (*Paginator) GetTotal

func (this *Paginator) GetTotal() int

func (*Paginator) HasMorePage

func (this *Paginator) HasMorePage() bool

func (*Paginator) Offset

func (this *Paginator) Offset() (offset int)

func (*Paginator) PerPage

func (this *Paginator) PerPage() int

func (*Paginator) SetPerPage

func (this *Paginator) SetPerPage(perPage int)

func (*Paginator) SetTotal

func (this *Paginator) SetTotal(total int64) *Paginator

type ProjectComment

type ProjectComment struct{}

项目评论

func (ProjectComment) SetObjinfo

func (self ProjectComment) SetObjinfo(ids []int, commentMap map[int][]*model.Comment)

实现 CommentObjecter 接口

func (ProjectComment) String

func (self ProjectComment) String() string

func (ProjectComment) UpdateComment

func (self ProjectComment) UpdateComment(cid, objid, uid int, cmttime time.Time)

更新该项目的评论信息 cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间

type ProjectLike

type ProjectLike struct{}

项目喜欢

func (ProjectLike) String

func (self ProjectLike) String() string

func (ProjectLike) UpdateLike

func (self ProjectLike) UpdateLike(objid, num int)

更新该项目的喜欢数 objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type ProjectLogic

type ProjectLogic struct{}

func (ProjectLogic) Count

func (ProjectLogic) Count(ctx context.Context, querystring string, args ...interface{}) int64

func (ProjectLogic) FindAll

func (self ProjectLogic) FindAll(ctx context.Context, paginator *Paginator, orderBy string, querystring string, args ...interface{}) []*model.OpenProject

FindAll 支持多页翻看

func (ProjectLogic) FindBy

func (ProjectLogic) FindBy(ctx context.Context, limit int, lastIds ...int) []*model.OpenProject

FindBy 获取开源项目列表(分页)

func (ProjectLogic) FindByIds

func (ProjectLogic) FindByIds(ids []int) []*model.OpenProject

FindByIds 获取多个项目详细信息

func (ProjectLogic) FindOne

func (ProjectLogic) FindOne(ctx context.Context, val interface{}) *model.OpenProject

FindOne 获取单个项目

func (ProjectLogic) FindRecent

func (ProjectLogic) FindRecent(ctx context.Context, username string) []*model.OpenProject

FindRecent 获得某个用户最近发布的开源项目

func (ProjectLogic) ParseOneProject

func (ProjectLogic) ParseOneProject(projectUrl string) error

ParseOneProject 处理单个 project

func (ProjectLogic) ParseProjectList

func (self ProjectLogic) ParseProjectList(pUrl string) error

ParseProjectList 解析其他网站的开源项目

func (ProjectLogic) Publish

func (self ProjectLogic) Publish(ctx context.Context, user *model.Me, form url.Values) (err error)

func (ProjectLogic) Total

func (ProjectLogic) Total() int64

Total 开源项目总数

func (ProjectLogic) UriExists

func (ProjectLogic) UriExists(ctx context.Context, uri string) bool

UriExists 通过 uri 是否存在 project

type RankLogic

type RankLogic struct{}

func (RankLogic) FindDAURank

func (self RankLogic) FindDAURank(ctx context.Context, num int, ymds ...string) []*model.User

FindDAURank DAU 排名,默认获取当天的

func (RankLogic) FindDayRank

func (self RankLogic) FindDayRank(ctx context.Context, objtype int, ymd string, num int, needExt ...bool) (result interface{})

FindDayRank needExt 是否需要扩展数据

func (RankLogic) FindMonthRank

func (self RankLogic) FindMonthRank(ctx context.Context, objtype, num int, needExt ...bool) (result interface{})

func (RankLogic) FindRichRank

func (self RankLogic) FindRichRank(ctx context.Context) []*model.User

FindRichRank 社区财富排行榜

func (RankLogic) FindWeekRank

func (self RankLogic) FindWeekRank(ctx context.Context, objtype, num int, needExt ...bool) (result interface{})

func (RankLogic) GenDAURank

func (self RankLogic) GenDAURank(uid, weight int)

GenDAURank 生成日活跃用户排行

func (RankLogic) GenDayRank

func (self RankLogic) GenDayRank(objtype, objid, num int)

func (RankLogic) GenMonthRank

func (self RankLogic) GenMonthRank(objtype int)

GenMonthRank 过去 30 天排行榜

func (RankLogic) GenWeekRank

func (self RankLogic) GenWeekRank(objtype int)

GenWeekRank 过去 7 天排行榜

func (RankLogic) TotalDAUUser

func (self RankLogic) TotalDAUUser(ctx context.Context) int

TotalDAUUser 今日活跃用户数

func (RankLogic) UserDAURank

func (self RankLogic) UserDAURank(ctx context.Context, uid int) int

type ReadingLogic

type ReadingLogic struct{}

func (ReadingLogic) FindBy

func (ReadingLogic) FindBy(ctx context.Context, limit, rtype int, lastIds ...int) []*model.MorningReading

获取晨读列表(分页)

func (ReadingLogic) FindById

func (ReadingLogic) FindById(ctx context.Context, id int) *model.MorningReading

FindById 获取单条晨读

func (ReadingLogic) FindLastList

func (ReadingLogic) FindLastList(beginTime string) ([]*model.MorningReading, error)

func (ReadingLogic) FindReadingByPage

func (ReadingLogic) FindReadingByPage(ctx context.Context, conds map[string]string, curPage, limit int) ([]*model.MorningReading, int)

FindReadingByPage 获取晨读列表(分页)

func (ReadingLogic) IReading

func (ReadingLogic) IReading(ctx context.Context, id int) string

【我要晨读】

func (ReadingLogic) SaveReading

func (ReadingLogic) SaveReading(ctx context.Context, form url.Values, username string) (errMsg string, err error)

SaveReading 保存晨读

type RedditLogic

type RedditLogic struct {
	// contains filtered or unexported fields
}

func (*RedditLogic) Parse

func (this *RedditLogic) Parse(redditUrl string) error

Parse 获取url对应的资源并根据规则进行解析

type ResourceComment

type ResourceComment struct{}

资源评论

func (ResourceComment) SetObjinfo

func (self ResourceComment) SetObjinfo(ids []int, commentMap map[int][]*model.Comment)

实现 CommentObjecter 接口

func (ResourceComment) String

func (self ResourceComment) String() string

func (ResourceComment) UpdateComment

func (self ResourceComment) UpdateComment(cid, objid, uid int, cmttime time.Time)

更新该资源的评论信息 cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间

type ResourceLike

type ResourceLike struct{}

资源喜欢

func (ResourceLike) String

func (self ResourceLike) String() string

func (ResourceLike) UpdateLike

func (self ResourceLike) UpdateLike(objid, num int)

更新该主题的喜欢数 objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type ResourceLogic

type ResourceLogic struct{}

func (ResourceLogic) Count

func (ResourceLogic) Count(ctx context.Context, querystring string, args ...interface{}) int64

func (ResourceLogic) FindAll

func (self ResourceLogic) FindAll(ctx context.Context, paginator *Paginator, orderBy, querystring string, args ...interface{}) (resources []map[string]interface{}, total int64)

FindAll 获得资源列表(完整信息),分页

func (ResourceLogic) FindBy

func (ResourceLogic) FindBy(ctx context.Context, limit int, lastIds ...int) []*model.Resource

FindBy 获取资源列表(分页)

func (ResourceLogic) FindByCatid

func (ResourceLogic) FindByCatid(ctx context.Context, paginator *Paginator, catid int) (resources []map[string]interface{}, total int64)

FindByCatid 获得某个分类的资源列表,分页

func (ResourceLogic) FindById

func (ResourceLogic) FindById(ctx context.Context, id int) (resourceMap map[string]interface{}, comments []map[string]interface{})

获得资源详细信息

func (ResourceLogic) FindByIds

func (ResourceLogic) FindByIds(ids []int) []*model.Resource

FindByIds 获取多个资源详细信息

func (ResourceLogic) FindRecent

func (ResourceLogic) FindRecent(ctx context.Context, uid int) []*model.Resource

获得某个用户最近的资源

func (ResourceLogic) FindResource

func (ResourceLogic) FindResource(ctx context.Context, id int) *model.Resource

获取单个 Resource 信息(用于编辑)

func (ResourceLogic) Publish

func (ResourceLogic) Publish(ctx context.Context, me *model.Me, form url.Values) (err error)

Publish 增加(修改)资源

func (ResourceLogic) Total

func (ResourceLogic) Total() int64

Total 资源总数

type RiskLogic

type RiskLogic struct{}

func (RiskLogic) AddBlackIP

func (RiskLogic) AddBlackIP(ip string) error

AddBlackIP 加入 IP 黑名单

func (RiskLogic) AddBlackIPByUID

func (self RiskLogic) AddBlackIPByUID(uid int) error

AddBlackIPByUID 通过用户 UID 将最后一次登录 IP 加入黑名单

func (RiskLogic) IsBlackIP

func (RiskLogic) IsBlackIP(ip string) bool

IsBlackIP 是否是 IP 黑名单

type RuleLogic

type RuleLogic struct{}

func (RuleLogic) Delete

func (RuleLogic) Delete(ctx context.Context, id string) error

func (RuleLogic) FindBy

func (RuleLogic) FindBy(ctx context.Context, conds map[string]string, curPage, limit int) ([]*model.CrawlRule, int)

获取抓取规则列表(分页)

func (RuleLogic) FindById

func (RuleLogic) FindById(ctx context.Context, id string) *model.CrawlRule

func (RuleLogic) Save

func (RuleLogic) Save(ctx context.Context, form url.Values, opUser string) (errMsg string, err error)

type SearcherLogic

type SearcherLogic struct {
	// contains filtered or unexported fields
}

func (*SearcherLogic) DoSearch

func (this *SearcherLogic) DoSearch(q, field string, start, rows int) (*model.ResponseBody, error)

DoSearch 搜索

func (*SearcherLogic) FillNodeAndUser

func (this *SearcherLogic) FillNodeAndUser(ctx context.Context, respBody *model.ResponseBody) (map[int]*model.User, map[int]*model.TopicNode)

func (*SearcherLogic) FindAtomFeeds

func (this *SearcherLogic) FindAtomFeeds(rows int) (*model.ResponseBody, error)

func (SearcherLogic) Indexing

func (self SearcherLogic) Indexing(isAll bool)

准备索引数据,post 给 solr isAll: 是否全量

func (SearcherLogic) IndexingArticle

func (self SearcherLogic) IndexingArticle(isAll bool)

IndexingArticle 索引博文

func (SearcherLogic) IndexingOpenProject

func (self SearcherLogic) IndexingOpenProject(isAll bool)

IndexingOpenProject 索引博文

func (SearcherLogic) IndexingResource

func (self SearcherLogic) IndexingResource(isAll bool)

索引资源

func (SearcherLogic) IndexingTopic

func (self SearcherLogic) IndexingTopic(isAll bool)

索引主题

func (*SearcherLogic) SearchByField

func (this *SearcherLogic) SearchByField(field, value string, start, rows int, sorts ...string) (*model.ResponseBody, error)

DoSearch 搜索

type SettingLogic

type SettingLogic struct{}

func (SettingLogic) Update

func (SettingLogic) Update(ctx context.Context, form url.Values) error

func (SettingLogic) UpdateIndexTabChildren

func (SettingLogic) UpdateIndexTabChildren(ctx context.Context, form url.Values) error

type SolrClient

type SolrClient struct {
	// contains filtered or unexported fields
}

func NewSolrClient

func NewSolrClient() *SolrClient

func (*SolrClient) Post

func (this *SolrClient) Post() error

func (*SolrClient) PushAdd

func (this *SolrClient) PushAdd(addCommand *model.AddCommand)

func (*SolrClient) PushDel

func (this *SolrClient) PushDel(delCommand *model.DelCommand)

type SubjectLogic

type SubjectLogic struct{}

func (SubjectLogic) Contribute

func (self SubjectLogic) Contribute(ctx context.Context, me *model.Me, sid, articleId int) error

Contribute 投稿

func (SubjectLogic) ExistByName

func (self SubjectLogic) ExistByName(name string) bool

func (SubjectLogic) FindArticleSubjects

func (self SubjectLogic) FindArticleSubjects(ctx context.Context, articleId int) []*model.Subject

func (SubjectLogic) FindArticleTotal

func (self SubjectLogic) FindArticleTotal(ctx context.Context, sid int) int64

FindArticleTotal 专栏收录的文章数

func (SubjectLogic) FindArticles

func (self SubjectLogic) FindArticles(ctx context.Context, sid int, paginator *Paginator, orderBy string) []*model.Article

func (SubjectLogic) FindBy

func (self SubjectLogic) FindBy(ctx context.Context, paginator *Paginator) []*model.Subject

func (SubjectLogic) FindFollowerTotal

func (self SubjectLogic) FindFollowerTotal(ctx context.Context, sid int) int64

FindFollowerTotal 专栏关注的用户数

func (SubjectLogic) FindFollowers

func (self SubjectLogic) FindFollowers(ctx context.Context, sid int) []*model.SubjectFollower

FindFollowers 专栏关注的用户

func (SubjectLogic) FindMine

func (self SubjectLogic) FindMine(ctx context.Context, me *model.Me, articleId int, kw string) []map[string]interface{}

FindMine 获取我管理的专栏列表

func (SubjectLogic) FindOne

func (self SubjectLogic) FindOne(ctx context.Context, sid int) *model.Subject

func (SubjectLogic) Follow

func (self SubjectLogic) Follow(ctx context.Context, sid int, me *model.Me) (err error)

Follow 关注或取消关注

func (SubjectLogic) HadFollow

func (self SubjectLogic) HadFollow(ctx context.Context, sid int, me *model.Me) bool

func (SubjectLogic) Modify

func (SubjectLogic) Modify(ctx context.Context, user *model.Me, form url.Values) (errMsg string, err error)

Modify 修改专栏

func (SubjectLogic) Publish

func (self SubjectLogic) Publish(ctx context.Context, me *model.Me, form url.Values) (sid int, err error)

Publish 发布专栏。

func (SubjectLogic) RemoveContribute

func (self SubjectLogic) RemoveContribute(ctx context.Context, sid, articleId int) error

RemoveContribute 删除投稿

type ThirdUserLogic

type ThirdUserLogic struct{}

func (ThirdUserLogic) BindGitea

func (self ThirdUserLogic) BindGitea(ctx context.Context, code string, me *model.Me) error

func (ThirdUserLogic) BindGithub

func (self ThirdUserLogic) BindGithub(ctx context.Context, code string, me *model.Me) error

func (ThirdUserLogic) GiteaAuthCodeUrl

func (ThirdUserLogic) GiteaAuthCodeUrl(ctx context.Context, redirectURL string) string

func (ThirdUserLogic) GithubAuthCodeUrl

func (ThirdUserLogic) GithubAuthCodeUrl(ctx context.Context, redirectURL string) string

func (ThirdUserLogic) LoginFromGitea

func (self ThirdUserLogic) LoginFromGitea(ctx context.Context, code string) (*model.User, error)

func (ThirdUserLogic) LoginFromGithub

func (self ThirdUserLogic) LoginFromGithub(ctx context.Context, code string) (*model.User, error)

func (ThirdUserLogic) UnBindUser

func (ThirdUserLogic) UnBindUser(ctx context.Context, bindId interface{}, me *model.Me) error

type TodayActiveObserver

type TodayActiveObserver struct{}

func (*TodayActiveObserver) Update

func (*TodayActiveObserver) Update(action string, uid, objtype, objid int)

type TopicComment

type TopicComment struct{}

话题回复(评论)

func (TopicComment) SetObjinfo

func (self TopicComment) SetObjinfo(ids []int, commentMap map[int][]*model.Comment)

实现 CommentObjecter 接口

func (TopicComment) String

func (self TopicComment) String() string

func (TopicComment) UpdateComment

func (self TopicComment) UpdateComment(cid, objid, uid int, cmttime time.Time)

UpdateComment 更新该主题的回复信息 cid:评论id;objid:被评论对象id;uid:评论者;cmttime:评论时间

type TopicLike

type TopicLike struct{}

主题喜欢

func (TopicLike) String

func (self TopicLike) String() string

func (TopicLike) UpdateLike

func (self TopicLike) UpdateLike(objid, num int)

更新该主题的喜欢数 objid:被喜欢对象id;num: 喜欢数(负数表示取消喜欢)

type TopicLogic

type TopicLogic struct{}

func (TopicLogic) Append

func (self TopicLogic) Append(ctx context.Context, uid, tid int, content string) error

Append 主题附言

func (TopicLogic) AutoUnsetTop

func (self TopicLogic) AutoUnsetTop() error

AutoUnsetTop 自动取消置顶

func (TopicLogic) Count

func (TopicLogic) Count(ctx context.Context, querystring string, args ...interface{}) int64

func (TopicLogic) FindAll

func (self TopicLogic) FindAll(ctx context.Context, paginator *Paginator, orderBy string, querystring string, args ...interface{}) []map[string]interface{}

FindAll 支持多页翻看

func (TopicLogic) FindAppend

func (TopicLogic) FindAppend(ctx context.Context, tid int) []*model.TopicAppend

func (TopicLogic) FindByNid

func (TopicLogic) FindByNid(ctx context.Context, nid, curTid string) []*model.Topic

FindByNid 获得某个节点下的主题列表(侧边栏推荐)

func (TopicLogic) FindByPage

func (TopicLogic) FindByPage(ctx context.Context, conds map[string]string, curPage, limit int) ([]*model.Topic, int)

获取列表(分页):后台用

func (TopicLogic) FindByTid

func (self TopicLogic) FindByTid(ctx context.Context, tid int) (topicMap map[string]interface{}, replies []map[string]interface{}, err error)

FindByTid 获得主题详细信息(包括详细回复)

func (TopicLogic) FindByTids

func (TopicLogic) FindByTids(tids []int) []*model.Topic

FindByTids 获取多个主题详细信息

func (TopicLogic) FindFullinfoByTids

func (self TopicLogic) FindFullinfoByTids(tids []int) []map[string]interface{}

func (TopicLogic) FindHotNodes

func (TopicLogic) FindHotNodes(ctx context.Context) []map[string]interface{}

FindHotNodes 获得热门节点

func (TopicLogic) FindLastList

func (TopicLogic) FindLastList(beginTime string, limit int) ([]*model.Topic, error)

func (TopicLogic) FindRecent

func (self TopicLogic) FindRecent(limit int, uids ...int) []*model.Topic

FindRecent 获得最近的主题(uids[0],则获取某个用户最近的主题)

func (TopicLogic) JSEscape

func (TopicLogic) JSEscape(topics []*model.Topic) []*model.Topic

JSEscape 安全过滤

func (TopicLogic) Modify

func (TopicLogic) Modify(ctx context.Context, user *model.Me, form url.Values) (errMsg string, err error)

Modify 修改主题 user 修改人的(有可能是作者或管理员)

func (TopicLogic) Publish

func (self TopicLogic) Publish(ctx context.Context, me *model.Me, form url.Values) (tid int, err error)

Publish 发布主题。入topics和topics_ex库

func (TopicLogic) SetTop

func (self TopicLogic) SetTop(ctx context.Context, me *model.Me, tid int) error

SetTop 置顶

func (TopicLogic) Total

func (TopicLogic) Total() int64

Total 话题总数

func (TopicLogic) UnsetTop

func (self TopicLogic) UnsetTop(ctx context.Context, tid int) error

UnsetTop 取消置顶

type TopicNodeLogic

type TopicNodeLogic struct{}

func (TopicNodeLogic) FindAll

func (self TopicNodeLogic) FindAll(ctx context.Context) []*model.TopicNode

func (TopicNodeLogic) FindByEname

func (self TopicNodeLogic) FindByEname(ename string) *model.TopicNode

func (TopicNodeLogic) FindByNids

func (self TopicNodeLogic) FindByNids(nids []int) map[int]*model.TopicNode

func (TopicNodeLogic) FindByParent

func (self TopicNodeLogic) FindByParent(pid, num int) []*model.TopicNode

func (TopicNodeLogic) FindOne

func (self TopicNodeLogic) FindOne(nid int) *model.TopicNode

func (TopicNodeLogic) FindParallelTree

func (self TopicNodeLogic) FindParallelTree(ctx context.Context) []*model.TopicNode

func (TopicNodeLogic) Modify

func (self TopicNodeLogic) Modify(ctx context.Context, form url.Values) error

func (TopicNodeLogic) ModifySeq

func (self TopicNodeLogic) ModifySeq(ctx context.Context, nid, seq int) error

type UploaderLogic

type UploaderLogic struct {
	// contains filtered or unexported fields
}

http://developer.qiniu.com/code/v6/sdk/go-sdk-6.html

func (*UploaderLogic) InitQiniu

func (this *UploaderLogic) InitQiniu()

func (*UploaderLogic) TransferUrl

func (this *UploaderLogic) TransferUrl(ctx context.Context, origUrl string, prefixs ...string) (string, error)

TransferUrl 将外站图片URL转为本站,如果失败,返回原图

func (*UploaderLogic) UploadImage

func (this *UploaderLogic) UploadImage(ctx context.Context, reader gio.Reader, imgDir string, buf []byte, ext string) (string, error)

type UserData

type UserData struct {
	// contains filtered or unexported fields
}

func (*UserData) InitMessageQueue

func (this *UserData) InitMessageQueue(serverId int)

func (*UserData) Len

func (this *UserData) Len() int

func (*UserData) MessageQueue

func (this *UserData) MessageQueue(serverId int) <-chan *Message

func (*UserData) Remove

func (this *UserData) Remove(serverId int)

func (*UserData) SendMessage

func (this *UserData) SendMessage(message *Message)

type UserLogic

type UserLogic struct{}

func (UserLogic) Activate

func (self UserLogic) Activate(ctx context.Context, email, uuid string, timestamp int64, sign string) (*model.User, error)

Activate 用户激活

func (UserLogic) AdminUpdateUser

func (self UserLogic) AdminUpdateUser(ctx context.Context, uid string, form url.Values)

func (UserLogic) ChangeAvatar

func (UserLogic) ChangeAvatar(ctx context.Context, uid int, avatar string) (err error)

ChangeAvatar 更换头像

func (UserLogic) CreateUser

func (self UserLogic) CreateUser(ctx context.Context, form url.Values) (errMsg string, err error)

CreateUser 创建用户

func (UserLogic) DecrUserWeight

func (UserLogic) DecrUserWeight(field string, value interface{}, divide int)

func (UserLogic) DeleteUserContent

func (UserLogic) DeleteUserContent(ctx context.Context, uid int) error

func (UserLogic) EmailOrUsernameExists

func (UserLogic) EmailOrUsernameExists(ctx context.Context, email, username string) bool

EmailOrUsernameExists 判断指定的邮箱(email)或用户名是否存在

func (UserLogic) EmailSubscribe

func (UserLogic) EmailSubscribe(ctx context.Context, uid, unsubscribe int)

邮件订阅或取消订阅

func (UserLogic) FindActiveUsers

func (UserLogic) FindActiveUsers(ctx context.Context, limit int, offset ...int) []*model.UserActive

FindActiveUsers 获得活跃用户

func (UserLogic) FindBindUsers

func (UserLogic) FindBindUsers(ctx context.Context, uid int) []*model.BindUser

func (UserLogic) FindCurrentUser

func (self UserLogic) FindCurrentUser(ctx context.Context, username interface{}) *model.Me

获取当前登录用户信息(常用信息)

func (UserLogic) FindDAUUsers

func (UserLogic) FindDAUUsers(ctx context.Context, uids []int) map[int]*model.User

func (UserLogic) FindNewUsers

func (UserLogic) FindNewUsers(ctx context.Context, limit int, offset ...int) []*model.User

FindNewUsers 最新加入会员

func (UserLogic) FindNotLoginUsers

func (UserLogic) FindNotLoginUsers(loginTime time.Time) (userList []*model.UserLogin, err error)

获取 loginTime 之前没有登录的用户

func (UserLogic) FindOne

func (self UserLogic) FindOne(ctx context.Context, field string, val interface{}) *model.User

func (UserLogic) FindUserByPage

func (UserLogic) FindUserByPage(ctx context.Context, conds map[string]string, curPage, limit int) ([]*model.User, int)

获取用户列表(分页):后台用

func (UserLogic) FindUserInfos

func (self UserLogic) FindUserInfos(ctx context.Context, uniq interface{}) map[int]*model.User

FindUserInfos 获得用户信息,uniq 可能是 uid slice 或 username slice

func (UserLogic) GetUserMentions

func (UserLogic) GetUserMentions(term string, limit int, isHttps bool) []map[string]string

GetUserMentions 获取 @ 的 suggest 列表

func (UserLogic) HasPasswd

func (UserLogic) HasPasswd(ctx context.Context, uid int) bool

func (UserLogic) IncrUserWeight

func (UserLogic) IncrUserWeight(field string, value interface{}, weight int)

增加或减少用户活跃度

func (UserLogic) IsAdmin

func (UserLogic) IsAdmin(user *model.User) bool

func (UserLogic) Login

func (self UserLogic) Login(ctx context.Context, username, passwd string) (*model.UserLogin, error)

Login 登录;成功返回用户登录信息(user_login)

func (UserLogic) RecordLogin

func (UserLogic) RecordLogin(username string, ipinter interface{}) error

RecordLogin 记录用户最后登录时间和 IP

func (UserLogic) ResetPasswd

func (self UserLogic) ResetPasswd(ctx context.Context, email, passwd string) (string, error)

func (UserLogic) Total

func (UserLogic) Total() int64

会员总数

func (UserLogic) Update

func (self UserLogic) Update(ctx context.Context, me *model.Me, form url.Values) (errMsg string, err error)

Update 更新用户信息

func (UserLogic) UpdatePasswd

func (self UserLogic) UpdatePasswd(ctx context.Context, username, curPasswd, newPasswd string) (string, error)

UpdatePasswd 更新用户密码

func (UserLogic) UpdateUserStatus

func (UserLogic) UpdateUserStatus(ctx context.Context, uid, status int) error

UpdateUserStatus 更新用户状态

func (UserLogic) UserExists

func (UserLogic) UserExists(ctx context.Context, field, val string) bool

UserExists 判断用户是否存在

type UserRichLogic

type UserRichLogic struct{}

func (UserRichLogic) AwardCooper

func (self UserRichLogic) AwardCooper()

func (UserRichLogic) FindBalanceDetail

func (UserRichLogic) FindBalanceDetail(ctx context.Context, me *model.Me, p int, types ...int) []*model.UserBalanceDetail

func (UserRichLogic) FindRecharge

func (self UserRichLogic) FindRecharge(ctx context.Context, me *model.Me) int

func (UserRichLogic) IncrUserRich

func (self UserRichLogic) IncrUserRich(user *model.User, typ, award int, desc string)

IncrUserRich 增加或减少用户财富

func (UserRichLogic) Recharge

func (self UserRichLogic) Recharge(ctx context.Context, uid string, form url.Values)

Recharge 用户充值

func (UserRichLogic) Total

func (UserRichLogic) Total(ctx context.Context, uid int) int64

type UserRichObserver

type UserRichObserver struct{}

func (UserRichObserver) Update

func (UserRichObserver) Update(action string, uid, objtype, objid int)

Update 如果是回复,则 objid 是 cid

type UserWeightObserver

type UserWeightObserver struct{}

func (*UserWeightObserver) Update

func (this *UserWeightObserver) Update(action string, uid, objtype, objid int)

type ViewRecordLogic

type ViewRecordLogic struct{}

func (ViewRecordLogic) FindUserNum

func (ViewRecordLogic) FindUserNum(ctx context.Context, objid, objtype int) int64

func (ViewRecordLogic) Record

func (ViewRecordLogic) Record(objid, objtype, uid int)

type ViewSourceLogic

type ViewSourceLogic struct{}

func (ViewSourceLogic) FindOne

func (ViewSourceLogic) FindOne(ctx context.Context, objid, objtype int) *model.ViewSource

FindOne 获得浏览来源

func (ViewSourceLogic) Record

func (ViewSourceLogic) Record(req *http.Request, objtype, objid int)

Record 记录浏览来源

type WechatLogic

type WechatLogic struct{}

func (WechatLogic) AutoReply

func (self WechatLogic) AutoReply(ctx context.Context, reqData []byte) (*model.WechatReply, error)

func (WechatLogic) Bind

func (self WechatLogic) Bind(ctx context.Context, id, uid int, userInfo string) (*model.WechatUser, error)

func (WechatLogic) CheckCaptchaAndActivate

func (self WechatLogic) CheckCaptchaAndActivate(ctx context.Context, me *model.Me, captcha string) error

func (WechatLogic) CheckCaptchaAndBind

func (self WechatLogic) CheckCaptchaAndBind(ctx context.Context, me *model.Me, captcha string) error

func (WechatLogic) CheckSession

func (self WechatLogic) CheckSession(ctx context.Context, code string) (*model.WechatUser, error)

CheckSession 微信小程序登录凭证校验

func (WechatLogic) FetchOrUpdateToken

func (self WechatLogic) FetchOrUpdateToken() (string, error)

type WikiLogic

type WikiLogic struct{}

func (WikiLogic) Create

func (WikiLogic) Create(ctx context.Context, me *model.Me, form url.Values) error

Create 创建一个wiki页面

func (WikiLogic) FindBy

func (WikiLogic) FindBy(ctx context.Context, limit int, lastIds ...int) []*model.Wiki

FindBy 获取 wiki 列表(分页)

func (WikiLogic) FindById

func (WikiLogic) FindById(ctx context.Context, id int) *model.Wiki

FindById 通过ID获取Wiki

func (WikiLogic) FindByIds

func (WikiLogic) FindByIds(ids []int) []*model.Wiki

FindByIds 获取多个wiki页面详细信息

func (WikiLogic) FindOne

func (WikiLogic) FindOne(ctx context.Context, uri string) *model.Wiki

FindOne 某个wiki页面详细信息

func (WikiLogic) Modify

func (self WikiLogic) Modify(ctx context.Context, me *model.Me, form url.Values) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL