domain

package
v0.0.0-...-84e4fc3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSession

func DeleteSession(session *Session)

DeleteSession 删除会话

func DeleteUserSession

func DeleteUserSession(userid string)

DeleteUserSession 删除某用户所有会话

func EditPage

func EditPage(id, name, header, body, footer string, siteID *primitive.ObjectID) error

EditPage 修改页面

func NewBBS

func NewBBS(name, parentID, description string, siteID primitive.ObjectID) error

NewBBS 新论坛

func NewOnlineActive

func NewOnlineActive(siteid primitive.ObjectID, ua, clientIP string, session *Session)

NewOnlineActive 在线活动

func NewPage

func NewPage(name, header, body, footer, alias string, siteID *primitive.ObjectID) error

NewPage 新页面

func NewResource

func NewResource(name, contentType, raw string) error

NewResource 新资源文件

Types

type Article

type Article struct {
	ID         primitive.ObjectID `bson:"_id"`
	Title      string
	Content    string
	CreateTime time.Time
	Author     *Session
	Replies    []*ArticleReply
	ViewCount  int64
}

Article 文章

func NewArticle

func NewArticle(title, content string, session *Session) (*Article, error)

NewArticle 新文章

func (*Article) NewReply

func (article *Article) NewReply(content, userAgent string, session *Session) error

NewReply 新回复

type ArticleReply

type ArticleReply struct {
	ID         primitive.ObjectID `bson:"_id"`
	Content    string
	CreateTime time.Time
	UserAgent  string
	Author     *Session
}

ArticleReply 文章回复

type BBS

type BBS struct {
	ID          primitive.ObjectID `bson:"_id"`
	SiteID      primitive.ObjectID
	Name        string
	ParentID    *primitive.ObjectID
	BBSContexts []*BBSContext
	Description string
	CreateTime  time.Time
	Stats       *Stats
}

BBS 论坛

func LoadBBSByID

func LoadBBSByID(id string) (*BBS, error)

LoadBBSByID LoadBBS

func LoadSiteBBS

func LoadSiteBBS(siteID primitive.ObjectID) ([]*BBS, error)

LoadSiteBBS 获取所有BBS

func (*BBS) NewThread

func (bbs *BBS) NewThread(title, content, alias, ua string, session *Session) (*Thread, error)

NewThread 新帖子

func (*BBS) Subs

func (bbs *BBS) Subs() []*BBS

Subs 子版块

type BBSContext

type BBSContext struct {
	ID   primitive.ObjectID `bson:"_id"`
	Name string
}

BBSContext 版块上下文

type File

type File struct {
	Name       string
	URI        string
	CreateTime time.Time
	UsedBy     interface{}
}

File 用户上传的附件

type Online

type Online struct {
	SiteID         primitive.ObjectID
	User           *Session
	UserAgent      string
	LastActiveTime time.Time
	IP             string
}

Online 在线用户

func LoadOnline

func LoadOnline(siteid, userid primitive.ObjectID) (*Online, error)

LoadOnline 加载在线用户

func LoadOnlines

func LoadOnlines(siteid primitive.ObjectID) ([]*Online, error)

LoadOnlines 在线用户

type OnlineObj

type OnlineObj struct {
	Duration       int64
	LastActiveTime time.Time
}

OnlineObj 在线时长对象

type Page

type Page struct {
	ID         primitive.ObjectID `bson:"_id"`
	SiteID     primitive.ObjectID
	Alias      string
	Name       string
	SysPage    bool
	Body       template.HTML
	Header     template.HTML
	Footer     template.HTML
	CreateTime time.Time
}

Page Site Pages

func LoadPageByAlias

func LoadPageByAlias(siteID primitive.ObjectID, alias string) (*Page, error)

LoadPageByAlias 按别名加载站点页面

func LoadPageByID

func LoadPageByID(id string) (*Page, error)

LoadPageByID 按ID加载页面

func LoadPages

func LoadPages(siteID primitive.ObjectID) ([]*Page, error)

LoadPages 站点所有页面

func (*Page) Delete

func (page *Page) Delete() error

Delete 删除页面

type Reply

type Reply struct {
	ID         primitive.ObjectID `bson:"_id"`
	Content    string
	CreateTime time.Time
	Author     *Session
	UserAgent  string
}

Reply 帖子回复

type Resource

type Resource struct {
	ID          primitive.ObjectID `bson:"_id"`
	Name        string
	ContentType string
	Raw         []byte
	Etag        string
}

Resource 资源

func LoadResource

func LoadResource(resourceName string) (*Resource, error)

LoadResource 加载资源

func LoadResourceByID

func LoadResourceByID(id string) (*Resource, error)

LoadResourceByID 加载资源

func LoadResources

func LoadResources() ([]*Resource, error)

LoadResources 加载所有资源

func (*Resource) RawString

func (r *Resource) RawString() string

RawString RawString

func (*Resource) UpdateRaw

func (r *Resource) UpdateRaw(rawString string) error

UpdateRaw UpdateRaw

type Session

type Session struct {
	SID        string
	Name       string
	Avatar     string
	Email      string
	UserID     string
	Active     bool
	CreateTime time.Time
}

Session 用户会话

func LoadSession

func LoadSession(sessionID string) (*Session, error)

LoadSession 加载会话

func NewSession

func NewSession(user *User) (*Session, error)

NewSession 新会话

type Site

type Site struct {
	ID         primitive.ObjectID `bson:"_id"`
	Name       string
	User       *User
	Main       bool
	Hosts      []string
	CreateTime time.Time
	Themes     []*Theme
	Footer     template.HTML
	Header     template.HTML
}

Site 站点

func LoadLatestSites

func LoadLatestSites(size int64) ([]*Site, error)

LoadLatestSites 最新的站点

func LoadSiteByHost

func LoadSiteByHost(host string) (*Site, error)

LoadSiteByHost 按Host加载站点

func LoadSiteByID

func LoadSiteByID(siteID string) (*Site, error)

LoadSiteByID 按站点ID加载

func NewSite

func NewSite(name, host string) (*Site, error)

NewSite 新站点

func NewSiteBundleUser

func NewSiteBundleUser(name, host string, user *User) (*Site, error)

NewSiteBundleUser 新站点并绑定用户

func (*Site) BundleUser

func (site *Site) BundleUser(userID string) error

BundleUser 绑定用户

func (*Site) Editable

func (site *Site) Editable(session *Session) bool

Editable 是否可编辑

func (*Site) Init

func (site *Site) Init(mainSite *Site) error

Init 初始化站点

func (*Site) Update

func (site *Site) Update(name, header, footer string) error

Update 更新

func (*Site) UpdatePkiValidation

func (site *Site) UpdatePkiValidation(host, fileauth string) error

UpdatePkiValidation 更新PkiValidation

type SiteExtra

type SiteExtra struct {
	SiteID         primitive.ObjectID
	PkiValidations *map[string]string
}

SiteExtra 站点额外信息

func LoadSiteExtra

func LoadSiteExtra(siteid primitive.ObjectID) (*SiteExtra, error)

LoadSiteExtra 加载站点额外信息

type Stats

type Stats struct {
	ThreadCount int64
	ReplyCount  int64
}

Stats 论坛统计

type Theme

type Theme struct {
	Name      string
	GlobalCSS []byte
	GlobalJS  []byte
	Enabled   bool
}

Theme 主题

type Thread

type Thread struct {
	ID             primitive.ObjectID `bson:"_id"`
	SiteID         primitive.ObjectID
	BBSID          primitive.ObjectID
	BBSContexts    []*BBSContext
	Title          string
	Alias          string
	Author         *Session
	UserAgent      string
	Content        string
	CreateTime     time.Time
	LastActiveTime time.Time
	ViewCount      int64
	GoodCount      int64
	GoodUsers      []*Session
	Replies        []*Reply
}

Thread 帖子

func LoadThreadByAlias

func LoadThreadByAlias(alias string) (*Thread, error)

LoadThreadByAlias 按别名获取帖子

func LoadThreadByID

func LoadThreadByID(id string) (*Thread, error)

LoadThreadByID 按ID获取帖子

func LoadThreadsByBBSID

func LoadThreadsByBBSID(siteID primitive.ObjectID, bbsID primitive.ObjectID, page, size int64) ([]*Thread, error)

LoadThreadsByBBSID LoadThreadsByBBSID

func LoadThreadsByFilterAndOptions

func LoadThreadsByFilterAndOptions(siteID primitive.ObjectID, size int64, filter *bson.M, options *options.FindOptions) ([]*Thread, error)

LoadThreadsByFilterAndOptions 按Filter查询帖子

func (*Thread) Good

func (t *Thread) Good(session *Session) error

Good 点赞

func (*Thread) IncViewCount

func (t *Thread) IncViewCount()

IncViewCount 增长浏览数

func (*Thread) NewReply

func (t *Thread) NewReply(content, ua string, session *Session) error

NewReply 新回复

type User

type User struct {
	ID             primitive.ObjectID `bson:"_id"`
	SiteID         primitive.ObjectID
	Name           string
	Password       string
	Avatar         string
	Phone          string
	Email          string
	CreateTime     time.Time
	Coins          *map[string]int64
	OnlineDuration *map[string]*OnlineObj
	Active         bool
	ActiveToken    string
}

User 用户

func LoadUserByActiveToken

func LoadUserByActiveToken(token string) (*User, error)

LoadUserByActiveToken 按激活码加载用户

func LoadUserByEmail

func LoadUserByEmail(email string) (*User, error)

LoadUserByEmail 按邮件加载用户

func LoadUserByID

func LoadUserByID(userID string) (*User, error)

LoadUserByID 按ID加载用户

func LoadUserByLoginID

func LoadUserByLoginID(user string) (*User, error)

LoadUserByLoginID 按登录ID加载

func LoadUserByName

func LoadUserByName(name string) (*User, error)

LoadUserByName 按Name加载用户

func NewActivedUser

func NewActivedUser(name, email, phone, password string, coin int64, createTime time.Time, siteID primitive.ObjectID) (*User, error)

NewActivedUser 新用户(更多初始化信息)

func NewUser

func NewUser(name, email, password string, siteID primitive.ObjectID) (*User, error)

NewUser 新用户

func (*User) ActiveAccount

func (u *User) ActiveAccount() error

ActiveAccount 激活

func (*User) ChangePassword

func (u *User) ChangePassword(passwd string) error

ChangePassword 更改密码

func (*User) NewActiveToken

func (u *User) NewActiveToken() error

NewActiveToken 新验证Token

Jump to

Keyboard shortcuts

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