feat: file type.
This commit is contained in:
@@ -322,6 +322,7 @@ func (tc *TrainingController) AnalyzeByAI(c *gin.Context) {
|
|||||||
analysisType := c.PostForm("analysis_type")
|
analysisType := c.PostForm("analysis_type")
|
||||||
teachingPlanSource := c.PostForm("teaching_plan_source")
|
teachingPlanSource := c.PostForm("teaching_plan_source")
|
||||||
regionIDStr := c.PostForm("regionid")
|
regionIDStr := c.PostForm("regionid")
|
||||||
|
trainID := c.PostForm("trainid")
|
||||||
if analysisType == "" {
|
if analysisType == "" {
|
||||||
analysisType = analysisTypeHeartRateOnly
|
analysisType = analysisTypeHeartRateOnly
|
||||||
}
|
}
|
||||||
@@ -436,6 +437,7 @@ func (tc *TrainingController) AnalyzeByAI(c *gin.Context) {
|
|||||||
|
|
||||||
record := models.AIAnalysisRecord{
|
record := models.AIAnalysisRecord{
|
||||||
RegionID: regionID,
|
RegionID: regionID,
|
||||||
|
TrainId: trainID,
|
||||||
SourceType: teachingPlanSource,
|
SourceType: teachingPlanSource,
|
||||||
AnalysisType: analysisType,
|
AnalysisType: analysisType,
|
||||||
AnalysisResult: analysisResult.Content,
|
AnalysisResult: analysisResult.Content,
|
||||||
|
|||||||
@@ -218,6 +218,31 @@ func (tc *TrainingController) UploadTrainingSession(c *gin.Context) {
|
|||||||
writeSuccess(c, http.StatusOK, "session updated", nil)
|
writeSuccess(c, http.StatusOK, "session updated", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type cloudLessonPlanItem struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
OriginalFilename string `json:"originalFilename"`
|
||||||
|
FileSize int64 `json:"fileSize"`
|
||||||
|
UploaderName string `json:"uploaderName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc *TrainingController) ListCloudLessonPlans(c *gin.Context) {
|
||||||
|
var records []models.AppFile
|
||||||
|
if err := tc.DB.Where("file_type = ?", models.AppFileTypeLessonPlan).Order("created_at DESC").Find(&records).Error; err != nil {
|
||||||
|
writeError(c, http.StatusInternalServerError, "failed to list lesson plans")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
items := make([]cloudLessonPlanItem, 0, len(records))
|
||||||
|
for _, r := range records {
|
||||||
|
items = append(items, cloudLessonPlanItem{
|
||||||
|
ID: r.ID,
|
||||||
|
OriginalFilename: r.OriginalFilename,
|
||||||
|
FileSize: r.FileSize,
|
||||||
|
UploaderName: r.UploaderName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
writeSuccess(c, http.StatusOK, "query success", items)
|
||||||
|
}
|
||||||
|
|
||||||
// analysis_response.go
|
// analysis_response.go
|
||||||
type AnalysisResponse struct {
|
type AnalysisResponse struct {
|
||||||
Status string `json:"status"` // 状态码
|
Status string `json:"status"` // 状态码
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
type AIAnalysisRecord struct {
|
type AIAnalysisRecord struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
RegionID *uint32 `gorm:"index" json:"regionId"`
|
RegionID *uint32 `gorm:"index" json:"regionId"`
|
||||||
|
TrainId string `gorm:"size:255;index" json:"trainId"`
|
||||||
SourceType string `gorm:"size:32" json:"sourceType"`
|
SourceType string `gorm:"size:32" json:"sourceType"`
|
||||||
AnalysisType string `gorm:"size:32" json:"analysisType"`
|
AnalysisType string `gorm:"size:32" json:"analysisType"`
|
||||||
AnalysisResult string `gorm:"type:text" json:"analysisResult"`
|
AnalysisResult string `gorm:"type:text" json:"analysisResult"`
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ func SetupRouter() *gin.Engine {
|
|||||||
{
|
{
|
||||||
records.POST("", trainingController.CreateTrainingRecord)
|
records.POST("", trainingController.CreateTrainingRecord)
|
||||||
records.POST("/session", trainingController.UploadTrainingSession)
|
records.POST("/session", trainingController.UploadTrainingSession)
|
||||||
|
records.GET("/cloud-files", trainingController.ListCloudLessonPlans)
|
||||||
records.GET("/analysis", trainingController.HandleCurveAnalysis)
|
records.GET("/analysis", trainingController.HandleCurveAnalysis)
|
||||||
records.POST("/analysis-by-ai", trainingController.AnalyzeByAI)
|
records.POST("/analysis-by-ai", trainingController.AnalyzeByAI)
|
||||||
// 可扩展其他路由:GET, PUT, DELETE等
|
// 可扩展其他路由:GET, PUT, DELETE等
|
||||||
|
|||||||
Reference in New Issue
Block a user