/** * @ File: * @ Date: 2021/1/25 16:15 * @ Author: JYQ * @ Description: */ package controller import ( "net/http" "video_course/service" ) type HrSensors struct { BaseController } type UpdateHrSensorsInfo struct { ResponseBase HrId int } // HrSensorsUpdate godoc // @Summary 心率带信息查询和更新 // @tags HrSensors // @Description 心率带信息查询和更新 // @Accept x-www-form-urlencoded // @Produce json // @Param token formData string true "Token" // @Param sn formData string true "心率带编号" // @Success 200 {object} controller.ResponseBase // @Router /HrSensors/HrSensorsUpdate [post] func (h *HrSensors) HrSensorsUpdate() (err error) { token := h.Ctx().PostForm("token") sn := h.Ctx().PostForm("sn") hrId, err := service.HrSensors{}.HrSensorsUpdate(token, sn) if err != nil { return } r := UpdateHrSensorsInfo{ newResponseBase(), hrId, } h.Ctx().JSON(http.StatusOK, r) return } type AddHRRtn struct { ResponseBase InClass int } // AddAppHeartRate godoc // @Summary App心率数据上报 // @tags HrSensors // @Description App心率数据上报 // @Accept x-www-form-urlencoded // @Produce json // @Param token formData string true "Token" // @Param duId formData int true "duId" // @Param sn formData string true "sn" // @Param hrId formData int true "心率带id" // @Param heartRate formData int true "心跳" // @Param rcvTime formData int true "时间戳毫秒" // @Param calories formData int true "卡路里" // @Param pureCalories formData int true "运动卡路里" // @Success 200 {object} controller.AddHRRtn // @Router /HrSensors/AddAppHeartRate [post] func (h *HrSensors) AddAppHeartRate() (err error) { token := h.Ctx().PostForm("token") duId := h.postIntNecessary("duId") sn := h.Ctx().PostForm("sn") hrId := h.postIntNecessary("hrId") heartRate := h.postIntNecessary("heartRate") rcvTime := h.postIntNecessary("rcvTime") calories := h.postIntNecessary("calories") pureCalories := h.postIntNecessary("pureCalories") inClass, err := service.HrSensors{}.AddAppHeartRate(token, duId, sn, hrId, heartRate, rcvTime, calories, pureCalories) if err != nil { return } r := AddHRRtn{ newResponseBase(), inClass, } h.Ctx().JSON(http.StatusOK, r) return }