database

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalCache = cache.New(time.Second*30, time.Second*30)

GlobalCache 全局缓存

Functions

func CheckIsAdmin

func CheckIsAdmin(userID string) (isAdmin bool)

CheckIsAdmin 检查是否是管理员

@param userID
@return isAdmin

func FindByCache

func FindByCache[T any](model T) (modelList []T, hitCache bool)

FindByCache 查找缓存

@param model
@return modelList

func FindByCacheFunc

func FindByCacheFunc[T any](model T, keyFunc func(T) string) (res []T, hitCache bool)

FindByCacheFunc 查找缓存

@param model T
@param f func(T) string
@return modelList []T
@return hitCache bool
@author heyuhengmatt
@update 2024-07-17 06:36:14

func FindFuncNoCache

func FindFuncNoCache[T any](model T) (res []T)

func GetAdminLevel

func GetAdminLevel(userID string) int

GetAdminLevel 获取管理员等级

@param userID
@return level

func GetDbConnection

func GetDbConnection() *gorm.DB

GetDbConnection returns the db connection

@return *gorm.DB

Types

type Administrator

type Administrator struct {
	gorm.Model
	UserID   int64  `json:"user_id" gorm:"primaryKey"`
	UserName string `json:"user_name"`
	Level    int64  `json:"level"`
}

Administrator is the struct of administrator

type AlertList

type AlertList struct {
	EmailAddress string
}

AlertList is the struct of alert config

type ChannelLogExt

type ChannelLogExt struct {
	UserID      string `json:"user_id" gorm:"primaryKey"`
	UserName    string `json:"user_name"`
	ChannelID   string `json:"channel_id" gorm:"primaryKey"`
	ChannelName string `json:"channel_name"`
	JoinedTime  string `json:"joined_time" gorm:"primaryKey"`
	LeftTime    string `json:"left_time"`
	ISUpdate    bool   `json:"is_update"`
	MsgID       string `json:"msg_id"`
	GuildID     string `json:"guild_id" `
}

ChannelLogExt is the struct of channel log

func (*ChannelLogExt) AddJoinedRecord

func (cl *ChannelLogExt) AddJoinedRecord() error

AddJoinedRecord 添加加入记录

@receiver cl
@return error

func (*ChannelLogExt) UpdateLeftTime

func (cl *ChannelLogExt) UpdateLeftTime() (newChanLog *ChannelLogExt, err error)

UpdateLeftTime 更新离开时间

@receiver cl
@return error

type ChatContextRecord

type ChatContextRecord struct {
	UserID    string `json:"user_id"`
	SessionID string `json:"session_id"`
}

ChatContextRecord is

type ChatRecordLog

type ChatRecordLog struct {
	AuthorID  string `json:"user_id" gorm:"primaryKey"`
	RecordStr string `json:"record_str"`
}

ChatRecordLog 存储chat的对话记录

type CommandInfo

type CommandInfo struct {
	CommandName     string    `json:"command_name" gorm:"primaryKey;autoIncrement:false"`
	CommandDesc     string    `json:"command_desc"`
	CommandParamLen int       `json:"command_param_len"`
	CommandType     string    `json:"command_type"`
	CreatedAt       time.Time `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt       time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}

CommandInfo is the struct of command info

func GetCommandInfo

func GetCommandInfo(command string) (commandInfoList []*CommandInfo, err error)

GetCommandInfo 获取命令信息

@param command
@return info

func GetCommandInfoWithOpt

func GetCommandInfoWithOpt(optionf string) (commandInfoList []*CommandInfo, err error)

GetCommandInfoWithOpt 获取命令信息

@param option
@return info

type CopyWritingCustom

type CopyWritingCustom struct {
	Endpoint string         `json:"endpoint" gorm:"primaryKey;autoIncrement:false"`
	GuildID  string         `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
	Content  pq.StringArray `gorm:"type:text[]" json:"content"`
}

type CopyWritingGeneral

type CopyWritingGeneral struct {
	Endpoint string         `json:"endpoint" gorm:"primaryKey;autoIncrement:false"`
	Content  pq.StringArray `gorm:"type:text[]" json:"content"`
}

type DynamicConfig

type DynamicConfig struct {
	Key   string `json:"key" gorm:"primaryKey"`
	Value string `json:"value" gorm:"primaryKey"`
}

DynamicConfig is the struct of dynamic command info

type FunctionEnabling

type FunctionEnabling struct {
	GuildID  string                  `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
	Function consts.LarkFunctionEnum `json:"function" gorm:"primaryKey;autoIncrement:false"`
}

type General

type General struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type GeneralConf

type GeneralConf struct {
	General
	ConfigKey string `json:"config_key" gorm:"primaryKey;index"`
	ConfigVar string `json:"config_var"`
}

type ImitateRateCustom

type ImitateRateCustom struct {
	General
	GuildID string `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
	Rate    int    `json:"rate"`
}

type InteractionStats

type InteractionStats struct {
	OpenID     string                 `json:"open_id" gorm:"index"`
	GuildID    string                 `json:"guild_id" gorm:"index"`
	UserName   string                 `json:"user_name"`
	ActionType consts.LarkInteraction `json:"action_type" gorm:"index"`
	CreatedAt  time.Time
}

type LarkImg

type LarkImg struct {
	gorm.Model
	SongID string `json:"song_id" gorm:"primaryKey;autoIncrement:false"`
	ImgKey string `json:"img_key" gorm:"primaryKey;autoIncrement:false"`
}

LarkImg is

type MsgTraceLog

type MsgTraceLog struct {
	MsgID     string `json:"msg_id" gorm:"index"`
	TraceID   string `json:"trace_id"`
	CreatedAt time.Time
}

type PromptConf

type PromptConf struct {
	General
	PromptKey       string `json:"prompt_key" gorm:"primaryKey;index"`
	SystemPromptTpl string `json:"system_prompt_tpl"`
	UserPromptTpl   string `json:"user_prompt_tpl"`
}

type PromptTemplateArgs

type PromptTemplateArgs struct {
	PromptID       int      `json:"prompt_id" gorm:"primaryKey;autoIncrement:false"`
	TemplateStr    string   `json:"template_str"`
	Task           string   `json:"task"`
	HistoryRecords []string `json:"history_records" gorm:"-"`
	Constraints    string   `json:"constraints"`
	UserInput      []string `json:"user_input" gorm:"-"`
}

type QuoteReplyMsg

type QuoteReplyMsg struct {
	MatchType consts.WordMatchType `json:"match_type" gorm:"primaryKey;index;default:substr"`
	Keyword   string               `json:"keyword" gorm:"primaryKey;index"`
	ReplyNType
}

type QuoteReplyMsgCustom

type QuoteReplyMsgCustom struct {
	GuildID   string               `json:"guil d_id" gorm:"primaryKey;index"`
	MatchType consts.WordMatchType `json:"match_type" gorm:"primaryKey;index;default:substr"`
	Keyword   string               `json:"keyword" gorm:"primaryKey;index"`
	ReplyNType
}

type ReactImageMeterial

type ReactImageMeterial struct {
	GuildID string `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
	FileID  string `json:"file_id" gorm:"primaryKey;autoIncrement:false"`
	Type    string `json:"type"`
}

type ReactionWhitelist

type ReactionWhitelist struct {
	GuildID string `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
}

type RepeatWhitelist

type RepeatWhitelist struct {
	GuildID string `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
}

type RepeatWordsRate

type RepeatWordsRate struct {
	General
	Word string `json:"word" gorm:"primaryKey;autoIncrement:false"`
	Rate int    `json:"rate"`
}

type RepeatWordsRateCustom

type RepeatWordsRateCustom struct {
	General
	GuildID string `json:"guild_id" gorm:"primaryKey;autoIncrement:false"`
	Word    string `json:"word" gorm:"primaryKey;autoIncrement:false"`
	Rate    int    `json:"rate"`
}

type ReplyNType

type ReplyNType struct {
	Reply     string           `json:"reply" gorm:"primaryKey;index"`
	ReplyType consts.ReplyType `json:"reply_type" gorm:"primaryKey;index;default:text"`
}

type StickerMapping

type StickerMapping struct {
	General
	StickerKey string `json:"sticker_key" gorm:"primaryKey;autoIncrement:false;index"`
	ImageKey   string `json:"image_key" gorm:"index"`
}

type TemplateVersion

type TemplateVersion struct {
	TemplateID      string `json:"template_id" gorm:"primaryKey;autoIncrement:false"`
	TemplateVersion string `json:"template_version"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
	TemplateSrc     string `json:"template_src"`
}

Jump to

Keyboard shortcuts

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