Documentation
¶
Index ¶
- func WithResumeInput(input string) einotool.Option
- type AuthService
- func (s *AuthService) AdminLogin(ctx context.Context, phone, password, userAgent string) (*response.WechatLoginResponse, error)
- func (s *AuthService) BanUser(ctx context.Context, operatorUserID, targetUserID uint, durationSeconds int64, ...) (int, error)
- func (s *AuthService) GetUserAuthDetail(ctx context.Context, userID uint) (*response.UserAuthDetailResponse, error)
- func (s *AuthService) GetUserByID(ctx context.Context, userID uint) (*models.User, error)
- func (s *AuthService) GetUserSessions(ctx context.Context, userID uint, currentSID string) ([]response.AuthSessionSummary, error)
- func (s *AuthService) KickUser(ctx context.Context, operatorUserID, targetUserID uint) (int, error)
- func (s *AuthService) Logout(ctx context.Context, userID uint, sid string) error
- func (s *AuthService) LogoutAll(ctx context.Context, userID uint) (int, error)
- func (s *AuthService) MockWechatLogin(ctx context.Context, testUser, userAgent string) (*response.WechatLoginResponse, error)
- func (s *AuthService) RefreshToken(ctx context.Context, refreshTokenString, userAgent string) (*response.WechatLoginResponse, error)
- func (s *AuthService) SetAdminLoginCredentials(ctx context.Context, operatorUserID, targetUserID uint, phone, password string) error
- func (s *AuthService) UnbanUser(ctx context.Context, operatorUserID, targetUserID uint) error
- func (s *AuthService) UpdateUserProfile(ctx context.Context, userID uint, updates map[string]any) error
- func (s *AuthService) WechatLogin(ctx context.Context, code, userAgent string) (*response.WechatLoginResponse, error)
- type ChatService
- func (s *ChatService) AppendMessages(ctx context.Context, userID, conversationID uint, checkpointID string, ...) error
- func (s *ChatService) CreateConversation(ctx context.Context, userID uint, title string) (*models.Conversation, error)
- func (s *ChatService) DeleteConversation(ctx context.Context, userID, conversationID uint) error
- func (s *ChatService) ExportConversation(ctx context.Context, userID, conversationID uint) (*models.Conversation, []*schema.Message, error)
- func (s *ChatService) GenerateTitleFromFirstMessage(ctx context.Context, content string) (string, error)
- func (s *ChatService) GetConversation(ctx context.Context, userID, conversationID uint) (*models.Conversation, error)
- func (s *ChatService) GetMessages(ctx context.Context, userID, conversationID uint) ([]*schema.Message, error)
- func (s *ChatService) ListConversations(ctx context.Context, userID uint, page, pageSize int) ([]models.Conversation, int64, error)
- func (s *ChatService) StreamChat(ctx context.Context, userID, conversationID uint, newMessage *schema.Message, ...) (<-chan string, <-chan error, error)
- func (s *ChatService) UpdateConversation(ctx context.Context, userID, conversationID uint, title string) error
- type ConfigService
- func (s *ConfigService) Create(ctx context.Context, key, value, valueType, description string) (*models.SystemConfig, error)
- func (s *ConfigService) Delete(ctx context.Context, key string) error
- func (s *ConfigService) GetByKey(ctx context.Context, key string) (*models.SystemConfig, error)
- func (s *ConfigService) SearchConfigs(ctx context.Context, query string, page, size int) ([]models.SystemConfig, int64, error)
- func (s *ConfigService) Update(ctx context.Context, key, value, valueType string, description *string) error
- type ContributionService
- func (s *ContributionService) CreateContribution(ctx context.Context, userID uint, req *request.CreateContributionRequest) error
- func (s *ContributionService) GetAdminContributionStats(ctx context.Context) (*response.AdminContributionStatsResponse, error)
- func (s *ContributionService) GetContributionByID(ctx context.Context, contributionID uint, userID uint) (*response.ContributionResponse, error)
- func (s *ContributionService) GetContributions(ctx context.Context, userID uint, req *request.GetContributionsRequest) (*response.PageResponse, error)
- func (s *ContributionService) GetUserContributionStats(ctx context.Context, userID uint) (map[string]interface{}, error)
- func (s *ContributionService) ReviewContribution(ctx context.Context, contributionID uint, reviewerID uint, ...) error
- type CountdownService
- func (s *CountdownService) CreateCountdown(ctx context.Context, userID uint, req *request.CreateCountdownRequest) (*response.CountdownResponse, error)
- func (s *CountdownService) DeleteCountdown(ctx context.Context, countdownID uint, userID uint) error
- func (s *CountdownService) GetCountdownByID(ctx context.Context, countdownID uint, userID uint) (*response.CountdownResponse, error)
- func (s *CountdownService) GetCountdowns(ctx context.Context, userID uint) ([]response.CountdownResponse, error)
- func (s *CountdownService) UpdateCountdown(ctx context.Context, countdownID uint, userID uint, ...) (*response.CountdownResponse, error)
- type CourseTableService
- func (s *CourseTableService) CreateAdminCourseTable(ctx context.Context, req *request.AdminCreateCourseTableRequest) (*response.AdminCourseTableResponse, error)
- func (s *CourseTableService) DeleteAdminCourseTable(ctx context.Context, id uint) error
- func (s *CourseTableService) EditUserCourseCell(ctx context.Context, userID uint, semester string, index string, ...) error
- func (s *CourseTableService) GetAdminCourseTableByID(ctx context.Context, id uint) (*response.AdminCourseTableResponse, error)
- func (s *CourseTableService) GetUserBindCount(ctx context.Context, userID uint) (int, error)
- func (s *CourseTableService) GetUserCourseTable(ctx context.Context, userID uint, semester string) (*response.CourseTableResponse, error)
- func (s *CourseTableService) GetUserCourseTableWithVersion(ctx context.Context, userID uint, semester string, clientLastModified *int64) (*response.CourseTableResponse, error)
- func (s *CourseTableService) ListAdminCourseTables(ctx context.Context, req *request.AdminListCourseTablesRequest) ([]response.AdminCourseTableResponse, int64, error)
- func (s *CourseTableService) ResetUserBindCount(ctx context.Context, targetUserID uint) error
- func (s *CourseTableService) ResetUserBindCountToOne(ctx context.Context, targetUserID uint) error
- func (s *CourseTableService) ResetUserSchedule(ctx context.Context, userID uint, semester string) error
- func (s *CourseTableService) SearchClasses(ctx context.Context, keyword string, page, size int) (*response.SearchClassResponse, error)
- func (s *CourseTableService) UpdateAdminCourseTable(ctx context.Context, id uint, req *request.AdminUpdateCourseTableRequest) (*response.AdminCourseTableResponse, error)
- func (s *CourseTableService) UpdateUserClass(ctx context.Context, userID uint, classID string) (err error)
- type DictionaryService
- type FailRateService
- func (s *FailRateService) CreateAdminFailRate(ctx context.Context, req *request.AdminCreateFailRateRequest) (*response.AdminFailRateResponse, error)
- func (s *FailRateService) DeleteAdminFailRate(ctx context.Context, id uint) error
- func (s *FailRateService) GetAdminFailRateByID(ctx context.Context, id uint) (*response.AdminFailRateResponse, error)
- func (s *FailRateService) ListAdminFailRates(ctx context.Context, req *request.AdminListFailRatesRequest) ([]response.AdminFailRateResponse, int64, error)
- func (s *FailRateService) Rand(ctx context.Context, limit int) ([]models.FailRate, error)
- func (s *FailRateService) Search(ctx context.Context, keyword string, page, size int) ([]models.FailRate, int64, error)
- func (s *FailRateService) UpdateAdminFailRate(ctx context.Context, id uint, req *request.AdminUpdateFailRateRequest) (*response.AdminFailRateResponse, error)
- type FeatureService
- func (s *FeatureService) BatchGrantFeatureToUsers(ctx context.Context, userIDs []uint, featureKey string) error
- func (s *FeatureService) CheckUserFeature(ctx context.Context, userID uint, featureKey string) (bool, error)
- func (s *FeatureService) CreateFeature(ctx context.Context, feature *models.Feature) error
- func (s *FeatureService) DB() *gorm.DB
- func (s *FeatureService) DeleteFeature(ctx context.Context, featureKey string) error
- func (s *FeatureService) GetEnabledProjectFeatures(ctx context.Context) (map[string]bool, error)
- func (s *FeatureService) GetFeature(ctx context.Context, featureKey string) (*models.Feature, error)
- func (s *FeatureService) GetRoleIDsByFeature(ctx context.Context, featureKey string) ([]uint, error)
- func (s *FeatureService) GetUserFeatures(ctx context.Context, userID uint) ([]string, error)
- func (s *FeatureService) GetUserIDsByFeature(ctx context.Context, featureKey string) ([]uint, error)
- func (s *FeatureService) GrantFeatureToUser(ctx context.Context, userID uint, featureKey string) error
- func (s *FeatureService) GrantRoleToFeature(ctx context.Context, featureKey string, roleID uint) error
- func (s *FeatureService) IsFeatureEnabled(ctx context.Context, featureKey string) (bool, error)
- func (s *FeatureService) ListFeatures(ctx context.Context) ([]models.Feature, error)
- func (s *FeatureService) RevokeFeatureFromUser(ctx context.Context, userID uint, featureKey string) error
- func (s *FeatureService) RevokeRoleFromFeature(ctx context.Context, featureKey string, roleID uint) error
- func (s *FeatureService) SetFeatureRoles(ctx context.Context, featureKey string, roleIDs []uint) error
- func (s *FeatureService) UpdateFeature(ctx context.Context, featureKey string, updates map[string]interface{}) error
- type GPABackupService
- func (s *GPABackupService) CreateBackup(ctx context.Context, userID uint, title string, rawData []byte) (*response.GPABackupResponse, error)
- func (s *GPABackupService) DeleteBackup(ctx context.Context, userID, backupID uint) error
- func (s *GPABackupService) GetBackupByID(ctx context.Context, userID, backupID uint) (*response.GPABackupResponse, error)
- func (s *GPABackupService) ListBackups(ctx context.Context, userID uint) ([]response.GPABackupResponse, error)
- type HeroService
- func (s *HeroService) Create(ctx context.Context, name string, sort int, isShow bool) (*models.Hero, error)
- func (s *HeroService) Delete(ctx context.Context, id uint) error
- func (s *HeroService) Get(ctx context.Context, id uint) (*models.Hero, error)
- func (s *HeroService) ListAll(ctx context.Context) ([]string, error)
- func (s *HeroService) SearchHeroes(ctx context.Context, query string, isShow *bool, page, size int) ([]models.Hero, int64, error)
- func (s *HeroService) Update(ctx context.Context, id uint, name string, sort *int, isShow *bool) error
- type MaterialService
- func (s *MaterialService) CalculateHotness(ctx context.Context) error
- func (s *MaterialService) CreateMaterialLog(ctx context.Context, userID uint, req *request.MaterialLogCreateRequest) error
- func (s *MaterialService) DeleteMaterial(ctx context.Context, md5 string) error
- func (s *MaterialService) GetCategoriesByParent(ctx context.Context, parentID *uint) ([]response.MaterialCategoryResponse, error)
- func (s *MaterialService) GetHotWords(ctx context.Context, limit int) ([]response.HotWordsResponse, error)
- func (s *MaterialService) GetMaterialByMD5(ctx context.Context, md5 string, userID *uint) (*response.MaterialDetailResponse, error)
- func (s *MaterialService) GetMaterialDesc(ctx context.Context, md5 string) (*response.MaterialDescResponse, error)
- func (s *MaterialService) GetMaterialList(ctx context.Context, req *request.MaterialListRequest) ([]response.MaterialListResponse, int64, error)
- func (s *MaterialService) GetTopMaterials(ctx context.Context, req *request.TopMaterialsRequest) ([]response.MaterialListResponse, error)
- func (s *MaterialService) RateMaterial(ctx context.Context, userID uint, md5 string, rating int) error
- func (s *MaterialService) SearchMaterials(ctx context.Context, req *request.MaterialSearchRequest) (*response.MaterialSearchResponse, error)
- func (s *MaterialService) UpdateMaterialDesc(ctx context.Context, md5 string, req *request.MaterialDescUpdateRequest) error
- type NotificationService
- func (s *NotificationService) ApproveNotification(ctx context.Context, notificationID uint, reviewerID uint, ...) error
- func (s *NotificationService) ConvertToSchedule(ctx context.Context, notificationID uint, ...) error
- func (s *NotificationService) CreateCategory(ctx context.Context, req *request.CreateCategoryRequest) (*response.NotificationCategoryResponse, error)
- func (s *NotificationService) CreateNotification(ctx context.Context, userID uint, req *request.CreateNotificationRequest) (*response.NotificationResponse, error)
- func (s *NotificationService) DeleteNotification(ctx context.Context, notificationID uint, userID uint) error
- func (s *NotificationService) GetAdminNotifications(ctx context.Context, req *request.GetNotificationsRequest) (*response.PageResponse, error)
- func (s *NotificationService) GetCategories(ctx context.Context) ([]response.NotificationCategoryResponse, error)
- func (s *NotificationService) GetNotificationAdminByID(ctx context.Context, notificationID uint) (*response.NotificationResponse, error)
- func (s *NotificationService) GetNotificationByID(ctx context.Context, notificationID uint) (*response.NotificationResponse, error)
- func (s *NotificationService) GetNotificationStats(ctx context.Context) (*response.NotificationStatsResponse, error)
- func (s *NotificationService) GetNotifications(ctx context.Context, req *request.GetNotificationsRequest) (*response.PageResponse, error)
- func (s *NotificationService) PinNotification(ctx context.Context, notificationID uint) error
- func (s *NotificationService) PublishNotification(ctx context.Context, notificationID uint, userID uint) error
- func (s *NotificationService) PublishNotificationAdmin(ctx context.Context, notificationID uint, userID uint) error
- func (s *NotificationService) UnpinNotification(ctx context.Context, notificationID uint) error
- func (s *NotificationService) UpdateCategory(ctx context.Context, categoryID uint8, req *request.UpdateCategoryRequest) (*response.NotificationCategoryResponse, error)
- func (s *NotificationService) UpdateNotification(ctx context.Context, notificationID uint, userID uint, ...) (*response.NotificationResponse, error)
- type OSSService
- type OrganizationService
- func (s *OrganizationService) CreateOrganization(ctx context.Context, req *request.CreateOrganizationRequest) (*models.Organization, error)
- func (s *OrganizationService) DeleteOrganization(ctx context.Context, id uint) error
- func (s *OrganizationService) GetOrganizationByID(ctx context.Context, id uint) (*models.Organization, error)
- func (s *OrganizationService) ListOrganizations(ctx context.Context, req *request.ListOrganizationsRequest) ([]models.Organization, int64, error)
- func (s *OrganizationService) UpdateOrganization(ctx context.Context, id uint, req *request.UpdateOrganizationRequest) (*models.Organization, error)
- type PointsService
- func (s *PointsService) AddPoints(ctx context.Context, tx *gorm.DB, userID uint, points int, source string, ...) error
- func (s *PointsService) GetPointsTransactions(ctx context.Context, userID uint, req *request.GetPointsTransactionsRequest) (*response.PageResponse, error)
- func (s *PointsService) GetUserPoints(ctx context.Context, userID uint) (*response.UserPointsResponse, error)
- func (s *PointsService) GetUserPointsStats(ctx context.Context, userID uint) (map[string]interface{}, error)
- func (s *PointsService) GrantPoints(ctx context.Context, userID uint, points int, description string) error
- func (s *PointsService) SpendPoints(ctx context.Context, userID uint, req *request.SpendPointsRequest) error
- type PomodoroService
- type QuestionService
- func (s *QuestionService) CreateAdminQuestion(ctx context.Context, req *request.AdminCreateQuestionRequest) (*response.AdminQuestionResponse, error)
- func (s *QuestionService) CreateAdminQuestionProject(ctx context.Context, req *request.AdminCreateQuestionProjectRequest) (*response.AdminQuestionProjectResponse, error)
- func (s *QuestionService) DeleteAdminQuestion(ctx context.Context, id uint) error
- func (s *QuestionService) DeleteAdminQuestionProject(ctx context.Context, id uint) error
- func (s *QuestionService) GetAdminQuestionByID(ctx context.Context, id uint) (*response.AdminQuestionResponse, error)
- func (s *QuestionService) GetAdminQuestionProjectByID(ctx context.Context, id uint) (*response.AdminQuestionProjectResponse, error)
- func (s *QuestionService) GetProjectByID(ctx context.Context, projectID uint) (*models.QuestionProject, error)
- func (s *QuestionService) GetProjects(ctx context.Context, userID uint) ([]response.QuestionProjectResponse, error)
- func (s *QuestionService) GetQuestionByID(ctx context.Context, userID, questionID uint) (*response.QuestionResponse, error)
- func (s *QuestionService) GetQuestions(ctx context.Context, userID uint, req *request.GetQuestionRequest) (*response.QuestionListResponse, error)
- func (s *QuestionService) ListAdminQuestionProjects(ctx context.Context, req *request.AdminListQuestionProjectsRequest) ([]response.AdminQuestionProjectResponse, int64, error)
- func (s *QuestionService) ListAdminQuestions(ctx context.Context, req *request.AdminListQuestionsRequest) ([]response.AdminQuestionResponse, int64, error)
- func (s *QuestionService) RecordStudy(ctx context.Context, userID uint, req *request.RecordStudyRequest) error
- func (s *QuestionService) SubmitPractice(ctx context.Context, userID uint, req *request.SubmitPracticeRequest) error
- func (s *QuestionService) UpdateAdminQuestion(ctx context.Context, id uint, req *request.AdminUpdateQuestionRequest) (*response.AdminQuestionResponse, error)
- func (s *QuestionService) UpdateAdminQuestionProject(ctx context.Context, id uint, req *request.AdminUpdateQuestionProjectRequest) (*response.AdminQuestionProjectResponse, error)
- type RBACService
- func (s *RBACService) CheckPermission(ctx context.Context, userID uint, permissionTag string) (bool, error)
- func (s *RBACService) CheckUserRole(ctx context.Context, userID uint, role string) bool
- func (s *RBACService) CreatePermission(ctx context.Context, perm *models.Permission) error
- func (s *RBACService) CreateRole(ctx context.Context, role *models.Role) error
- func (s *RBACService) DeleteRole(ctx context.Context, id uint) error
- func (s *RBACService) EnsureUserHasRoleByTag(ctx context.Context, userID uint, roleTag string) error
- func (s *RBACService) GetRolesWithPermissions(ctx context.Context) ([]models.Role, map[uint][]models.Permission, error)
- func (s *RBACService) GetUserPermissionSnapshot(ctx context.Context, userID uint) (*UserPermissionSnapshot, error)
- func (s *RBACService) GetUserPermissions(ctx context.Context, userID uint) ([]string, error)
- func (s *RBACService) GetUserRoleTags(ctx context.Context, userID uint) ([]string, error)
- func (s *RBACService) GetUsersByRoleTags(ctx context.Context, roleTags []string) ([]models.User, error)
- func (s *RBACService) GrantRole(ctx context.Context, userID uint, roleID uint) error
- func (s *RBACService) ListPermissions(ctx context.Context) ([]models.Permission, error)
- func (s *RBACService) ListRoles(ctx context.Context) ([]models.Role, error)
- func (s *RBACService) ListRolesWithUsers(ctx context.Context) ([]models.Role, map[uint]int, map[uint][]uint, error)
- func (s *RBACService) RevokeRole(ctx context.Context, userID uint, roleID uint) error
- func (s *RBACService) SeedDefaults(ctx context.Context) error
- func (s *RBACService) UpdateRole(ctx context.Context, id uint, updates map[string]any) error
- func (s *RBACService) UpdateRolePermissions(ctx context.Context, roleID uint, permissionIDs []uint) error
- func (s *RBACService) UpdateUserRoles(ctx context.Context, userID uint, roleIDs []uint) error
- type ReviewService
- func (s *ReviewService) ApproveReview(ctx context.Context, reviewID uint, adminNote string) error
- func (s *ReviewService) CreateReview(ctx context.Context, userID uint, req *request.CreateReviewRequest) error
- func (s *ReviewService) DeleteReview(ctx context.Context, reviewID uint) error
- func (s *ReviewService) GetReviewByID(ctx context.Context, reviewID uint) (*models.TeacherReview, error)
- func (s *ReviewService) GetReviews(ctx context.Context, page, size int, teacherName string, ...) ([]models.TeacherReview, int64, error)
- func (s *ReviewService) GetReviewsByTeacher(ctx context.Context, teacherName string, page, size int) ([]models.TeacherReview, int64, error)
- func (s *ReviewService) GetUserReviews(ctx context.Context, userID uint, page, size int) ([]models.TeacherReview, int64, error)
- func (s *ReviewService) RejectReview(ctx context.Context, reviewID uint, adminNote string) error
- type S3Service
- func (s *S3Service) AddObject(ctx context.Context, data io.ReadCloser, fileName string, mimeType string, ...) (string, error)
- func (s *S3Service) DeleteObject(ctx context.Context, resourceID string) error
- func (s *S3Service) GetObject(ctx context.Context, resourceID string) (io.ReadCloser, *models.S3Data, error)
- func (s *S3Service) ListExpiredObjects(ctx context.Context) ([]models.S3Resource, error)
- func (s *S3Service) ListObjects(ctx context.Context) ([]models.S3Data, error)
- func (s *S3Service) ShareObject(ctx context.Context, openid, resourceID string, expires *time.Duration, ...) (string, error)
- type S3ServiceInterface
- type StatService
- func (s *StatService) GetAllProjectsOnlineCount(ctx context.Context) ([]response.AllProjectsOnlineStatItem, error)
- func (s *StatService) GetCountdownCountsByUser(ctx context.Context, page, pageSize int) ([]response.AdminUserCountStatResponse, int64, error)
- func (s *StatService) GetGPABackupCountsByUser(ctx context.Context, page, pageSize int) ([]response.AdminUserCountStatResponse, int64, error)
- func (s *StatService) GetProjectOnlineCount(ctx context.Context, projectID uint, userID ...uint) (int64, error)
- func (s *StatService) GetStudyTaskCountsByUser(ctx context.Context, page, pageSize int) ([]response.AdminUserCountStatResponse, int64, error)
- func (s *StatService) GetSystemOnlineCount(ctx context.Context) (int64, error)
- type StudyTaskService
- func (s *StudyTaskService) CreateStudyTask(ctx context.Context, userID uint, req *request.CreateStudyTaskRequest) (*response.StudyTaskResponse, error)
- func (s *StudyTaskService) DeleteStudyTask(ctx context.Context, taskID uint, userID uint) error
- func (s *StudyTaskService) GetCompletedTasks(ctx context.Context, userID uint, page, size int) (*response.PageResponse, error)
- func (s *StudyTaskService) GetStudyTaskByID(ctx context.Context, taskID uint, userID uint) (*response.StudyTaskResponse, error)
- func (s *StudyTaskService) GetStudyTaskStats(ctx context.Context, userID uint) (*response.StudyTaskStatsResponse, error)
- func (s *StudyTaskService) GetStudyTasks(ctx context.Context, userID uint, req *request.GetStudyTasksRequest) (*response.PageResponse, error)
- func (s *StudyTaskService) UpdateStudyTask(ctx context.Context, taskID uint, userID uint, ...) (*response.StudyTaskResponse, error)
- type UserActivityService
- type UserPermissionSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithResumeInput ¶
WithResumeInput 创建一个包含恢复输入的工具选项
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
func NewAuthService ¶
func NewAuthService(db *gorm.DB, cfg *config.Config, rbac *RBACService, ca cache.Cache) *AuthService
func (*AuthService) AdminLogin ¶
func (s *AuthService) AdminLogin(ctx context.Context, phone, password, userAgent string) (*response.WechatLoginResponse, error)
AdminLogin 后台手机号密码登录
func (*AuthService) GetUserAuthDetail ¶
func (s *AuthService) GetUserAuthDetail(ctx context.Context, userID uint) (*response.UserAuthDetailResponse, error)
func (*AuthService) GetUserByID ¶
GetUserByID 根据ID获取用户信息
func (*AuthService) GetUserSessions ¶
func (s *AuthService) GetUserSessions(ctx context.Context, userID uint, currentSID string) ([]response.AuthSessionSummary, error)
func (*AuthService) MockWechatLogin ¶
func (s *AuthService) MockWechatLogin(ctx context.Context, testUser, userAgent string) (*response.WechatLoginResponse, error)
MockWechatLogin 模拟微信小程序登录 - 仅用于测试
func (*AuthService) RefreshToken ¶
func (s *AuthService) RefreshToken(ctx context.Context, refreshTokenString, userAgent string) (*response.WechatLoginResponse, error)
RefreshToken 刷新 AccessToken 和 RefreshToken。
func (*AuthService) SetAdminLoginCredentials ¶
func (s *AuthService) SetAdminLoginCredentials(ctx context.Context, operatorUserID, targetUserID uint, phone, password string) error
SetAdminLoginCredentials 设置后台登录凭据
func (*AuthService) UnbanUser ¶
func (s *AuthService) UnbanUser(ctx context.Context, operatorUserID, targetUserID uint) error
func (*AuthService) UpdateUserProfile ¶
func (s *AuthService) UpdateUserProfile(ctx context.Context, userID uint, updates map[string]any) error
UpdateUserProfile 更新用户资料
func (*AuthService) WechatLogin ¶
func (s *AuthService) WechatLogin(ctx context.Context, code, userAgent string) (*response.WechatLoginResponse, error)
WechatLogin 微信小程序登录
type ChatService ¶
type ChatService struct {
// contains filtered or unexported fields
}
func NewChatService ¶
func NewChatService(db *gorm.DB, cfg *config.Config) *ChatService
func (*ChatService) AppendMessages ¶
func (s *ChatService) AppendMessages(ctx context.Context, userID, conversationID uint, checkpointID string, messages []*schema.Message) error
AppendMessages 追加消息到对话消息表
func (*ChatService) CreateConversation ¶
func (s *ChatService) CreateConversation(ctx context.Context, userID uint, title string) (*models.Conversation, error)
CreateConversation 创建新对话
func (*ChatService) DeleteConversation ¶
func (s *ChatService) DeleteConversation(ctx context.Context, userID, conversationID uint) error
DeleteConversation 删除对话
func (*ChatService) ExportConversation ¶
func (s *ChatService) ExportConversation(ctx context.Context, userID, conversationID uint) (*models.Conversation, []*schema.Message, error)
ExportConversation 导出对话
func (*ChatService) GenerateTitleFromFirstMessage ¶
func (s *ChatService) GenerateTitleFromFirstMessage(ctx context.Context, content string) (string, error)
GenerateTitleFromFirstMessage 从第一条消息生成标题
func (*ChatService) GetConversation ¶
func (s *ChatService) GetConversation(ctx context.Context, userID, conversationID uint) (*models.Conversation, error)
GetConversation 获取对话详情
func (*ChatService) GetMessages ¶
func (s *ChatService) GetMessages(ctx context.Context, userID, conversationID uint) ([]*schema.Message, error)
GetMessages 获取对话的所有消息
func (*ChatService) ListConversations ¶
func (s *ChatService) ListConversations(ctx context.Context, userID uint, page, pageSize int) ([]models.Conversation, int64, error)
ListConversations 列出用户的对话
func (*ChatService) StreamChat ¶
func (s *ChatService) StreamChat(ctx context.Context, userID, conversationID uint, newMessage *schema.Message, userToken string, checkpointID string, resumeInput string) (<-chan string, <-chan error, error)
StreamChat 流式聊天 (返回一个通道用于 SSE) 使用 NewChatModelAgent 实现,支持中断恢复和流式传输 当 checkpointID 不为空时,执行恢复操作;否则执行新对话
func (*ChatService) UpdateConversation ¶
func (s *ChatService) UpdateConversation(ctx context.Context, userID, conversationID uint, title string) error
UpdateConversation 更新对话标题
type ConfigService ¶
type ConfigService struct {
// contains filtered or unexported fields
}
func NewConfigService ¶
func NewConfigService(db *gorm.DB) *ConfigService
func (*ConfigService) Create ¶
func (s *ConfigService) Create(ctx context.Context, key, value, valueType, description string) (*models.SystemConfig, error)
Create 创建配置项(key唯一)
func (*ConfigService) Delete ¶
func (s *ConfigService) Delete(ctx context.Context, key string) error
Delete 软删除(按key)
func (*ConfigService) GetByKey ¶
func (s *ConfigService) GetByKey(ctx context.Context, key string) (*models.SystemConfig, error)
GetByKey 通过key获取配置项
func (*ConfigService) SearchConfigs ¶
func (s *ConfigService) SearchConfigs(ctx context.Context, query string, page, size int) ([]models.SystemConfig, int64, error)
SearchConfigs 搜索配置项,支持按key搜索,空query返回全部(分页版本)
type ContributionService ¶
type ContributionService struct {
// contains filtered or unexported fields
}
func NewContributionService ¶
func NewContributionService(db *gorm.DB, pointsService *PointsService) *ContributionService
func (*ContributionService) CreateContribution ¶
func (s *ContributionService) CreateContribution(ctx context.Context, userID uint, req *request.CreateContributionRequest) error
CreateContribution 创建投稿
func (*ContributionService) GetAdminContributionStats ¶
func (s *ContributionService) GetAdminContributionStats(ctx context.Context) (*response.AdminContributionStatsResponse, error)
GetAdminContributionStats 获取管理员投稿统计(全系统)
func (*ContributionService) GetContributionByID ¶
func (s *ContributionService) GetContributionByID(ctx context.Context, contributionID uint, userID uint) (*response.ContributionResponse, error)
GetContributionByID 根据ID获取投稿详情
func (*ContributionService) GetContributions ¶
func (s *ContributionService) GetContributions(ctx context.Context, userID uint, req *request.GetContributionsRequest) (*response.PageResponse, error)
GetContributions 获取投稿列表
func (*ContributionService) GetUserContributionStats ¶
func (s *ContributionService) GetUserContributionStats(ctx context.Context, userID uint) (map[string]interface{}, error)
GetUserContributionStats 获取用户投稿统计
func (*ContributionService) ReviewContribution ¶
func (s *ContributionService) ReviewContribution(ctx context.Context, contributionID uint, reviewerID uint, req *request.ReviewContributionRequest) error
ReviewContribution 审核投稿
type CountdownService ¶
type CountdownService struct {
// contains filtered or unexported fields
}
func NewCountdownService ¶
func NewCountdownService(db *gorm.DB) *CountdownService
func (*CountdownService) CreateCountdown ¶
func (s *CountdownService) CreateCountdown(ctx context.Context, userID uint, req *request.CreateCountdownRequest) (*response.CountdownResponse, error)
CreateCountdown 创建倒数日
func (*CountdownService) DeleteCountdown ¶
func (s *CountdownService) DeleteCountdown(ctx context.Context, countdownID uint, userID uint) error
DeleteCountdown 删除倒数日
func (*CountdownService) GetCountdownByID ¶
func (s *CountdownService) GetCountdownByID(ctx context.Context, countdownID uint, userID uint) (*response.CountdownResponse, error)
GetCountdownByID 根据ID获取倒数日详情
func (*CountdownService) GetCountdowns ¶
func (s *CountdownService) GetCountdowns(ctx context.Context, userID uint) ([]response.CountdownResponse, error)
GetCountdowns 获取用户倒数日列表
func (*CountdownService) UpdateCountdown ¶
func (s *CountdownService) UpdateCountdown(ctx context.Context, countdownID uint, userID uint, req *request.UpdateCountdownRequest) (*response.CountdownResponse, error)
UpdateCountdown 更新倒数日
type CourseTableService ¶
type CourseTableService struct {
// contains filtered or unexported fields
}
func NewCourseTableService ¶
func NewCourseTableService(db *gorm.DB) *CourseTableService
func (*CourseTableService) CreateAdminCourseTable ¶
func (s *CourseTableService) CreateAdminCourseTable(ctx context.Context, req *request.AdminCreateCourseTableRequest) (*response.AdminCourseTableResponse, error)
func (*CourseTableService) DeleteAdminCourseTable ¶
func (s *CourseTableService) DeleteAdminCourseTable(ctx context.Context, id uint) error
func (*CourseTableService) EditUserCourseCell ¶
func (s *CourseTableService) EditUserCourseCell(ctx context.Context, userID uint, semester string, index string, value datatypes.JSON) error
EditUserCourseCell 编辑用户课程表的单个格子(1-35)
func (*CourseTableService) GetAdminCourseTableByID ¶
func (s *CourseTableService) GetAdminCourseTableByID(ctx context.Context, id uint) (*response.AdminCourseTableResponse, error)
func (*CourseTableService) GetUserBindCount ¶
GetUserBindCount 获取当前用户的课表绑定次数
func (*CourseTableService) GetUserCourseTable ¶
func (s *CourseTableService) GetUserCourseTable(ctx context.Context, userID uint, semester string) (*response.CourseTableResponse, error)
GetUserCourseTable 获取用户课程表 (保持向后兼容)
func (*CourseTableService) GetUserCourseTableWithVersion ¶
func (s *CourseTableService) GetUserCourseTableWithVersion(ctx context.Context, userID uint, semester string, clientLastModified *int64) (*response.CourseTableResponse, error)
GetUserCourseTableWithVersion 获取用户课程表(带版本检测)
func (*CourseTableService) ListAdminCourseTables ¶
func (s *CourseTableService) ListAdminCourseTables(ctx context.Context, req *request.AdminListCourseTablesRequest) ([]response.AdminCourseTableResponse, int64, error)
func (*CourseTableService) ResetUserBindCount ¶
func (s *CourseTableService) ResetUserBindCount(ctx context.Context, targetUserID uint) error
func (*CourseTableService) ResetUserBindCountToOne ¶
func (s *CourseTableService) ResetUserBindCountToOne(ctx context.Context, targetUserID uint) error
ResetUserBindCountToOne 将指定用户的绑定次数置为1(管理员操作)
func (*CourseTableService) ResetUserSchedule ¶
func (s *CourseTableService) ResetUserSchedule(ctx context.Context, userID uint, semester string) error
ResetUserSchedule 重置用户个人课表(删除个人编辑的数据条目)
func (*CourseTableService) SearchClasses ¶
func (s *CourseTableService) SearchClasses(ctx context.Context, keyword string, page, size int) (*response.SearchClassResponse, error)
SearchClasses 模糊搜索班级
func (*CourseTableService) UpdateAdminCourseTable ¶
func (s *CourseTableService) UpdateAdminCourseTable(ctx context.Context, id uint, req *request.AdminUpdateCourseTableRequest) (*response.AdminCourseTableResponse, error)
func (*CourseTableService) UpdateUserClass ¶
func (s *CourseTableService) UpdateUserClass(ctx context.Context, userID uint, classID string) (err error)
UpdateUserClass 更新用户班级(普通用户2次绑定限制)
type DictionaryService ¶
type DictionaryService struct {
// contains filtered or unexported fields
}
func NewDictionaryService ¶
func NewDictionaryService(db *gorm.DB) *DictionaryService
func (*DictionaryService) GetRandomWord ¶
func (s *DictionaryService) GetRandomWord(ctx context.Context) (*models.Dictionary, error)
GetRandomWord 从数据库随机获取一个词
type FailRateService ¶
type FailRateService struct {
// contains filtered or unexported fields
}
func NewFailRateService ¶
func NewFailRateService(db *gorm.DB) *FailRateService
func (*FailRateService) CreateAdminFailRate ¶
func (s *FailRateService) CreateAdminFailRate(ctx context.Context, req *request.AdminCreateFailRateRequest) (*response.AdminFailRateResponse, error)
func (*FailRateService) DeleteAdminFailRate ¶
func (s *FailRateService) DeleteAdminFailRate(ctx context.Context, id uint) error
func (*FailRateService) GetAdminFailRateByID ¶
func (s *FailRateService) GetAdminFailRateByID(ctx context.Context, id uint) (*response.AdminFailRateResponse, error)
func (*FailRateService) ListAdminFailRates ¶
func (s *FailRateService) ListAdminFailRates(ctx context.Context, req *request.AdminListFailRatesRequest) ([]response.AdminFailRateResponse, int64, error)
func (*FailRateService) Search ¶
func (s *FailRateService) Search(ctx context.Context, keyword string, page, size int) ([]models.FailRate, int64, error)
Search 按课程名关键词分页查询,默认按 failrate 降序
func (*FailRateService) UpdateAdminFailRate ¶
func (s *FailRateService) UpdateAdminFailRate(ctx context.Context, id uint, req *request.AdminUpdateFailRateRequest) (*response.AdminFailRateResponse, error)
type FeatureService ¶
type FeatureService struct {
// contains filtered or unexported fields
}
func NewFeatureService ¶
func NewFeatureService(db *gorm.DB) *FeatureService
func (*FeatureService) BatchGrantFeatureToUsers ¶
func (s *FeatureService) BatchGrantFeatureToUsers(ctx context.Context, userIDs []uint, featureKey string) error
BatchGrantFeatureToUsers 批量授予用户功能权限
func (*FeatureService) CheckUserFeature ¶
func (s *FeatureService) CheckUserFeature(ctx context.Context, userID uint, featureKey string) (bool, error)
CheckUserFeature 检查用户是否有指定功能权限(带缓存)
func (*FeatureService) CreateFeature ¶
CreateFeature 创建功能
func (*FeatureService) DeleteFeature ¶
func (s *FeatureService) DeleteFeature(ctx context.Context, featureKey string) error
DeleteFeature 删除功能(软删除)
func (*FeatureService) GetEnabledProjectFeatures ¶
GetEnabledProjectFeatures 获取所有启用的项目灰度 feature_key 查询 SELECT ... LIKE 'review.project.%' 走 B-tree 索引前缀匹配,~1ms,无需缓存
func (*FeatureService) GetFeature ¶
func (s *FeatureService) GetFeature(ctx context.Context, featureKey string) (*models.Feature, error)
GetFeature 获取功能详情
func (*FeatureService) GetRoleIDsByFeature ¶
func (s *FeatureService) GetRoleIDsByFeature(ctx context.Context, featureKey string) ([]uint, error)
GetRoleIDsByFeature 查询某功能已授权的角色ID列表
func (*FeatureService) GetUserFeatures ¶
GetUserFeatures 获取用户的所有可用功能列表(带缓存) 来源:① user_id IN user_ids ② user_role IN role_ids(一条SQL搞定)
func (*FeatureService) GetUserIDsByFeature ¶
func (s *FeatureService) GetUserIDsByFeature(ctx context.Context, featureKey string) ([]uint, error)
GetUserIDsByFeature 查询某功能已授权的用户ID列表
func (*FeatureService) GrantFeatureToUser ¶
func (s *FeatureService) GrantFeatureToUser(ctx context.Context, userID uint, featureKey string) error
GrantFeatureToUser 授予用户功能权限(往 UserIDs JSON 数组添加 userID)
func (*FeatureService) GrantRoleToFeature ¶
func (s *FeatureService) GrantRoleToFeature(ctx context.Context, featureKey string, roleID uint) error
GrantRoleToFeature 给功能添加单个授权角色(追加到 role_ids)
func (*FeatureService) IsFeatureEnabled ¶
IsFeatureEnabled 检查功能是否全局启用(带缓存)
func (*FeatureService) ListFeatures ¶
ListFeatures 获取所有功能列表
func (*FeatureService) RevokeFeatureFromUser ¶
func (s *FeatureService) RevokeFeatureFromUser(ctx context.Context, userID uint, featureKey string) error
RevokeFeatureFromUser 撤销用户功能权限(从 UserIDs JSON 数组移除)
func (*FeatureService) RevokeRoleFromFeature ¶
func (s *FeatureService) RevokeRoleFromFeature(ctx context.Context, featureKey string, roleID uint) error
RevokeRoleFromFeature 从功能移除单个授权角色
func (*FeatureService) SetFeatureRoles ¶
func (s *FeatureService) SetFeatureRoles(ctx context.Context, featureKey string, roleIDs []uint) error
SetFeatureRoles 设置功能的授权角色ID列表
func (*FeatureService) UpdateFeature ¶
func (s *FeatureService) UpdateFeature(ctx context.Context, featureKey string, updates map[string]interface{}) error
UpdateFeature 更新功能
type GPABackupService ¶
type GPABackupService struct {
// contains filtered or unexported fields
}
func NewGPABackupService ¶
func NewGPABackupService(db *gorm.DB) *GPABackupService
func (*GPABackupService) CreateBackup ¶
func (s *GPABackupService) CreateBackup(ctx context.Context, userID uint, title string, rawData []byte) (*response.GPABackupResponse, error)
func (*GPABackupService) DeleteBackup ¶
func (s *GPABackupService) DeleteBackup(ctx context.Context, userID, backupID uint) error
func (*GPABackupService) GetBackupByID ¶
func (s *GPABackupService) GetBackupByID(ctx context.Context, userID, backupID uint) (*response.GPABackupResponse, error)
func (*GPABackupService) ListBackups ¶
func (s *GPABackupService) ListBackups(ctx context.Context, userID uint) ([]response.GPABackupResponse, error)
type HeroService ¶
type HeroService struct {
// contains filtered or unexported fields
}
func NewHeroService ¶
func NewHeroService(db *gorm.DB) *HeroService
func (*HeroService) ListAll ¶
func (s *HeroService) ListAll(ctx context.Context) ([]string, error)
ListAll 返回仅名称的字符串数组,按 sort 升序(只返回is_show=true的)
type MaterialService ¶
type MaterialService struct {
// contains filtered or unexported fields
}
func NewMaterialService ¶
func NewMaterialService(db *gorm.DB) *MaterialService
func (*MaterialService) CalculateHotness ¶
func (s *MaterialService) CalculateHotness(ctx context.Context) error
CalculateHotness 计算热度(定时任务调用)
func (*MaterialService) CreateMaterialLog ¶
func (s *MaterialService) CreateMaterialLog(ctx context.Context, userID uint, req *request.MaterialLogCreateRequest) error
CreateMaterialLog 创建资料日志
func (*MaterialService) DeleteMaterial ¶
func (s *MaterialService) DeleteMaterial(ctx context.Context, md5 string) error
DeleteMaterial 删除资料(管理员)
func (*MaterialService) GetCategoriesByParent ¶
func (s *MaterialService) GetCategoriesByParent(ctx context.Context, parentID *uint) ([]response.MaterialCategoryResponse, error)
GetCategoriesByParent 通过上级分类ID获取分类(只获取第一层子分类)
func (*MaterialService) GetHotWords ¶
func (s *MaterialService) GetHotWords(ctx context.Context, limit int) ([]response.HotWordsResponse, error)
GetHotWords 获取搜索热词
func (*MaterialService) GetMaterialByMD5 ¶
func (s *MaterialService) GetMaterialByMD5(ctx context.Context, md5 string, userID *uint) (*response.MaterialDetailResponse, error)
GetMaterialByMD5 根据MD5获取资料详情
func (*MaterialService) GetMaterialDesc ¶
func (s *MaterialService) GetMaterialDesc(ctx context.Context, md5 string) (*response.MaterialDescResponse, error)
GetMaterialDesc 获取资料描述
func (*MaterialService) GetMaterialList ¶
func (s *MaterialService) GetMaterialList(ctx context.Context, req *request.MaterialListRequest) ([]response.MaterialListResponse, int64, error)
GetMaterialList 获取资料列表(按热度排序)
func (*MaterialService) GetTopMaterials ¶
func (s *MaterialService) GetTopMaterials(ctx context.Context, req *request.TopMaterialsRequest) ([]response.MaterialListResponse, error)
GetTopMaterials 获取TOP热门资料
func (*MaterialService) RateMaterial ¶
func (s *MaterialService) RateMaterial(ctx context.Context, userID uint, md5 string, rating int) error
RateMaterial 为资料评分
func (*MaterialService) SearchMaterials ¶
func (s *MaterialService) SearchMaterials(ctx context.Context, req *request.MaterialSearchRequest) (*response.MaterialSearchResponse, error)
SearchMaterials 搜索资料
func (*MaterialService) UpdateMaterialDesc ¶
func (s *MaterialService) UpdateMaterialDesc(ctx context.Context, md5 string, req *request.MaterialDescUpdateRequest) error
UpdateMaterialDesc 更新资料描述(管理员,不存在时自动创建)
type NotificationService ¶
type NotificationService struct {
// contains filtered or unexported fields
}
func NewNotificationService ¶
func NewNotificationService(db *gorm.DB, rbacService *RBACService) *NotificationService
func (*NotificationService) ApproveNotification ¶
func (s *NotificationService) ApproveNotification(ctx context.Context, notificationID uint, reviewerID uint, req *request.ApproveNotificationRequest) error
ApproveNotification 审核通知
func (*NotificationService) ConvertToSchedule ¶
func (s *NotificationService) ConvertToSchedule(ctx context.Context, notificationID uint, req *request.ConvertToScheduleRequest) error
ConvertToSchedule 转换通知为日程
func (*NotificationService) CreateCategory ¶
func (s *NotificationService) CreateCategory(ctx context.Context, req *request.CreateCategoryRequest) (*response.NotificationCategoryResponse, error)
CreateCategory 创建分类
func (*NotificationService) CreateNotification ¶
func (s *NotificationService) CreateNotification(ctx context.Context, userID uint, req *request.CreateNotificationRequest) (*response.NotificationResponse, error)
CreateNotification 创建通知(管理员专用)
func (*NotificationService) DeleteNotification ¶
func (s *NotificationService) DeleteNotification(ctx context.Context, notificationID uint, userID uint) error
DeleteNotification 删除通知(软删除)
func (*NotificationService) GetAdminNotifications ¶
func (s *NotificationService) GetAdminNotifications(ctx context.Context, req *request.GetNotificationsRequest) (*response.PageResponse, error)
GetAdminNotifications 获取管理员通知列表(包括所有状态的通知)
func (*NotificationService) GetCategories ¶
func (s *NotificationService) GetCategories(ctx context.Context) ([]response.NotificationCategoryResponse, error)
GetCategories 获取所有分类
func (*NotificationService) GetNotificationAdminByID ¶
func (s *NotificationService) GetNotificationAdminByID(ctx context.Context, notificationID uint) (*response.NotificationResponse, error)
GetNotificationByID 根据ID获取通知详情
func (*NotificationService) GetNotificationByID ¶
func (s *NotificationService) GetNotificationByID(ctx context.Context, notificationID uint) (*response.NotificationResponse, error)
GetNotificationByID 根据ID获取通知详情
func (*NotificationService) GetNotificationStats ¶
func (s *NotificationService) GetNotificationStats(ctx context.Context) (*response.NotificationStatsResponse, error)
GetNotificationStats 获取通知统计信息
func (*NotificationService) GetNotifications ¶
func (s *NotificationService) GetNotifications(ctx context.Context, req *request.GetNotificationsRequest) (*response.PageResponse, error)
GetNotifications 获取通知列表
func (*NotificationService) PinNotification ¶
func (s *NotificationService) PinNotification(ctx context.Context, notificationID uint) error
PinNotification 置顶通知(管理员专用)
func (*NotificationService) PublishNotification ¶
func (s *NotificationService) PublishNotification(ctx context.Context, notificationID uint, userID uint) error
PublishNotification 发布通知
func (*NotificationService) PublishNotificationAdmin ¶
func (s *NotificationService) PublishNotificationAdmin(ctx context.Context, notificationID uint, userID uint) error
PublishNotificationAdmin 管理员直接发布通知(跳过审核流程)
func (*NotificationService) UnpinNotification ¶
func (s *NotificationService) UnpinNotification(ctx context.Context, notificationID uint) error
UnpinNotification 取消置顶通知(管理员专用)
func (*NotificationService) UpdateCategory ¶
func (s *NotificationService) UpdateCategory(ctx context.Context, categoryID uint8, req *request.UpdateCategoryRequest) (*response.NotificationCategoryResponse, error)
UpdateCategory 更新分类
func (*NotificationService) UpdateNotification ¶
func (s *NotificationService) UpdateNotification(ctx context.Context, notificationID uint, userID uint, req *request.UpdateNotificationRequest) (*response.NotificationResponse, error)
UpdateNotification 更新通知
type OSSService ¶
type OSSService struct {
// contains filtered or unexported fields
}
OSSService 负责生成又拍云/自建 CDN 的 Token 防盗链参数
func NewOSSService ¶
func NewOSSService(cfg *config.Config) *OSSService
func (*OSSService) GenerateToken ¶
func (s *OSSService) GenerateToken(uri string, ttlSeconds int64) (token string, expireAt int64, signedURL string, err error)
GenerateToken 根据 URI 生成 _upt 参数与可选的完整签名 URL 算法参考: https://help.upyun.com/knowledge-base/cdn-token-limite/
type OrganizationService ¶
type OrganizationService struct {
// contains filtered or unexported fields
}
func NewOrganizationService ¶
func NewOrganizationService(db *gorm.DB) *OrganizationService
func (*OrganizationService) CreateOrganization ¶
func (s *OrganizationService) CreateOrganization(ctx context.Context, req *request.CreateOrganizationRequest) (*models.Organization, error)
func (*OrganizationService) DeleteOrganization ¶
func (s *OrganizationService) DeleteOrganization(ctx context.Context, id uint) error
func (*OrganizationService) GetOrganizationByID ¶
func (s *OrganizationService) GetOrganizationByID(ctx context.Context, id uint) (*models.Organization, error)
func (*OrganizationService) ListOrganizations ¶
func (s *OrganizationService) ListOrganizations(ctx context.Context, req *request.ListOrganizationsRequest) ([]models.Organization, int64, error)
func (*OrganizationService) UpdateOrganization ¶
func (s *OrganizationService) UpdateOrganization(ctx context.Context, id uint, req *request.UpdateOrganizationRequest) (*models.Organization, error)
type PointsService ¶
type PointsService struct {
// contains filtered or unexported fields
}
func NewPointsService ¶
func NewPointsService(db *gorm.DB) *PointsService
func (*PointsService) AddPoints ¶
func (s *PointsService) AddPoints(ctx context.Context, tx *gorm.DB, userID uint, points int, source string, description string, relatedID *uint) error
AddPoints 增加积分(内部方法,用于其他服务调用)
func (*PointsService) GetPointsTransactions ¶
func (s *PointsService) GetPointsTransactions(ctx context.Context, userID uint, req *request.GetPointsTransactionsRequest) (*response.PageResponse, error)
GetPointsTransactions 获取积分交易记录
func (*PointsService) GetUserPoints ¶
func (s *PointsService) GetUserPoints(ctx context.Context, userID uint) (*response.UserPointsResponse, error)
GetUserPoints 获取用户积分信息
func (*PointsService) GetUserPointsStats ¶
func (s *PointsService) GetUserPointsStats(ctx context.Context, userID uint) (map[string]interface{}, error)
GetUserPointsStats 获取用户积分统计
func (*PointsService) GrantPoints ¶
func (s *PointsService) GrantPoints(ctx context.Context, userID uint, points int, description string) error
GrantPoints 管理员手动赋予积分
func (*PointsService) SpendPoints ¶
func (s *PointsService) SpendPoints(ctx context.Context, userID uint, req *request.SpendPointsRequest) error
SpendPoints 消费积分(原RedeemPoints)
type PomodoroService ¶
type PomodoroService struct {
// contains filtered or unexported fields
}
func NewPomodoroService ¶
func NewPomodoroService(db *gorm.DB) *PomodoroService
func (*PomodoroService) GetPomodoroCount ¶
GetPomodoroCount 获取用户番茄钟次数
func (*PomodoroService) GetPomodoroRanking ¶
func (s *PomodoroService) GetPomodoroRanking(ctx context.Context) ([]response.PomodoroRankingItem, error)
GetPomodoroRanking 获取番茄钟排名(前20名)
func (*PomodoroService) IncrementPomodoroCount ¶
func (s *PomodoroService) IncrementPomodoroCount(ctx context.Context, userID uint) error
IncrementPomodoroCount 增加番茄钟次数
type QuestionService ¶
type QuestionService struct {
// contains filtered or unexported fields
}
func NewQuestionService ¶
func NewQuestionService(db *gorm.DB, featureService *FeatureService) *QuestionService
func (*QuestionService) CreateAdminQuestion ¶
func (s *QuestionService) CreateAdminQuestion(ctx context.Context, req *request.AdminCreateQuestionRequest) (*response.AdminQuestionResponse, error)
func (*QuestionService) CreateAdminQuestionProject ¶
func (s *QuestionService) CreateAdminQuestionProject(ctx context.Context, req *request.AdminCreateQuestionProjectRequest) (*response.AdminQuestionProjectResponse, error)
func (*QuestionService) DeleteAdminQuestion ¶
func (s *QuestionService) DeleteAdminQuestion(ctx context.Context, id uint) error
func (*QuestionService) DeleteAdminQuestionProject ¶
func (s *QuestionService) DeleteAdminQuestionProject(ctx context.Context, id uint) error
func (*QuestionService) GetAdminQuestionByID ¶
func (s *QuestionService) GetAdminQuestionByID(ctx context.Context, id uint) (*response.AdminQuestionResponse, error)
func (*QuestionService) GetAdminQuestionProjectByID ¶
func (s *QuestionService) GetAdminQuestionProjectByID(ctx context.Context, id uint) (*response.AdminQuestionProjectResponse, error)
func (*QuestionService) GetProjectByID ¶
func (s *QuestionService) GetProjectByID(ctx context.Context, projectID uint) (*models.QuestionProject, error)
GetProjectByID 根据ID获取项目
func (*QuestionService) GetProjects ¶
func (s *QuestionService) GetProjects(ctx context.Context, userID uint) ([]response.QuestionProjectResponse, error)
GetProjects 获取项目列表 灰度规则:若 features 表中存在 review.project.{id} 且 is_enabled=true,则该项目灰度 feature 不存在或 is_enabled=false → 公开可见
func (*QuestionService) GetQuestionByID ¶
func (s *QuestionService) GetQuestionByID(ctx context.Context, userID, questionID uint) (*response.QuestionResponse, error)
GetQuestionByID 获取题目详情(公开方法)
func (*QuestionService) GetQuestions ¶
func (s *QuestionService) GetQuestions(ctx context.Context, userID uint, req *request.GetQuestionRequest) (*response.QuestionListResponse, error)
GetQuestions 获取题目列表(只返回题目ID数组,支持顺序/乱序)
func (*QuestionService) ListAdminQuestionProjects ¶
func (s *QuestionService) ListAdminQuestionProjects(ctx context.Context, req *request.AdminListQuestionProjectsRequest) ([]response.AdminQuestionProjectResponse, int64, error)
func (*QuestionService) ListAdminQuestions ¶
func (s *QuestionService) ListAdminQuestions(ctx context.Context, req *request.AdminListQuestionsRequest) ([]response.AdminQuestionResponse, int64, error)
func (*QuestionService) RecordStudy ¶
func (s *QuestionService) RecordStudy(ctx context.Context, userID uint, req *request.RecordStudyRequest) error
RecordStudy 记录学习(仅记录学习次数)
func (*QuestionService) SubmitPractice ¶
func (s *QuestionService) SubmitPractice(ctx context.Context, userID uint, req *request.SubmitPracticeRequest) error
SubmitPractice 提交做题(仅记录做题次数)
func (*QuestionService) UpdateAdminQuestion ¶
func (s *QuestionService) UpdateAdminQuestion(ctx context.Context, id uint, req *request.AdminUpdateQuestionRequest) (*response.AdminQuestionResponse, error)
func (*QuestionService) UpdateAdminQuestionProject ¶
func (s *QuestionService) UpdateAdminQuestionProject(ctx context.Context, id uint, req *request.AdminUpdateQuestionProjectRequest) (*response.AdminQuestionProjectResponse, error)
type RBACService ¶
type RBACService struct {
// contains filtered or unexported fields
}
RBACService 提供角色、权限、用户授权的核心能力
func (*RBACService) CheckPermission ¶
func (s *RBACService) CheckPermission(ctx context.Context, userID uint, permissionTag string) (bool, error)
CheckPermission 判断用户是否拥有指定权限
func (*RBACService) CheckUserRole ¶
CheckUserRole 检查用户是否拥有指定角色
func (*RBACService) CreatePermission ¶
func (s *RBACService) CreatePermission(ctx context.Context, perm *models.Permission) error
CreatePermission 创建权限
func (*RBACService) CreateRole ¶
CreateRole 创建角色
func (*RBACService) DeleteRole ¶
func (s *RBACService) DeleteRole(ctx context.Context, id uint) error
DeleteRole 删除角色并清理关联
func (*RBACService) EnsureUserHasRoleByTag ¶
func (s *RBACService) EnsureUserHasRoleByTag(ctx context.Context, userID uint, roleTag string) error
EnsureUserHasRoleByTag 确保用户拥有指定角色(用于新用户默认授权)
func (*RBACService) GetRolesWithPermissions ¶
func (s *RBACService) GetRolesWithPermissions(ctx context.Context) ([]models.Role, map[uint][]models.Permission, error)
GetRolesWithPermissions 获取所有角色及其对应的权限列表
func (*RBACService) GetUserPermissionSnapshot ¶
func (s *RBACService) GetUserPermissionSnapshot(ctx context.Context, userID uint) (*UserPermissionSnapshot, error)
GetUserPermissionSnapshot 获取用户有效权限(含缓存)
func (*RBACService) GetUserPermissions ¶
GetUserPermissions 返回用户权限标识列表
func (*RBACService) GetUserRoleTags ¶
GetUserRoleTags 获取用户角色标签
func (*RBACService) GetUsersByRoleTags ¶
func (s *RBACService) GetUsersByRoleTags(ctx context.Context, roleTags []string) ([]models.User, error)
GetUsersByRoleTags 根据角色标签列表获取用户数组
func (*RBACService) ListPermissions ¶
func (s *RBACService) ListPermissions(ctx context.Context) ([]models.Permission, error)
ListPermissions 获取权限列表
func (*RBACService) ListRolesWithUsers ¶
func (s *RBACService) ListRolesWithUsers(ctx context.Context) ([]models.Role, map[uint]int, map[uint][]uint, error)
ListRolesWithUsers 获取角色列表及其用户信息
func (*RBACService) RevokeRole ¶
RevokeRole 撤销用户角色
func (*RBACService) SeedDefaults ¶
func (s *RBACService) SeedDefaults(ctx context.Context) error
SeedDefaults 初始化设计文档中预置的角色/权限与绑定关系
func (*RBACService) UpdateRole ¶
UpdateRole 更新角色
func (*RBACService) UpdateRolePermissions ¶
func (s *RBACService) UpdateRolePermissions(ctx context.Context, roleID uint, permissionIDs []uint) error
UpdateRolePermissions 重置角色拥有的权限列表
func (*RBACService) UpdateUserRoles ¶
UpdateUserRoles 更新用户角色列表
type ReviewService ¶
type ReviewService struct {
// contains filtered or unexported fields
}
func NewReviewService ¶
func NewReviewService(db *gorm.DB, pointsService *PointsService) *ReviewService
func (*ReviewService) ApproveReview ¶
ApproveReview 审核通过评价
func (*ReviewService) CreateReview ¶
func (s *ReviewService) CreateReview(ctx context.Context, userID uint, req *request.CreateReviewRequest) error
CreateReview 创建教师评价
func (*ReviewService) DeleteReview ¶
func (s *ReviewService) DeleteReview(ctx context.Context, reviewID uint) error
DeleteReview 删除评价
func (*ReviewService) GetReviewByID ¶
func (s *ReviewService) GetReviewByID(ctx context.Context, reviewID uint) (*models.TeacherReview, error)
GetReviewByID 根据ID获取评价
func (*ReviewService) GetReviews ¶
func (s *ReviewService) GetReviews(ctx context.Context, page, size int, teacherName string, status models.TeacherReviewStatus) ([]models.TeacherReview, int64, error)
GetReviews 获取评价列表
func (*ReviewService) GetReviewsByTeacher ¶
func (s *ReviewService) GetReviewsByTeacher(ctx context.Context, teacherName string, page, size int) ([]models.TeacherReview, int64, error)
GetReviewsByTeacher 获取指定教师的评价
func (*ReviewService) GetUserReviews ¶
func (s *ReviewService) GetUserReviews(ctx context.Context, userID uint, page, size int) ([]models.TeacherReview, int64, error)
GetUserReviews 获取用户的评价记录
func (*ReviewService) RejectReview ¶
RejectReview 审核拒绝评价
type S3Service ¶
func (*S3Service) AddObject ¶
func (s *S3Service) AddObject(ctx context.Context, data io.ReadCloser, fileName string, mimeType string, isAdmin bool, customPath *string, tags map[string]string) (string, error)
AddObject adds an object to S3 and returns the resource ID.
func (*S3Service) DeleteObject ¶
DeleteObject deletes an object from S3 based on the resource ID.
func (*S3Service) GetObject ¶
func (s *S3Service) GetObject(ctx context.Context, resourceID string) (io.ReadCloser, *models.S3Data, error)
GetObject retrieves an object from S3 based on the resource ID.
func (*S3Service) ListExpiredObjects ¶
ListExpiredObjects lists all expired objects in the S3Resource table.
func (*S3Service) ListObjects ¶
ListObjects lists all objects in the S3Data table.
type S3ServiceInterface ¶
type S3ServiceInterface interface {
AddObject(ctx context.Context, data io.ReadCloser,
fileName string, mimeType string, isAdmin bool,
customPath *string, tags map[string]string) (string, error)
DeleteObject(ctx context.Context, resourceID string) error
ListObjects(ctx context.Context) ([]models.S3Data, error)
ListExpiredObjects(ctx context.Context) ([]models.S3Resource, error)
GetObject(ctx context.Context, resourceID string) (io.ReadCloser, *models.S3Data, error)
}
func NewS3Service ¶
func NewS3Service(db *gorm.DB, cfg *config.Config) S3ServiceInterface
type StatService ¶
type StatService struct {
// contains filtered or unexported fields
}
func NewStatService ¶
func NewStatService(db *gorm.DB) *StatService
func (*StatService) GetAllProjectsOnlineCount ¶
func (s *StatService) GetAllProjectsOnlineCount(ctx context.Context) ([]response.AllProjectsOnlineStatItem, error)
GetAllProjectsOnlineCount 获取所有启用项目的在线人数
func (*StatService) GetCountdownCountsByUser ¶
func (s *StatService) GetCountdownCountsByUser(ctx context.Context, page, pageSize int) ([]response.AdminUserCountStatResponse, int64, error)
func (*StatService) GetGPABackupCountsByUser ¶
func (s *StatService) GetGPABackupCountsByUser(ctx context.Context, page, pageSize int) ([]response.AdminUserCountStatResponse, int64, error)
func (*StatService) GetProjectOnlineCount ¶
func (s *StatService) GetProjectOnlineCount(ctx context.Context, projectID uint, userID ...uint) (int64, error)
GetProjectOnlineCount 获取项目在线人数 使用 Sorted Set,只统计最近1分钟内有活动的用户 不主动清理过期数据,只统计有效范围内的用户,过期数据不影响统计结果 如果传入了userID(>0),则在统计前先更新该用户的在线状态
func (*StatService) GetStudyTaskCountsByUser ¶
func (s *StatService) GetStudyTaskCountsByUser(ctx context.Context, page, pageSize int) ([]response.AdminUserCountStatResponse, int64, error)
func (*StatService) GetSystemOnlineCount ¶
func (s *StatService) GetSystemOnlineCount(ctx context.Context) (int64, error)
GetSystemOnlineCount 获取系统在线人数 使用 Sorted Set,只统计最近1分钟内有活动的用户 不主动清理过期数据,只统计有效范围内的用户,过期数据不影响统计结果
type StudyTaskService ¶
type StudyTaskService struct {
// contains filtered or unexported fields
}
func NewStudyTaskService ¶
func NewStudyTaskService(db *gorm.DB) *StudyTaskService
func (*StudyTaskService) CreateStudyTask ¶
func (s *StudyTaskService) CreateStudyTask(ctx context.Context, userID uint, req *request.CreateStudyTaskRequest) (*response.StudyTaskResponse, error)
CreateStudyTask 创建学习任务
func (*StudyTaskService) DeleteStudyTask ¶
DeleteStudyTask 删除学习任务
func (*StudyTaskService) GetCompletedTasks ¶
func (s *StudyTaskService) GetCompletedTasks(ctx context.Context, userID uint, page, size int) (*response.PageResponse, error)
GetCompletedTasks 获取已完成的任务(历史记录)
func (*StudyTaskService) GetStudyTaskByID ¶
func (s *StudyTaskService) GetStudyTaskByID(ctx context.Context, taskID uint, userID uint) (*response.StudyTaskResponse, error)
GetStudyTaskByID 根据ID获取学习任务详情
func (*StudyTaskService) GetStudyTaskStats ¶
func (s *StudyTaskService) GetStudyTaskStats(ctx context.Context, userID uint) (*response.StudyTaskStatsResponse, error)
GetStudyTaskStats 获取用户学习任务统计
func (*StudyTaskService) GetStudyTasks ¶
func (s *StudyTaskService) GetStudyTasks(ctx context.Context, userID uint, req *request.GetStudyTasksRequest) (*response.PageResponse, error)
GetStudyTasks 获取用户学习任务列表
func (*StudyTaskService) UpdateStudyTask ¶
func (s *StudyTaskService) UpdateStudyTask(ctx context.Context, taskID uint, userID uint, req *request.UpdateStudyTaskRequest) (*response.StudyTaskResponse, error)
UpdateStudyTask 更新学习任务
type UserActivityService ¶
type UserActivityService struct {
// contains filtered or unexported fields
}
func NewUserActivityService ¶
func NewUserActivityService(db *gorm.DB, rbacService *RBACService) *UserActivityService
func (*UserActivityService) GetUserLoginDays ¶
func (s *UserActivityService) GetUserLoginDays(ctx context.Context, userID uint, pastDays int) (int64, error)
GetUserLoginDays 获取用户在过去指定天数内的登录天数
func (*UserActivityService) UpdateActiveUserRoles ¶
func (s *UserActivityService) UpdateActiveUserRoles(ctx context.Context) error
UpdateActiveUserRoles 更新活跃用户角色 规则:100天内有25天访问次数,授予活跃角色;不满足条件则取消活跃角色
Source Files
¶
- auth_service.go
- chat_service.go
- config_service.go
- contribution_service.go
- countdown_service.go
- coursetable_admin_service.go
- coursetable_service.go
- dictionary_service.go
- failrate_admin_service.go
- failrate_service.go
- feature_service.go
- gpa_backup_service.go
- hero_service.go
- material_service.go
- notification_service.go
- organization_service.go
- oss_service.go
- points_service.go
- pomodoro_service.go
- question_admin_service.go
- question_service.go
- rbac_query.go
- rbac_service.go
- review_service.go
- s3_service.go
- stat_service.go
- study_task_service.go
- user_activity_service.go