Documentation ¶
Overview ¶
处理将磁盘文件记录入数据库的操作
用于查询数据库中的资源
通过文件监控使数据库自适应
orm/mainServer.go 负责数据库读取
TODO: 文章是否可以删除? TODO: 文章的访问权限问题?
Index ¶
- Constants
- func DMAddResources(rs []dm_1.DMResource, status *dm_1.DMTaskStatus) (e error)
- func DMAddResourcesGo(rs []dm_1.DMResource, status *dm_1.DMTaskStatus, goCount int) (e error)
- func DMCheckPermission(accountId int64) (hasPermission bool, er error)
- func DMGetTagIdByName(name string) int64
- func DMIndicateResourceBackupOf(resourceId int64, backupId int64) (e error)
- func DMIndicateResourceBinary(id int64) (e error)
- func DMInsertTag(tag DMTag) error
- func DMIsTagExist(name string) bool
- func DMIsTargetResourceExist(path string) (exist bool, e error)
- func DMNewNotifyFileDb() *dm_1.DMNotifyFile
- func DMTags2Strings(tags []DMTag) (ts []string)
- func GetPostCustomStyleById(id int64) (css string)
- func GetTagIds(tags []string) ([]int64, error)
- func GetTagNames(tagIds []int64) ([]string, error)
- func InitEngine(dbPath string)
- func IsPostFav(id, pid int64) (isFav bool, e error)
- func ModifyPost(id int64, title, text string, owner int64, isPrivate bool, tags []string, ...) error
- func ModifyPostNoText(id int64, title string, owner int64, tags []string) error
- func ModifyPostPath(id int64, path string) error
- func NewAccount(name, email, phone, passwd string) error
- func NewChat(accountId int64, text string, date time.Time) error
- func NewPost(title, text string, owner int64, tags []string, private bool, path string) (int64, error)
- func SetAccountExAvatar(avatar string, id int64) error
- func SetAccountExInfo(info string, id int64) error
- func SetAccountPhone(phone string, id int64) error
- func Sync2Account()
- func Sync2Chat()
- func Sync2DM1()
- func Sync2Post()
- func Sync2VP()
- func VagueSearchPostAndTagName(text string) (ps []PostInfo, tags []Tag, e error)
- type Account
- type AccountEx
- type Chat
- type CountOf
- type DMBackupResource
- type DMTag
- type DMTargetResource
- func DMGetAllMusicResources() (dms []DMTargetResource, e error)
- func DMGetParentResource(parentId int64) (tr *DMTargetResource, er error)
- func DMGetTargetResourceById(id int64) (tr *DMTargetResource, er error)
- func DMGetTargetResourceByPath(path string) (tr *DMTargetResource, e error)
- func DMGetTargetResourcesByTags(tagIds []int64) ([]DMTargetResource, error)
- func GetAllMD5NotComputed() (rs []DMTargetResource, e error)
- func (pR *DMTargetResource) ComputeMD5() error
- func (R DMTargetResource) Decay() (*dm_1.DMResource, error)
- func (PR *DMTargetResource) GetChildResourceBackup() (*DMBackupResource, error)
- func (PR *DMTargetResource) GetChildResourceEx() (ex *DMTargetResourceEx, e error)
- func (R DMTargetResource) GetClones() (rs []DMTargetResource, e error)
- func (R DMTargetResource) Update() (e error)
- type DMTargetResourceEx
- type DMWhiteList
- type HomeInfoModel
- type InfoComponent
- type Post
- type PostInfo
- func GetAllFavPostInfos(id int64) (pis []PostInfo, e error)
- func GetAllPublicPostInfosLimited(start, count int) ([]PostInfo, error)
- func GetPostInfoById(id int64) (PostInfo, error)
- func GetPostInfosAll() ([]PostInfo, error)
- func GetPostInfosByCateDate(id int64, date string) (ps []PostInfo, e error)
- func GetPostInfosByIds(ids []int64) ([]PostInfo, error)
- func GetPostInfosByOwnerAll(OwnerId int64) ([]PostInfo, error)
- func GetPostInfosByOwnerPublic(OwnerId int64) ([]PostInfo, error)
- func GetPostInfosByTags(tags []string) ([]PostInfo, error)
- type PostInfoMono
- type Tag
- type UserSearchResult
- type VPInfoModel
- type VPModel
Constants ¶
View Source
const ( ACCOUNT_LEVEL_ADMIN = "admin" // 网站管理员 ACCOUNT_LEVEL_VIP = "vip" // 网站vip ACCOUNT_LEVEL_NORMAL = "n" // 一般会员 ACCOUNT_LEVEL_UNREGISTERED = "unrgstr" // 还未验证账户 ACCOUNT_LEVEL_TEST = "t" // 测试账户,鸟用没有 TIME_EXPIRE_ONE_MONTH = 2626560 TIME_EXPIRE_ONE_DAY = 87552 )
View Source
const ( DM_PERMISSION_ALL = 0 DM_PERMISSION_GUEST = 1 )
Variables ¶
This section is empty.
Functions ¶
func DMAddResources ¶
func DMAddResources(rs []dm_1.DMResource, status *dm_1.DMTaskStatus) (e error)
当添加一笔数据时,系统将会根据dm1.DMExts自动匹配文件的种类 只要有一笔数据为重复添加的,就会立刻返回错误
func DMAddResourcesGo ¶
func DMAddResourcesGo(rs []dm_1.DMResource, status *dm_1.DMTaskStatus, goCount int) (e error)
弃用 MD5 运算无法使用并发提高速度,因为有读取文件的磁盘速度短板
func DMCheckPermission ¶
用于在API时第一时间进行权限检查 如果是上帝id则会直接通过
func DMGetTagIdByName ¶
func DMIndicateResourceBackupOf ¶
指定某文件为某资源的备份
func DMInsertTag ¶
func DMIsTagExist ¶
func DMIsTargetResourceExist ¶
func DMNewNotifyFileDb ¶
func DMNewNotifyFileDb() *dm_1.DMNotifyFile
func DMTags2Strings ¶
func GetPostCustomStyleById ¶
func GetTagNames ¶
func InitEngine ¶
func InitEngine(dbPath string)
func ModifyPost ¶
func ModifyPost(id int64, title, text string, owner int64, isPrivate bool, tags []string, path string) error
修改文章
func ModifyPostNoText ¶
修改文章,不修改内容 减轻流量负担
func ModifyPostPath ¶
func NewAccount ¶
func NewPost ¶
func NewPost(title, text string, owner int64, tags []string, private bool, path string) (int64, error)
向数据库添加一笔新文章
func SetAccountExAvatar ¶
func SetAccountExInfo ¶
func SetAccountPhone ¶
func Sync2Account ¶
func Sync2Account()
Types ¶
type Account ¶
type Account struct { Id int64 Name string `xorm:"unique"` Email string `xorm:"unique"` Phone string `xorm:"unique"` Passwd string }
账户的基本信息
func GetAccount ¶
func GetAccountByLoginType ¶
func GetAccountByName ¶
type AccountEx ¶
type AccountEx struct { Id int64 AccountId int64 `xorm:"unique"` Avatar string // base64 数据 Info string // 个人简介,markdown数据 Level string // \see ACCOUNT_LEVEL_xxx BgUrl string // 装扮信息 Exp int64 // 等级? PrivateInfoMask string // 用于遮罩哪些信息不可被外部访问 FavPosts []int64 // 收藏文章 SteamId string SteamApi string }
账户的额外信息
func GetAccountEx ¶
type CountOf ¶
上传的文章
func GetOnesAllPostInfoDate ¶
获取某个人的文章日期列表,按月来算。 返回的列表应该形如: key: 2000-1 value: 2 表示在2000的1月有两篇文章
于2020/12/2通过测试
func GetOnesAllPostInfoTags ¶
返回某人拥有的所有tag
func Map2CountOf ¶
type DMBackupResource ¶
type DMBackupResource struct { Id int64 ParentId int64 Description string MD5 string Path string `xorm:"unique"` // 例如:备份一个文件夹,则其中的所有文件都会被该备份资源所备份 BackupTargetIds []int64 }
backup
func DMGetBackupResourceById ¶
func DMGetBackupResourceById(id int64) (bk *DMBackupResource, er error)
func (DMBackupResource) Update ¶
func (R DMBackupResource) Update() (e error)
type DMTargetResource ¶
type DMTargetResource struct { Id int64 Description string MD5 string Path string `xorm:"unique"` TagIds []int64 BackupIdList []int64 ChildGenre string Rating int Dead bool Size int64 }
target
func DMGetAllMusicResources ¶
func DMGetAllMusicResources() (dms []DMTargetResource, e error)
func DMGetParentResource ¶
func DMGetParentResource(parentId int64) (tr *DMTargetResource, er error)
获取某个子资源信息的父资源信息
func DMGetTargetResourceById ¶
func DMGetTargetResourceById(id int64) (tr *DMTargetResource, er error)
func DMGetTargetResourceByPath ¶
func DMGetTargetResourceByPath(path string) (tr *DMTargetResource, e error)
如果不存在则返回nil
func DMGetTargetResourcesByTags ¶
func DMGetTargetResourcesByTags(tagIds []int64) ([]DMTargetResource, error)
func GetAllMD5NotComputed ¶
func GetAllMD5NotComputed() (rs []DMTargetResource, e error)
func (*DMTargetResource) ComputeMD5 ¶
func (pR *DMTargetResource) ComputeMD5() error
func (DMTargetResource) Decay ¶
func (R DMTargetResource) Decay() (*dm_1.DMResource, error)
退化为DMResource 带文件信息
func (*DMTargetResource) GetChildResourceBackup ¶
func (PR *DMTargetResource) GetChildResourceBackup() (*DMBackupResource, error)
func (*DMTargetResource) GetChildResourceEx ¶
func (PR *DMTargetResource) GetChildResourceEx() (ex *DMTargetResourceEx, e error)
func (DMTargetResource) GetClones ¶
func (R DMTargetResource) GetClones() (rs []DMTargetResource, e error)
返回与 R md5相同的资源 包含自身
func (DMTargetResource) Update ¶
func (R DMTargetResource) Update() (e error)
type DMTargetResourceEx ¶
type DMTargetResourceEx struct { Id int64 ParentId int64 `xorm:"unique"` CompatibilityDescription string Commentary string Data string }
func DMGetTargetResourceExById ¶
func DMGetTargetResourceExById(id int64) (ex *DMTargetResourceEx, er error)
func (*DMTargetResourceEx) GetParentResource ¶
func (PR *DMTargetResourceEx) GetParentResource() (p *DMTargetResource, e error)
func (DMTargetResourceEx) Update ¶
func (R DMTargetResourceEx) Update() (e error)
type DMWhiteList ¶
permission
func DMGetWhiteList ¶
func DMGetWhiteList(level int) (wl DMWhiteList, er error)
获取文件管理白名单,返回某一等级的管理权限组 当 wl == {} && e == nil 时表明不存在该权限组
type HomeInfoModel ¶
type HomeInfoModel struct {
Name, Avatar string
PostCount int
// 通过特殊的标题名来进行匹配
Info, Projects, Gears InfoComponent
Id int64
Level string
Exp int64
}
func GetUserHomeInfo ¶
func GetUserHomeInfo(id int64) (him HomeInfoModel, e error)
--------- 账户信息模块 ---------
type InfoComponent ¶
type Post ¶
type Post struct { Id int64 Title string Text string TagIds []int64 OwnerId int64 IsPrivate bool Date string CreateDate string Path string }
上传的文章
func GetPostById ¶
func GetPostsByOwnerPublic ¶
func GetPostsPublicAll ¶
type PostInfo ¶
type PostInfo struct { Id int64 Title string CreateDate string Date string IsPrivate bool OwnerId int64 Path string TagIds []int64 }
上传的文章
func GetAllFavPostInfos ¶
func GetPostInfoById ¶
func GetPostInfosAll ¶
func GetPostInfosByCateDate ¶
func GetPostInfosByIds ¶
func GetPostInfosByOwnerAll ¶
通过某一个人获取所有他的文章 仅通过atk
func GetPostInfosByOwnerPublic ¶
通过某一个人获取所有公开文章
func GetPostInfosByTags ¶
type PostInfoMono ¶
上传的文章
func GetOnesRecentPostTitle ¶
func GetOnesRecentPostTitle(id int64) (titles []PostInfoMono, e error)
最新文章 获取最近的8篇文章标题
type UserSearchResult ¶
func VagueSearchAccountName ¶
func VagueSearchAccountName(text string) (usrs []UserSearchResult, e error)
type VPInfoModel ¶
func VPGetProjectListById ¶
func VPGetProjectListById(id string) (vpis []VPInfoModel, e error)
Click to show internal directories.
Click to hide internal directories.