Documentation
¶
Index ¶
- Constants
- Variables
- func AIAnalyzePic(base64String string) (string, error)
- func AIAnalyzeText(text string) (string, error)
- func AiAnalyzeClass(examID uint) (string, error)
- func AiAnalyzeStudent(examID uint, studentID uint) (string, error)
- func AnalyzeClass(examID uint) (models.ClassMetric, error)
- func AnalyzeKeypoint(examID uint) (models.KeypointMetricResp, error)
- func AnalyzeStudent(examID uint, studentID uint) (models.StudentAnalysisResponse, error)
- func Chat(text string, Model string, prompt string) (string, error)
- func ClassHistoryAnalysis(Subject string, ClassID uint) (models.ClassHistoryAnalysisResponse, error)
- func CreatProblems(problems []models.Problems) error
- func CreateClass(ClassNumber, GradeLevel int, userID uint) error
- func CreateExam(exam *models.Exam) error
- func CreateScores(examID uint, scoreInputs []models.ScoreInput) (int, error)
- func CreateStudent(classID uint, student models.Student) error
- func CreateUser(user *models.User, plainPassword string) (*models.User, error)
- func DeleteClass(classID string, userID uint) error
- func DeleteExam(examId string, userID uint) error
- func DeleteStudent(StudentNumber string) error
- func FileRead(objectName string) (ReadUrl string, err error)
- func GenerateFinalPrompt(topic string, history string) string
- func GeneratePresignedURL(bucketName, objectName, region, endpoint, processParams string, ...) (string, error)
- func GenerateSignature(auth *AuthConfig, timestamp int64) string
- func GenerateToken(userID uint) (string, error)
- func GetAIStream(ctx context.Context, message string) <-chan StreamChunk
- func GetClassByID(classID int) (*models.Class, error)
- func GetExamByID(db *gorm.DB, id string) (*models.Exam, error)
- func GetResourceUseExternal(objectName string) (string, error)
- func GetStuRank(examID uint) (models.StuRankResp, error)
- func GetUserByEmail(email string) (*models.User, error)
- func GetUserByPhoneNumber(phoneNumber string) (*models.User, error)
- func GetUserByuserID(userID uint) (*models.User, error)
- func GetUsernameByUserID(userID uint) (string, error)
- func ImageToBase64(fileBytes []byte) (string, error)
- func ListExamByClassID(classID uint, userID uint) ([]models.Exam, error)
- func ListScores(examID uint) ([]models.StudentScoreResponse, error)
- func ListStudents(classID uint) ([]models.Student, error)
- func PicGenerate(req PicGenerateRequest) (map[string]interface{}, error)
- func RagRecommend(prompt string) (map[string]interface{}, error)
- func ResetPasswordService(userID uint, oldPassword, newPassword string) error
- func SearchResources(pageNum, pageSize, q, subject, grade string) ([]models.Resource, int64, error)
- func StuAnalysis2String(examID uint, studentID uint) (string, error)
- func UpdatePassword(userID uint64, newPassword string) error
- func UploadFileToOSS(localFilePath, ossObjectName string) (*oss.PutObjectResult, error)
- type AuthConfig
- type ClassResp
- type CommonResponse
- type EmailConfig
- type EmailInfo
- type EmailVerificationService
- type GeneratePPTRequest
- type Outline
- type OutlineChapter
- type PPTThemeItem
- type PPTThemeRequest
- type PicGenerateRequest
- type Question
- type StreamChunk
- type VerificationService
Constants ¶
const ( DoubaoLite = "ep-20250311120726-h7xml" DeepSeekR1 = "ep-20250401115227-n89xn" DoubaoPro = "doubao-1-5-pro-256k-250115" AnalyzePrompt = `` /* 601-byte string literal not displayed */ ScoreAnalyzePrompt = "" /* 318-byte string literal not displayed */ StudentAnalyzePrompt = "" /* 359-byte string literal not displayed */ StudentRagPrompt = "" /* 223-byte string literal not displayed */ RagAiPrompt = "" /* 218-byte string literal not displayed */ RagMsgPrompt = "" /* 224-byte string literal not displayed */ )
const SystemPrompt = `` /* 2617-byte string literal not displayed */
Variables ¶
var Subjects = map[string][]string{
"物理": {
"密度公式应用宝典:一杯水的质量怎么算?",
"浮力原理实验室:为什么铁船能浮在水面?",
"压强公式实战:高跟鞋vs平底鞋谁更伤地板?",
"光的折射魔法秀:筷子弯折的奥秘在这里!",
"热传递三剑客:炒菜时三种传热方式都在工作",
"电路检修指南:如何用电压表快速定位故障?",
"焦耳定律实验课:电热丝为什么会发红?",
"电磁感应现象show:手摇发电机的秘密",
"能量转化大追踪:过山车中的动能势能转换",
"声音特性探索:为什么不同乐器音色不同?",
"杠杆平衡特训:撬地球需要多长的棍子?",
"惯性现象大发现:急刹车时身体前倾的真相",
},
"化学": {
"元素周期表探秘:同族元素为什么性质相似?",
"原子结构拆解:电子层就像洋葱的衣裳",
"化合价记忆口诀升级版:一价钾钠氯氢银...",
"实验室安全守则:这些标志你一定要认识!",
"过滤操作step by step:一贴二低三靠",
"气体收集妙招:排水法vs向上排空气法",
"燃烧条件实验:为什么纸锅烧水不会破?",
"碳的魔法世界:金刚石和石墨竟是亲戚!",
"化肥鉴别技巧:氮磷钾肥怎么区分?",
"指示剂变色秀:紫甘蓝汁的酸碱彩虹",
"质量守恒验证:镁条燃烧后的神秘增重",
"溶液配制实操:浓度计算的万能公式",
},
"生物": {
"细胞分裂live秀:有丝分裂全过程动画演示",
"植物器官功能展:根茎叶的才艺大比拼",
"消化系统漫游记:汉堡的24小时旅程",
"遗传规律实战:为什么双眼皮爸妈可能生出单眼皮宝宝?",
"生态沙盘模拟:如果草原上没有狼会怎样?",
"呼吸作用实验室:澄清石灰水变浑浊的秘密",
"免疫防线大阅兵:白细胞军团作战实录",
"生物分类闯关:你能找到大熊猫的族谱吗?",
"变异类型案例:太空椒的诞生记",
"微生物应用展:酵母菌的十八般武艺",
"湿地保护行动:地球之肾的生态价值",
"显微镜使用秘籍:从对光到找气泡的诀窍",
},
"历史": {
"秦朝时空穿越:如果你是秦始皇会怎么做?",
"丝路商队体验:从长安到罗马要带什么货物?",
"五四青年日志:还原1919年的热血一天",
"开国大典直播:1949年的历史性时刻",
"冷战剧场:美苏争霸的经典名场面",
"法国大革命剧本杀:攻占巴士底狱的真相",
"郑和宝船探秘:古代航海黑科技有哪些?",
"甲午沉思录:黄海海战的启示与教训",
"经济全球化实验:你的早餐包含多少国家元素?",
"抗战文物说:从老照片看民族记忆",
"古埃及探奇:金字塔建造的未解之谜",
},
"地理": {
"经纬网寻宝游戏:北纬30°的神秘地点",
"等高线解密:3D地形与平面图的转换魔法",
"中国地形探险:沿着胡焕庸线走一遍",
"气候类型cosplay:给不同气候配专属BGM",
"人口问题辩论:人多好还是人少好?",
"资源危机模拟:如果石油枯竭怎么办?",
"地球自转实验:用傅科摆证明地转偏向力",
"地震逃生演练:黄金12秒该怎么做?",
"城市病诊断书:堵车雾霾怎么治?",
"区域地理PK赛:秦岭淮河两岸大不同",
"火山探秘直播:地幔物质的地下旅行",
"二十四节气研学:古人如何观测太阳?",
},
"道德与法治": {
"法律诊所:帮小红分析网络谣言传播案例",
"罪案现场分析:这个行为构成犯罪吗?",
"价值观践行日记:我的24字修炼手册",
"民族团结拼图:五十六个民族服饰展",
"消费维权剧场:遇到假货该怎么处理?",
"道德两难选择:扶不扶老人的思辨课",
"外交风云录:最近的国际大事怎么看?",
"改革记忆馆:老物件里的时代变迁",
"教育公平调研:城乡学校设施对比",
"网络防身术:十条必备的安全守则",
"文化自信之旅:从故宫文创到汉服热",
"人类命运共同体实践:全球抗疫中的中国担当",
},
}
Functions ¶
func AiAnalyzeClass ¶
AiAnalyzeClass 调用 AI 模型(如豆包)对班级考试进行分析。 首先尝试从 Redis 缓存获取结果,如果缓存未命中,则调用 AnalyzeClass 和 AnalyzeKeypoint 获取数据, 将数据组合成 JSON 发送给 AI 模型,并将 AI 返回的分析结果存入 Redis 缓存。 examID: 需要分析的考试 ID。 返回 AI 生成的分析文本和可能发生的错误。
func AiAnalyzeStudent ¶
AiAnalyzeStudent 调用 AI 模型(如豆包)对学生在某次考试中的表现进行分析。 首先尝试从 Redis 缓存获取结果,如果缓存未命中,则调用 AnalyzeStudent 获取数据, 将数据组合成 JSON 发送给 AI 模型,并将 AI 返回的分析结果存入 Redis 缓存。 examID: 需要分析的考试 ID。 studentID: 需要分析的学生 ID。 返回 AI 生成的分析文本和可能发生的错误。
func AnalyzeClass ¶
func AnalyzeClass(examID uint) (models.ClassMetric, error)
AnalyzeClass 分析指定考试的班级整体指标。 如果已有分析结果,则直接返回;否则,计算各项统计指标(总分、平均分、最高分、最低分、中位数、标准差、分数段分布)并存入数据库。 examID: 需要分析的考试 ID。 返回计算出的班级指标和可能发生的错误。
func AnalyzeKeypoint ¶
func AnalyzeKeypoint(examID uint) (models.KeypointMetricResp, error)
AnalyzeKeypoint 分析指定考试的知识点掌握情况。 计算每个知识点的总分值、学生平均得分、参与学生数以及平均得分率(保留两位小数)。 examID: 需要分析的考试 ID。 返回包含各知识点指标的响应结构和可能发生的错误。
func AnalyzeStudent ¶
func AnalyzeStudent(examID uint, studentID uint) (models.StudentAnalysisResponse, error)
AnalyzeStudent 分析指定学生在某次考试中的表现。 计算学生的总分、历史成绩趋势(最近6次)、各知识点的得分、得分率和掌握程度。 examID: 需要分析的考试 ID。 studentID: 需要分析的学生 ID。 返回包含学生各项分析指标的响应结构和可能发生的错误。
func ClassHistoryAnalysis ¶
func ClassHistoryAnalysis(Subject string, ClassID uint) (models.ClassHistoryAnalysisResponse, error)
ClassHistoryAnalysis 获取指定班级和科目的历史考试分析数据 Subject: 科目名称 ClassID: 班级 ID 返回包含历次考试分析结果的响应结构和可能发生的错误
func CreatProblems ¶
func CreateClass ¶
CreateClass 创建班级
func CreateScores ¶
func CreateScores(examID uint, scoreInputs []models.ScoreInput) (int, error)
func CreateUser ¶
CreateUser 根据用户对象和明文密码创建新用户
func DeleteStudent ¶
func GenerateFinalPrompt ¶
func GeneratePresignedURL ¶
func GeneratePresignedURL(bucketName, objectName, region, endpoint, processParams string, expiration time.Duration) (string, error)
GeneratePresignedURL 为指定的 OSS 对象生成带处理参数的预签名 URL
func GenerateToken ¶
func GetAIStream ¶
func GetAIStream(ctx context.Context, message string) <-chan StreamChunk
GetAIStream 函数接收上下文和消息,返回一个只读的StreamChunk通道
func GetResourceUseExternal ¶
func GetStuRank ¶
func GetStuRank(examID uint) (models.StuRankResp, error)
GetStuRank 获取指定考试的学生排名信息,包括全班排名、进步最大学生和退步最大学生。 如果 ranks 表中没有当前考试的排名数据,则会根据 scores 表计算并生成排名数据存入 ranks 表。 examID: 需要获取排名的考试 ID。 返回包含排名信息的响应结构和可能发生的错误。
func GetUserByPhoneNumber ¶
GetUserByPhoneNumber 根据手机号获取用户
func GetUsernameByUserID ¶
func ListScores ¶
func ListScores(examID uint) ([]models.StudentScoreResponse, error)
func PicGenerate ¶
func PicGenerate(req PicGenerateRequest) (map[string]interface{}, error)
func RagRecommend ¶
func ResetPasswordService ¶
ResetPasswordService 重置密码(需要旧密码验证)
func SearchResources ¶
func StuAnalysis2String ¶
StuAnalysis2String将学生学情json转换为string
func UpdatePassword ¶
UpdatePassword 直接更新密码(不需要旧密码验证,用于忘记密码功能)
func UploadFileToOSS ¶
func UploadFileToOSS(localFilePath, ossObjectName string) (*oss.PutObjectResult, error)
UploadFileToOSS 将本地文件上传到指定的阿里云 OSS 存储空间
Types ¶
type AuthConfig ¶
type CommonResponse ¶
type CommonResponse struct {
Flag bool `json:"flag"`
Code int `json:"code"`
Desc string `json:"desc"`
Count interface{} `json:"count"`
Data interface{} `json:"data"`
}
func GeneratePPT ¶
func GeneratePPT(auth *AuthConfig, reqData GeneratePPTRequest) (*CommonResponse, error)
生成PPT(直接生成)
func GetPPTProgress ¶
func GetPPTProgress(auth *AuthConfig, sid string) (*CommonResponse, error)
查询PPT生成进度 GetPPTProgress 查询PPT生成进度 auth: 讯飞开放平台认证信息 sid: PPT生成的会话ID 返回包含进度信息的通用响应结构和可能发生的错误。 如果API返回“次数不足”,则返回一个特定的错误。
func GetPPTThemeList ¶
func GetPPTThemeList(auth *AuthConfig, reqData PPTThemeRequest) (*CommonResponse, error)
查询PPT主题列表
type EmailConfig ¶
EmailConfig 邮件配置
type EmailInfo ¶
type EmailInfo struct {
From string // 发件人邮箱
FromAlias string // 发件人别名
Password string // 邮箱密码
Host string // SMTP服务器地址
Port int // SMTP端口
To []string // 收件人列表
Subject string // 邮件主题
Content string // 邮件内容
ContentType string // 内容类型
}
smtpSend 发送邮件 EmailInfo 邮件信息结构体
type EmailVerificationService ¶
type EmailVerificationService struct {
// contains filtered or unexported fields
}
EmailVerificationService 邮件验证码服务实现
func NewEmailVerificationService ¶
func NewEmailVerificationService(config EmailConfig) *EmailVerificationService
NewEmailVerificationService 创建新的邮件验证码服务
func (*EmailVerificationService) SendCode ¶
func (s *EmailVerificationService) SendCode(recipient string) (string, error)
SendCode 发送验证码
func (*EmailVerificationService) VerifyCode ¶
func (s *EmailVerificationService) VerifyCode(recipient string, code string) bool
VerifyCode 验证验证码
type GeneratePPTRequest ¶
type Outline ¶
type Outline struct {
Title string `json:"title"`
SubTitle string `json:"subTitle"`
Chapters []OutlineChapter `json:"chapters"`
}
type OutlineChapter ¶
type OutlineChapter struct {
ChapterTitle string `json:"chapterTitle"`
ChapterContents []OutlineChapter `json:"chapterContents,omitempty"`
}
type PPTThemeItem ¶
type PPTThemeRequest ¶
type PicGenerateRequest ¶
type PicGenerateRequest struct {
Prompt string `json:"prompt"` // 提示词
Width int `json:"width"` // 图片宽度
Height int `json:"height"` // 图片高度
Seed int `json:"seed"` // 随机种子
}
PicGenerateRequest 图片生成请求参数
type Question ¶
type Question struct {
QuestionID string `json:"question_id"`
Key string `json:"key"`
Content string `json:"content"`
}
结构体定义
func ParseQuestions ¶
ParseQuestions 解析试题JSON到结构体切片
type StreamChunk ¶
type VerificationService ¶
type VerificationService interface {
// SendCode 发送验证码到指定接收者
// recipient: 接收者(如邮箱地址或手机号)
// 返回值: 生成的验证码和可能的错误
SendCode(recipient string) (string, error)
// VerifyCode 验证用户输入的验证码
// recipient: 接收者(如邮箱地址或手机号)
// code: 用户输入的验证码
// 返回值: 验证是否成功
VerifyCode(recipient string, code string) bool
}
VerificationService 验证码服务接口 使用方法: 1. 实现该接口的具体验证服务(如EmailVerificationService) 2. SendCode方法用于发送验证码到指定接收者,返回生成的验证码和可能的错误 3. VerifyCode方法用于验证用户输入的验证码是否正确