feat: swag.
This commit is contained in:
@@ -24,7 +24,17 @@ func NewStepTrainingController() *StepTrainingController {
|
||||
return &StepTrainingController{DB: config.DB}
|
||||
}
|
||||
|
||||
// 接收训练记录
|
||||
// @Summary 创建踏步训练记录
|
||||
// @Description 接收并保存踏步训练记录,包含心率和步频数据,异步计算回归结果
|
||||
// @Tags 踏步训练
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param record body SwagAPIResponse true "踏步训练记录"
|
||||
// @Security BearerAuth
|
||||
// @Success 201 {object} SwagAPIResponse "保存成功"
|
||||
// @Failure 400 {object} SwagAPIResponse "请求参数错误"
|
||||
// @Failure 401 {object} SwagAPIResponse "未认证"
|
||||
// @Router /step [post]
|
||||
func (tc *StepTrainingController) CreateTrainingRecord(c *gin.Context) {
|
||||
var record models.StepTrainRecord
|
||||
|
||||
@@ -123,6 +133,17 @@ func (tc *StepTrainingController) CreateTrainingRecord(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary 获取踏步训练记录列表
|
||||
// @Description 分页获取当前用户的踏步训练记录,按开始时间倒序
|
||||
// @Tags 踏步训练
|
||||
// @Produce json
|
||||
// @Param pageNum query int false "页码(默认1)"
|
||||
// @Param pageSize query int false "每页数量(默认10,最大100)"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} SwagAPIResponse "查询成功"
|
||||
// @Failure 400 {object} SwagAPIResponse "请求参数错误"
|
||||
// @Failure 401 {object} SwagAPIResponse "未认证"
|
||||
// @Router /step/train-records [get]
|
||||
func (tc *StepTrainingController) GetTrainingRecords(c *gin.Context) {
|
||||
// 定义分页参数结构
|
||||
type PaginationParams struct {
|
||||
@@ -191,6 +212,18 @@ func (tc *StepTrainingController) GetTrainingRecords(c *gin.Context) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary 获取踏步训练详情
|
||||
// @Description 根据训练ID获取踏步训练的详细信息,包含心率和步频数据
|
||||
// @Tags 踏步训练
|
||||
// @Produce json
|
||||
// @Param trainId path int true "训练ID"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} SwagAPIResponse "查询成功"
|
||||
// @Failure 400 {object} SwagAPIResponse "请求参数错误"
|
||||
// @Failure 401 {object} SwagAPIResponse "未认证"
|
||||
// @Failure 404 {object} SwagAPIResponse "训练记录不存在"
|
||||
// @Router /step/train-data/{trainId} [get]
|
||||
func (tc *StepTrainingController) GetTrainingRecordByTrainId(c *gin.Context) {
|
||||
// 从URL路径参数获取trainId
|
||||
trainId := c.Param("trainId")
|
||||
@@ -748,6 +781,17 @@ func (tc *StepTrainingController) GetRegressionResult(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary 获取训练排名
|
||||
// @Description 根据训练ID和回归类型获取训练排名
|
||||
// @Tags 踏步训练
|
||||
// @Produce json
|
||||
// @Param trainId path int true "训练ID"
|
||||
// @Param type query int true "回归类型: 1=线性回归 | 3=二次回归"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} SwagAPIResponse "查询成功"
|
||||
// @Failure 400 {object} SwagAPIResponse "请求参数错误"
|
||||
// @Failure 401 {object} SwagAPIResponse "未认证"
|
||||
// @Router /step/train-rank/{trainId} [get]
|
||||
func (tc *StepTrainingController) GetTrainingRank(c *gin.Context) {
|
||||
// 参数解析
|
||||
trainIdStr := c.Param("trainId")
|
||||
|
||||
Reference in New Issue
Block a user