services

package
v0.0.0-...-b03f85f Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(user *models.User, userdto dto.UserInfoDto) error

func ChangePasswordWithOld

func ChangePasswordWithOld(user *models.User, old string, new string) error

ChangePasswordWithOld 验证旧密码后更新为新密码(兼容历史明文/MD5/bcrypt)

func CreateMessage

func CreateMessage(message *models.Message) error

CreateMessage 发布一条笔记 允许所有注册登陆用户发布信息

func DeleteMessage

func DeleteMessage(id uint, userID uint) error

DeleteMessage 根据 ID 删除笔记

func DeleteMessageByAdmin

func DeleteMessageByAdmin(id uint) error

DeleteMessageByAdmin 管理员删除笔记(无需验证作者)

func FormatContentForCustomHttp

func FormatContentForCustomHttp(content string, images []string) string

FormatContentForCustomHttp 格式化内容以适应自定义HTTP

func FormatContentForFeishu

func FormatContentForFeishu(content string, images []string) string

FormatContentForFeishu 格式化内容以适应飞书

func FormatContentForTelegram

func FormatContentForTelegram(content string, images []string, format string) string

FormatContentForTelegram 格式化内容以适应 Telegram

func FormatContentForTwitter

func FormatContentForTwitter(content string, images []string) string

FormatContentForTwitter 格式化内容以适应 Twitter

func FormatContentForWebhook

func FormatContentForWebhook(content string, images []string) string

FormatContentForWebhook 格式化内容以适应 Webhook

func FormatContentForWework

func FormatContentForWework(content string, images []string) string

FormatContentForWework 格式化内容以适应企业微信

func GenerateRSS

func GenerateRSS(c *gin.Context) (string, error)

func GetAllMessages

func GetAllMessages(showPrivate bool) ([]models.Message, error)

GetAllMessages 封装业务逻辑,获取所有笔记

func GetFrontendConfig

func GetFrontendConfig() (map[string]interface{}, error)

GetFrontendConfig 获取前端配置

func GetMessageByID

func GetMessageByID(id uint, showPrivate bool) (*models.Message, error)

GetMessageByID 根据 ID 获取笔记

func GetMessagePage

func GetMessagePage(id uint) (*models.Message, error)

GetMessagePage 获取消息详情页

func GetMessagesByPage

func GetMessagesByPage(page, pageSize int, userID *uint, isAdmin bool, authorID *uint, username *string) (dto.PageQueryResult, error)

GetMessagesByPage 分页获取笔记(支持作者筛选;管理员查看全部;普通用户可查看公开和自己的私密)

func GetMessagesGroupByDate

func GetMessagesGroupByDate() ([]struct {
	Date  string `json:"date"`
	Count int    `json:"count"`
}, error)

func GetStatus

func GetStatus() (models.Status, error)

func GetUserByID

func GetUserByID(userID uint) (*models.User, error)

func GetUserByUsername

func GetUserByUsername(username string) (*models.User, error)

func GetUserToken

func GetUserToken(userID uint) (string, error)

func IncrementLikeCount

func IncrementLikeCount(messageID uint) (int, error)

IncrementLikeCount 点赞计数加一

func IsUserAdmin

func IsUserAdmin(userID uint) (bool, error)

func Login

func Login(userdto dto.LoginDto) (*models.User, error)

func ProcessMarkdownWithImages

func ProcessMarkdownWithImages(content string, additionalImages []string) string

ProcessMarkdownWithImages 处理 Markdown 内容并将图片链接转换为 HTML 图片标签

func RegenerateUserToken

func RegenerateUserToken(userID uint) (string, error)

func Register

func Register(userdto dto.RegisterDto) error

func RenderMarkdownPreview

func RenderMarkdownPreview(content string) string

RenderMarkdownPreview 将 Markdown 内容转换为预览状态

func SearchMessages

func SearchMessages(keyword string, page, pageSize int, showPrivate bool, authorID *uint, username *string) (dto.PageQueryResult, error)

func SeedDefaultData

func SeedDefaultData() error

SeedDefaultData 初始化默认数据

func StartInfoFeedAutoRefresh

func StartInfoFeedAutoRefresh()

StartInfoFeedAutoRefresh 启动/重建信息流后台定时刷新任务。

func ToggleLike

func ToggleLike(messageID uint, userID *uint, sessionID string) (bool, int, error)

ToggleLike 根据 session 或用户切换点赞状态

func UpdateFrontendSetting

func UpdateFrontendSetting(userID uint, settingMap map[string]interface{}) error

UpdateSetting 更新站点配置

func UpdateMessage

func UpdateMessage(messageID uint, content *string, private *bool) (*models.Message, error)

UpdateMessage 更新消息字段

func UpdateMessagePinned

func UpdateMessagePinned(messageID uint, pinned bool) error

UpdateMessagePinned 更新消息置顶状态

func UpdateUser

func UpdateUser(user *models.User, userdto dto.UserInfoDto) error

func UpdateUserAdmin

func UpdateUserAdmin(userID uint, currentUserID uint) error

func UploadImage

func UploadImage(c *gin.Context) dto.Result[string]

UploadImage 上传图片

Types

type InfoFeedItem

type InfoFeedItem struct {
	Title       string `json:"title"`
	Link        string `json:"link"`
	Content     string `json:"content"`
	Summary     string `json:"summary"`
	ImageURL    string `json:"imageURL"`
	Source      string `json:"source"`
	Type        string `json:"type"`
	Author      string `json:"author"`
	AvatarURL   string `json:"avatarURL"`
	PublishedAt string `json:"publishedAt"`
	Timestamp   int64  `json:"timestamp"`
}

func LoadInfoFeedItems

func LoadInfoFeedItems(limit int) ([]InfoFeedItem, error)

type InfoFeedSource

type InfoFeedSource struct {
	Type    string `json:"type"`
	Group   string `json:"group"`
	Name    string `json:"name"`
	URL     string `json:"url"`
	Enabled bool   `json:"enabled"`
	Visible bool   `json:"visible"`
}

func GetInfoFeedConfig

func GetInfoFeedConfig() (bool, int, []InfoFeedSource, error)

Jump to

Keyboard shortcuts

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