蛋蛋星球-客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

hdl_guide_page.go 1.3 KiB

2 周前
12345678910111213141516171819202122232425262728293031323334353637383940
  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/utils"
  6. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. "time"
  10. )
  11. // GetRunningTime
  12. // @Summary 蛋蛋星球-引导页-运行时间
  13. // @Tags 引导页
  14. // @Description 运行时间
  15. // @Accept json
  16. // @Produce json
  17. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  18. // @Success 200 {string} "运行时间"
  19. // @Failure 400 {object} md.Response "具体错误"
  20. // @Router /api/v1/guidePage/runningTime [GET]
  21. func GetRunningTime(c *gin.Context) {
  22. basicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
  23. setting, err := basicSettingDb.EggEnergyBasicSettingGetOne()
  24. if err != nil {
  25. e.OutErr(c, e.ERR_DB_ORM)
  26. return
  27. }
  28. startTime := utils.TimeParseStd(setting.CreateAt)
  29. now := time.Now()
  30. duration := now.Sub(startTime)
  31. days := duration / time.Hour / 24 // 获取天数
  32. hours := duration / time.Hour % 24 // 获取小时部分
  33. minutes := duration % time.Hour / time.Minute // 获取分钟部分(先除去小时后再乘以60)
  34. seconds := int64(duration/time.Second) % 60
  35. runTime := fmt.Sprintf("%d:%d:%d:%d", days, hours, minutes, seconds) //收益倒计时
  36. e.OutSuc(c, runTime, nil)
  37. }