services

package
v0.0.0-...-fcb87a8 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package services 服务

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptchaService

type CaptchaService struct {
}

CaptchaService 验证码服务

func (*CaptchaService) BuildImage

func (*CaptchaService) BuildImage(width, height, textLength int) ([]byte, string, error)

BuildImage 生成验证码

func (*CaptchaService) CheckCaptchaAnswer

func (*CaptchaService) CheckCaptchaAnswer(session *models.Session, answer string) bool

CheckCaptchaAnswer 判断验证码与session中保存的是否相同(不区分大小写)

func (*CaptchaService) SetCaptchaAnswer

func (*CaptchaService) SetCaptchaAnswer(session *models.Session, answer string)

SetCaptchaAnswer 将验证码写入session

type CounterService

type CounterService struct {
}

CounterService 计数器服务

func (*CounterService) Increment

func (s *CounterService) Increment(ctx context.Context, itemKey string) (int64, error)

Increment 增加计数器的值

func (*CounterService) InsertWithIncrement

func (s *CounterService) InsertWithIncrement(ctx context.Context, coll *mongo.Collection, counterKey string, itemInfo IncrementItem) error

InsertWithIncrement 插入document,并设置自增ID

type ForumRewardRuleService

type ForumRewardRuleService struct {
}

ForumRewardRuleService 板块奖励规则服务

func (*ForumRewardRuleService) InsertForumRewardRule

func (s *ForumRewardRuleService) InsertForumRewardRule(itemInfo *models.ForumRewardRule) error

InsertForumRewardRule 插入新的规则

type ForumService

type ForumService struct {
}

ForumService 板块奖励规则服务

func (*ForumService) InsertForum

func (s *ForumService) InsertForum(itemInfo *models.Forum) error

InsertForum 插入新的板块

type ForumTreeService

type ForumTreeService struct {
}

ForumTreeService 板块结构树服务

func (*ForumTreeService) InsertForumTree

func (s *ForumTreeService) InsertForumTree(itemInfo *models.ForumTree) error

InsertForumTree 插入新的板块结构树

type ForumZoneService

type ForumZoneService struct {
}

ForumZoneService 板块分区服务

func (*ForumZoneService) InsertForumZone

func (s *ForumZoneService) InsertForumZone(itemInfo *models.ForumZone) error

InsertForumZone 插入新的分区

type GroupUserService

type GroupUserService struct {
}

GroupUserService 组用户记录服务

func (*GroupUserService) InsertGroupUser

func (s *GroupUserService) InsertGroupUser(itemInfo *models.GroupUser) error

InsertGroupUser 插入新的组用户记录

type IncrementItem

type IncrementItem interface {
	// SetID 设置ID
	SetID(value int64)
}

IncrementItem 可以设置自增ID的文档

type MigrateService

type MigrateService struct {
}

MigrateService 处理数据迁移

func (*MigrateService) AllMigrations

func (m *MigrateService) AllMigrations() []common.Migration

AllMigrations 所有的迁移定义

func (*MigrateService) RunMigrate

func (m *MigrateService) RunMigrate(stepLimit int) (int, error)

RunMigrate 执行迁移,返回本次执行的迁移数量

func (*MigrateService) RunRollback

func (m *MigrateService) RunRollback(stepLimit int) (int, error)

RunRollback 执行回滚,返回本次执行回滚的数量, 如果`stepLimit`>0则只回滚指定数量的迁移, 如果`stepLimit`<=0则回滚最后一批迁移

func (*MigrateService) RunRollbackAll

func (m *MigrateService) RunRollbackAll() (int, error)

RunRollbackAll 回滚所有的迁移,返回本次执行回滚的数量

type SessionService

type SessionService struct {
}

SessionService 会话功能

func (*SessionService) CheckClient

func (s *SessionService) CheckClient(c *fiber.Ctx, requireLogin bool) (*models.Session, *common.APIError)

CheckClient 检测客户端会话状态

func (*SessionService) DestroySession

func (s *SessionService) DestroySession(item *models.Session) error

DestroySession 销毁会话

func (*SessionService) LoadFromContext

func (s *SessionService) LoadFromContext(c *fiber.Ctx) (*models.Session, *common.APIError)

LoadFromContext 从客户端请求中加载会话

func (*SessionService) LoadSession

func (s *SessionService) LoadSession(sessionID string) (*models.Session, *common.APIError)

LoadSession 使用会话ID从数据库中加载会话

func (*SessionService) LoginUser

func (s *SessionService) LoginUser(session *models.Session, userID int64, duration time.Duration)

LoginUser 登录用户

func (*SessionService) NewSession

func (s *SessionService) NewSession() (*models.Session, error)

NewSession 创建一个新的会话对象,设置随机生成的ID

func (*SessionService) SaveSession

func (s *SessionService) SaveSession(item *models.Session) error

SaveSession 保存会话到数据库

type UserService

type UserService struct {
}

UserService 用户功能

func (*UserService) FindUserByID

func (s *UserService) FindUserByID(userID int64) (*models.User, error)

FindUserByID 根据用户ID查找用户

func (*UserService) FindUserByNickname

func (s *UserService) FindUserByNickname(nickname string) (*models.User, error)

FindUserByNickname 根据昵称查找用户

func (*UserService) FindUserByUsername

func (s *UserService) FindUserByUsername(username string) (*models.User, error)

FindUserByUsername 根据用户名查找用户

func (*UserService) InsertUser

func (s *UserService) InsertUser(itemInfo *models.User) error

InsertUser 插入新用户

Jump to

Keyboard shortcuts

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