|
- package hdl
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "fmt"
- "github.com/gin-gonic/gin"
- "time"
- )
-
- // GetRunningTime
- // @Summary 蛋蛋星球-引导页-运行时间
- // @Tags 引导页
- // @Description 运行时间
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {string} "运行时间"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/v1/guidePage/runningTime [GET]
- func GetRunningTime(c *gin.Context) {
- basicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
- setting, err := basicSettingDb.EggEnergyBasicSettingGetOne()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM)
- return
- }
- startTime := utils.TimeParseStd(setting.CreateAt)
- now := time.Now()
- duration := now.Sub(startTime)
- days := duration / time.Hour / 24 // 获取天数
- hours := duration / time.Hour % 24 // 获取小时部分
- minutes := duration % time.Hour / time.Minute // 获取分钟部分(先除去小时后再乘以60)
- seconds := int64(duration/time.Second) % 60
- runTime := fmt.Sprintf("%d:%d:%d:%d", days, hours, minutes, seconds) //收益倒计时
-
- e.OutSuc(c, runTime, nil)
- }
|