shenjiachi 1 день назад
Родитель
Сommit
a13d707008
8 измененных файлов: 981 добавлений и 2 удалений
  1. +339
    -0
      app/hdl/home_page/hdl_basic.go
  2. +31
    -0
      app/md/home_page/md_basic.go
  3. +8
    -0
      app/router/router.go
  4. +40
    -0
      app/svc/home_page/svc_basic.go
  5. +209
    -0
      docs/docs.go
  6. +209
    -0
      docs/swagger.json
  7. +143
    -0
      docs/swagger.yaml
  8. +2
    -2
      go.mod

+ 339
- 0
app/hdl/home_page/hdl_basic.go Просмотреть файл

@@ -0,0 +1,339 @@
package home_page

import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/home_page"
svc "applet/app/svc/home_page"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/shopspring/decimal"
"math"
"time"
)

// HomePage
// @Summary 蛋蛋星球-主页-基础信息(获取)
// @Tags 主页
// @Description 基础信息(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.HomePageResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/homePage/index [get]
func HomePage(c *gin.Context) {
now := time.Now()
val, exists := c.Get("user")
if !exists {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}
user, ok := val.(*model.User)
if !ok {
e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
return
}

//1、查找 `egg_energy_basic_setting` 基础设置
eggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
eggEnergyBasicSetting, err := eggEnergyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

//2、计算今日涨幅
err, rises, isRise, nowPrice, initialPrice := svc.CalcTodayEggEnergyPriceRises(db.Db, now)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

//3、获取当前用户 蛋蛋能量(可用+结算+今日签到预估蛋蛋能量)
var isSign bool
var signCountdown string
var signEggEnergy = "0.00"
var totalEggEnergy float64
var teamRewardSetting *md2.TeamRewardSettingStruct
// 3.1 获取团队收益设置 一轮持续时间
err = json.Unmarshal([]byte(eggEnergyBasicSetting.DirectPushReward), &teamRewardSetting)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
//3.2 计算用户是否在团队收益时间段内签到
var oneRoundDuration = utils.StrToInt(teamRewardSetting.OneRoundDuration)
startTime := now.Add(-time.Hour * time.Duration(oneRoundDuration)).Format("2006-01-02 15:04:05")
signInDb := implement.NewEggSignInDb(db.Db)
has, signIn, err := signInDb.EggSignInGetOne(startTime, now.Format("2006-01-02 15:04:05"), user.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

if has && utils.TimeParseStd(signIn.EndTime).After(now) {
//3.2.1 获取预估每秒获得蛋蛋能量数
estimatePerSecondEggEnergyValue, err1 := decimal.NewFromString(signIn.EstimatePerSecondEggEnergyValue)
if err1 != nil {
e.OutErr(c, e.ERR, err1.Error())
return
}
diffSeconds := decimal.NewFromInt(int64(now.Sub(utils.TimeParseStd(signIn.StartTime)).Seconds()))
signEggEnergy = estimatePerSecondEggEnergyValue.Mul(diffSeconds).String()
isSign = true
signCountdown = signIn.EndTime
}

// 3.3 查询个人及团队蛋蛋能量
amountDb := implement.NewUserVirtualAmountDb(db.Db)
personEggEnergy, err := amountDb.GetUserVirtualWalletBySession(user.Id, eggEnergyBasicSetting.PersonEggEnergyCoinId)
if err != nil {
return
}
teamEggEnergy, err := amountDb.GetUserVirtualWalletBySession(user.Id, eggEnergyBasicSetting.TeamEggEnergyCoinId)
if err != nil {
return
}
signEggEnergyValue, _ := decimal.NewFromString(signEggEnergy)
personEggEnergyValue, _ := decimal.NewFromString(personEggEnergy.Amount)
teamEggEnergyValue, _ := decimal.NewFromString(teamEggEnergy.Amount)

totalEggEnergy, _ = signEggEnergyValue.Add(personEggEnergyValue).Add(teamEggEnergyValue).Float64()

//4、活跃积分(个人+团队)
var totalActivePoints float64
personActivePoints, err := amountDb.GetUserVirtualWalletBySession(user.Id, eggEnergyBasicSetting.PersonEggPointsCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

teamActivePoints, err := amountDb.GetUserVirtualWalletBySession(user.Id, eggEnergyBasicSetting.TeamEggPointsCoinId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

totalActivePoints = utils.StrToFloat64(personActivePoints.Amount) + utils.StrToFloat64(teamActivePoints.Amount)

//5、计算当前基础速率、团队速率
nowBasalRate := utils.StrToFloat64(signEggEnergy) * 60 * 60 //每小时基础速率
var estimateLevel int
nowBasalRateValue := decimal.NewFromFloat(nowBasalRate)
for {
estimateLevel++
rewardDecrementValue := utils.StrToFloat64(teamRewardSetting.RewardDecrementValue) / 100
tmpRewardBase := decimal.NewFromFloat(math.Pow(rewardDecrementValue, float64(estimateLevel)))
tmpReward := nowBasalRateValue.Mul(tmpRewardBase)
rewardEndValue, _ := decimal.NewFromString(teamRewardSetting.RewardEndValue)
if !tmpReward.GreaterThanOrEqual(rewardEndValue) {
estimateLevel--
break
}
if estimateLevel == 99 {
e.OutErr(c, e.ERR, "奖励结束值设置有误")
return
}
}

relateDb := implement.NewUserRelateDb(db.Db)
userRelates, err := relateDb.FindUserRelateByParentUid(user.Id, estimateLevel)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
var userRelatesUids []string
var userRelatesMap = map[int64]model.UserRelate{}
if userRelates != nil {
for _, userRelate := range *userRelates {
userRelatesUids = append(userRelatesUids, utils.Int64ToStr(userRelate.Uid))
userRelatesMap[userRelate.Uid] = userRelate
}
}

var eggSignIns []*model.EggSignIn
if len(userRelatesUids) > 0 {
eggSignIns, err = signInDb.EggSignInFindByParams(map[string]interface{}{
"key": "uid",
"value": userRelatesUids,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
}

var nowTeamRate float64 //每小时基础速率
for _, vv := range eggSignIns {
rewardDecrementValue := utils.StrToFloat64(teamRewardSetting.RewardDecrementValue) / 100
tmpRewardBase := decimal.NewFromFloat(math.Pow(rewardDecrementValue, float64(userRelatesMap[vv.Uid].Level)))
tmpReward := nowBasalRateValue.Mul(tmpRewardBase)
rewardEndValue, _ := decimal.NewFromString(teamRewardSetting.RewardEndValue)
if tmpReward.GreaterThanOrEqual(rewardEndValue) {
tmpRewardValue, _ := tmpReward.Float64()
nowTeamRate += tmpRewardValue
}
}

decimalRate := decimal.NewFromInt(100) //百分比
risesValue, _ := decimal.NewFromFloat(rises).Mul(decimalRate).Float64()

var residueTimes = utils.TimeParseStd(signCountdown).Unix() - time.Now().Unix()

userDb := implement.NewUserDb(db.Db)
userCount, err := userDb.UserCount()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
utils.FilePutContents("HomePage", utils.SerializeStr(map[string]interface{}{
"user_phone": user.Phone,
"user_uid": user.Id,
"data": map[string]interface{}{
"is_sign": isSign,
"sign_end_date": signCountdown,
"sign_end_timestamp": utils.TimeParseStd(signCountdown).Unix(),
"residue_times": residueTimes,
"total_egg_energy": totalEggEnergy,
"sign_reward_egg_energy": utils.StrToFloat64(signIn.EstimatePerSecondEggEnergyValue),
"total_active_points": totalActivePoints,
"egg_energy_now_price": nowPrice,
"initial_price": initialPrice,
"is_rises": isRise,
"rises": risesValue,
"now_basal_rate": nowBasalRate,
"now_team_rate": nowTeamRate,
"user_count": userCount,
"nickname": user.Nickname,
},
}))

resp := md.HomePageResp{
IsSign: isSign,
SignEndTime: signCountdown,
TotalEggEnergy: utils.Float64ToStr(totalEggEnergy),
SignRewardEggEnergy: signIn.EstimatePerSecondEggEnergyValue,
TotalActivePoints: utils.Float64ToStr(totalActivePoints),
EggEnergyNowPrice: nowPrice,
InitialPrice: initialPrice,
IsRises: isRise,
Rises: utils.Float64ToStr(risesValue),
NowBasalRate: utils.Float64ToStr(nowBasalRate),
NowTeamRate: utils.Float64ToStr(nowTeamRate),
UserCount: userCount,
NickName: user.Nickname,
}

e.OutSuc(c, resp, nil)
return
}

// HomePageWatchAdRule
// @Summary 蛋蛋星球-主页-视频奖励规则(获取)
// @Tags 主页
// @Description 视频奖励规则(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.HomePageWatchAdRuleResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/homePage/adRule [get]
func HomePageWatchAdRule(c *gin.Context) {
energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
basicSetting, err := energyBasicSettingDb.EggEnergyBasicSettingGetOne()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var videoRewardSystem md2.VideoRewardSystemStruct
utils.Unserialize([]byte(basicSetting.VideoRewardSystem), &videoRewardSystem)
resp := md.HomePageWatchAdRuleResp{
RewardValue: videoRewardSystem.RewardValue,
RewardTotalNum: videoRewardSystem.RewardTotalNum,
IntervalMinutes: videoRewardSystem.IntervalMinutes,
EachRoundHour: videoRewardSystem.EachRoundHour,
}
e.OutSuc(c, resp, nil)
}

const HomePageRealTimeRedisKey = "Home_Page_Real_Time_Cache_Key"

// RealTimePrice
// @Summary 蛋蛋星球-主页-实时数据(获取)
// @Tags 主页
// @Description 实时数据(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.RealTimePriceResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/homePage/realTimePrice [get]
func RealTimePrice(c *gin.Context) {
var isRises, userCount, risesValue, nowPrice interface{}
var rises float64
redisKey := HomePageRealTimeRedisKey
redisValue, err := cache.GetString(redisKey)
if err != nil {
if err.Error() == "redigo: nil returned" {
now := time.Now()
err, rises, isRises, nowPrice, _ = svc.CalcTodayEggEnergyPriceRises(db.Db, now)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
userDb := implement.NewUserDb(db.Db)
userCount, err = userDb.UserCount()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
decimalRate := decimal.NewFromInt(100) //百分比
risesValue, _ = decimal.NewFromFloat(rises).Mul(decimalRate).Float64()

// 缓存 5 s
cache.SetEx(redisKey, utils.SerializeStr(map[string]interface{}{
"user_count": userCount,
"is_rises": isRises,
"rises": risesValue,
"egg_energy_now_price": nowPrice,
}), 5)
} else {
e.OutErr(c, e.ERR, err.Error())
return
}
} else {
var result map[string]interface{}
err1 := json.Unmarshal([]byte(redisValue), &result)
if err1 != nil {
e.OutErr(c, e.ERR, err1.Error())
return
}
userCount = result["user_count"]
isRises = result["is_rises"]
risesValue = result["rises"]
nowPrice = result["green_energy_now_price"]
}

isRisesResp, ok := isRises.(bool)
if !ok {
e.OutErr(c, e.ERR, "断言失败")
}

resp := md.RealTimePriceResp{
UserCount: utils.AnyToString(userCount),
NowPrice: utils.AnyToString(nowPrice),
IsRises: isRisesResp,
Rises: utils.AnyToString(risesValue),
}

e.OutSuc(c, resp, nil)
}

+ 31
- 0
app/md/home_page/md_basic.go Просмотреть файл

@@ -0,0 +1,31 @@
package md

type HomePageResp struct {
IsSign bool `json:"is_sign"` // 是否完成签到
SignEndTime string `json:"sign_end_time"` // 签到截止时间
TotalEggEnergy string `json:"total_egg_energy"` // 总蛋蛋能量
SignRewardEggEnergy string `json:"sign_reward_egg_energy"` // 签到奖励蛋蛋能量/秒
TotalActivePoints string `json:"total_active_points"` // 总活跃积分
EggEnergyNowPrice string `json:"egg_energy_now_price"` // 蛋蛋能量当前价格
InitialPrice string `json:"initial_price"` // 蛋蛋能量初始价格
IsRises bool `json:"is_rises"` // 是否涨价
Rises string `json:"rises"` // 涨/跌价百分比
NowBasalRate string `json:"now_basal_rate"` // 当前基础速率/小时
NowTeamRate string `json:"now_team_rate"` // 当前团队速率/小时
UserCount int64 `json:"user_count"` // 当前用户数量
NickName string `json:"nick_name"` // 用户名称
}

type HomePageWatchAdRuleResp struct {
RewardValue string `json:"reward_value"` //奖励X个活跃积分
RewardTotalNum string `json:"reward_total_num"` //一共X个奖励视屏
IntervalMinutes string `json:"interval_minutes"` //间隔X秒
EachRoundHour string `json:"each_round_hour"` //每一轮X个小时
}

type RealTimePriceResp struct {
UserCount string `json:"user_count"`
NowPrice string `json:"now_price"`
IsRises bool `json:"is_rises"`
Rises string `json:"rises"`
}

+ 8
- 0
app/router/router.go Просмотреть файл

@@ -4,6 +4,7 @@ import (
"applet/app/cfg"
"applet/app/hdl"
"applet/app/hdl/comm"
"applet/app/hdl/home_page"
"applet/app/mw"
_ "applet/docs"
"github.com/gin-gonic/gin"
@@ -56,6 +57,13 @@ func route(r *gin.RouterGroup) {
r.POST("/login", hdl.Login)
r.Use(mw.Auth) // 以下接口需要JWT验证
rComm(r.Group("/comm"))
rHomePage := r.Group("/homePage")
{
rHomePage.GET("/index", home_page.HomePage) // 主页
rHomePage.GET("/adRule", home_page.HomePageWatchAdRule) // 可以观看广告列表
rHomePage.GET("/realTimePrice", home_page.RealTimePrice) // 实时数据
}

}

func rComm(r *gin.RouterGroup) {


+ 40
- 0
app/svc/home_page/svc_basic.go Просмотреть файл

@@ -0,0 +1,40 @@
package svc

import (
"applet/app/db"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"github.com/shopspring/decimal"
"time"
"xorm.io/xorm"
)

// CalcTodayEggEnergyPriceRises 计算蛋蛋能量今日涨跌幅
func CalcTodayEggEnergyPriceRises(engine *xorm.Engine, now time.Time) (err error, rises float64, isRises bool, nowPrice string, initialPrice string) {

//1、查找昨日价格、今日价格 计算涨跌幅
var m *model.EggEnergyPrice
dateStr := now.AddDate(0, 0, -1).Format("2006-01-02")
hourStr := now.AddDate(0, 0, -1).Hour()
priceDb := implement.NewEggEnergyPriceDb(db.Db)
m, err = priceDb.EggEnergyPriceGetOneByParams(dateStr, hourStr)
if err != nil {
return err, 0, false, "", ""
}
initialPrice = m.Price
yesterdayPrice, _ := decimal.NewFromString(m.Price)
coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db)
coreData, err := coreDataDb.EggEnergyCoreDataGet()
if err != nil {
return err, 0, false, "", ""
}
nowPrice = coreData.NowPrice
todayPrice, _ := decimal.NewFromString(coreData.NowPrice)
if todayPrice.GreaterThanOrEqual(yesterdayPrice) {
isRises = true
rises, _ = todayPrice.Sub(yesterdayPrice).Div(yesterdayPrice).Float64()
} else {
rises, _ = yesterdayPrice.Sub(todayPrice).Div(todayPrice).Float64()
}
return nil, rises, isRises, nowPrice, initialPrice
}

+ 209
- 0
docs/docs.go Просмотреть файл

@@ -62,6 +62,120 @@ const docTemplate = `{
}
}
},
"/api/v1/homePage/adRule": {
"get": {
"description": "视频奖励规则(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"主页"
],
"summary": "蛋蛋星球-主页-视频奖励规则(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.HomePageWatchAdRuleResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/index": {
"get": {
"description": "基础信息(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"主页"
],
"summary": "蛋蛋星球-主页-基础信息(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.HomePageResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/realTimePrice": {
"get": {
"description": "实时数据(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"主页"
],
"summary": "蛋蛋星球-主页-实时数据(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.RealTimePriceResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/test": {
"get": {
"description": "Demo样例测试",
@@ -183,6 +297,84 @@ const docTemplate = `{
}
},
"definitions": {
"md.HomePageResp": {
"type": "object",
"properties": {
"egg_energy_now_price": {
"description": "蛋蛋能量当前价格",
"type": "string"
},
"initial_price": {
"description": "蛋蛋能量初始价格",
"type": "string"
},
"is_rises": {
"description": "是否涨价",
"type": "boolean"
},
"is_sign": {
"description": "是否完成签到",
"type": "boolean"
},
"nick_name": {
"description": "用户名称",
"type": "string"
},
"now_basal_rate": {
"description": "当前基础速率/小时",
"type": "string"
},
"now_team_rate": {
"description": "当前团队速率/小时",
"type": "string"
},
"rises": {
"description": "涨/跌价百分比",
"type": "string"
},
"sign_end_time": {
"description": "签到截止时间",
"type": "string"
},
"sign_reward_egg_energy": {
"description": "签到奖励蛋蛋能量/秒",
"type": "string"
},
"total_active_points": {
"description": "总活跃积分",
"type": "string"
},
"total_egg_energy": {
"description": "总蛋蛋能量",
"type": "string"
},
"user_count": {
"description": "当前用户数量",
"type": "integer"
}
}
},
"md.HomePageWatchAdRuleResp": {
"type": "object",
"properties": {
"each_round_hour": {
"description": "每一轮X个小时",
"type": "string"
},
"interval_minutes": {
"description": "间隔X秒",
"type": "string"
},
"reward_total_num": {
"description": "一共X个奖励视屏",
"type": "string"
},
"reward_value": {
"description": "奖励X个活跃积分",
"type": "string"
}
}
},
"md.LoginReq": {
"type": "object",
"required": [
@@ -212,6 +404,23 @@ const docTemplate = `{
}
}
},
"md.RealTimePriceResp": {
"type": "object",
"properties": {
"is_rises": {
"type": "boolean"
},
"now_price": {
"type": "string"
},
"rises": {
"type": "string"
},
"user_count": {
"type": "string"
}
}
},
"md.RegisterReq": {
"type": "object",
"required": [


+ 209
- 0
docs/swagger.json Просмотреть файл

@@ -56,6 +56,120 @@
}
}
},
"/api/v1/homePage/adRule": {
"get": {
"description": "视频奖励规则(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"主页"
],
"summary": "蛋蛋星球-主页-视频奖励规则(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.HomePageWatchAdRuleResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/index": {
"get": {
"description": "基础信息(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"主页"
],
"summary": "蛋蛋星球-主页-基础信息(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.HomePageResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/realTimePrice": {
"get": {
"description": "实时数据(获取)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"主页"
],
"summary": "蛋蛋星球-主页-实时数据(获取)",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
}
],
"responses": {
"200": {
"description": "具体数据",
"schema": {
"$ref": "#/definitions/md.RealTimePriceResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/test": {
"get": {
"description": "Demo样例测试",
@@ -177,6 +291,84 @@
}
},
"definitions": {
"md.HomePageResp": {
"type": "object",
"properties": {
"egg_energy_now_price": {
"description": "蛋蛋能量当前价格",
"type": "string"
},
"initial_price": {
"description": "蛋蛋能量初始价格",
"type": "string"
},
"is_rises": {
"description": "是否涨价",
"type": "boolean"
},
"is_sign": {
"description": "是否完成签到",
"type": "boolean"
},
"nick_name": {
"description": "用户名称",
"type": "string"
},
"now_basal_rate": {
"description": "当前基础速率/小时",
"type": "string"
},
"now_team_rate": {
"description": "当前团队速率/小时",
"type": "string"
},
"rises": {
"description": "涨/跌价百分比",
"type": "string"
},
"sign_end_time": {
"description": "签到截止时间",
"type": "string"
},
"sign_reward_egg_energy": {
"description": "签到奖励蛋蛋能量/秒",
"type": "string"
},
"total_active_points": {
"description": "总活跃积分",
"type": "string"
},
"total_egg_energy": {
"description": "总蛋蛋能量",
"type": "string"
},
"user_count": {
"description": "当前用户数量",
"type": "integer"
}
}
},
"md.HomePageWatchAdRuleResp": {
"type": "object",
"properties": {
"each_round_hour": {
"description": "每一轮X个小时",
"type": "string"
},
"interval_minutes": {
"description": "间隔X秒",
"type": "string"
},
"reward_total_num": {
"description": "一共X个奖励视屏",
"type": "string"
},
"reward_value": {
"description": "奖励X个活跃积分",
"type": "string"
}
}
},
"md.LoginReq": {
"type": "object",
"required": [
@@ -206,6 +398,23 @@
}
}
},
"md.RealTimePriceResp": {
"type": "object",
"properties": {
"is_rises": {
"type": "boolean"
},
"now_price": {
"type": "string"
},
"rises": {
"type": "string"
},
"user_count": {
"type": "string"
}
}
},
"md.RegisterReq": {
"type": "object",
"required": [


+ 143
- 0
docs/swagger.yaml Просмотреть файл

@@ -1,5 +1,62 @@
basePath: /api/v1
definitions:
md.HomePageResp:
properties:
egg_energy_now_price:
description: 蛋蛋能量当前价格
type: string
initial_price:
description: 蛋蛋能量初始价格
type: string
is_rises:
description: 是否涨价
type: boolean
is_sign:
description: 是否完成签到
type: boolean
nick_name:
description: 用户名称
type: string
now_basal_rate:
description: 当前基础速率/小时
type: string
now_team_rate:
description: 当前团队速率/小时
type: string
rises:
description: 涨/跌价百分比
type: string
sign_end_time:
description: 签到截止时间
type: string
sign_reward_egg_energy:
description: 签到奖励蛋蛋能量/秒
type: string
total_active_points:
description: 总活跃积分
type: string
total_egg_energy:
description: 总蛋蛋能量
type: string
user_count:
description: 当前用户数量
type: integer
type: object
md.HomePageWatchAdRuleResp:
properties:
each_round_hour:
description: 每一轮X个小时
type: string
interval_minutes:
description: 间隔X秒
type: string
reward_total_num:
description: 一共X个奖励视屏
type: string
reward_value:
description: 奖励X个活跃积分
type: string
type: object
md.LoginReq:
properties:
code:
@@ -20,6 +77,17 @@ definitions:
token:
type: string
type: object
md.RealTimePriceResp:
properties:
is_rises:
type: boolean
now_price:
type: string
rises:
type: string
user_count:
type: string
type: object
md.RegisterReq:
properties:
avatar:
@@ -101,6 +169,81 @@ paths:
summary: 通用请求-对象存储-上传许可链接(获取)
tags:
- 对象存储
/api/v1/homePage/adRule:
get:
consumes:
- application/json
description: 视频奖励规则(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.HomePageWatchAdRuleResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-主页-视频奖励规则(获取)
tags:
- 主页
/api/v1/homePage/index:
get:
consumes:
- application/json
description: 基础信息(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.HomePageResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-主页-基础信息(获取)
tags:
- 主页
/api/v1/homePage/realTimePrice:
get:
consumes:
- application/json
description: 实时数据(获取)
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
produces:
- application/json
responses:
"200":
description: 具体数据
schema:
$ref: '#/definitions/md.RealTimePriceResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-主页-实时数据(获取)
tags:
- 主页
/api/v1/test:
get:
consumes:


+ 2
- 2
go.mod Просмотреть файл

@@ -2,9 +2,9 @@ module applet

go 1.19

//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models
replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models
//
//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules
replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules

require (
github.com/boombuler/barcode v1.0.1


Загрузка…
Отмена
Сохранить