Browse Source

update

master
shenjiachi 1 day ago
parent
commit
211b6c9bf7
6 changed files with 197 additions and 0 deletions
  1. +70
    -0
      app/hdl/home_page/hdl_basic.go
  2. +4
    -0
      app/md/home_page/md_basic.go
  3. +1
    -0
      app/router/router.go
  4. +46
    -0
      docs/docs.go
  5. +46
    -0
      docs/swagger.json
  6. +30
    -0
      docs/swagger.yaml

+ 70
- 0
app/hdl/home_page/hdl_basic.go View File

@@ -337,3 +337,73 @@ func RealTimePrice(c *gin.Context) {


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

// IsCanSignIn
// @Summary 蛋蛋星球-主页-是否能签到(获取)
// @Tags 主页
// @Description 是否能签到(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.IsCanSignInResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/homePage/isCanSignIn [get]
func IsCanSignIn(c *gin.Context) {
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、查找 `OneCirclesPublicPlatoonBasicSetting` 基础设置
energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
eggEnergyBasicSetting, err := energyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var videoRewardSystem *md2.VideoRewardSystemStruct
err = json.Unmarshal([]byte(eggEnergyBasicSetting.VideoRewardSystem), &videoRewardSystem)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
rewardTotalNum := utils.StrToInt(videoRewardSystem.RewardTotalNum)

//2、查询当前用户观看视屏记录
watchRecordsDb := implement.NewEggEnergyUserWatchRecordsDb(db.Db)
userWatchRecords, err := watchRecordsDb.EggEnergyUserWatchRecordsGetOneByParams(map[string]interface{}{
"key": "uid",
"value": user.Id,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

var isCan bool
now := time.Now()
if userWatchRecords != nil && userWatchRecords.ResidueWatchAdNum == rewardTotalNum && userWatchRecords.NextWatchAdDate.After(now) {
isCan = true
}

utils.FilePutContents("HomePageIsCanSignIn", utils.SerializeStr(map[string]interface{}{
"user_phone": user.Phone,
"user_uid": user.Id,
"is_can": isCan,
"time": now.Format("2006-01-02 15:04:05"),
}))
resp := md.IsCanSignInResp{
IsCan: isCan,
}
e.OutSuc(c, resp, nil)
return
}

+ 4
- 0
app/md/home_page/md_basic.go View File

@@ -29,3 +29,7 @@ type RealTimePriceResp struct {
IsRises bool `json:"is_rises"` IsRises bool `json:"is_rises"`
Rises string `json:"rises"` Rises string `json:"rises"`
} }

type IsCanSignInResp struct {
IsCan bool `json:"is_can_sign_in"`
}

+ 1
- 0
app/router/router.go View File

@@ -62,6 +62,7 @@ func route(r *gin.RouterGroup) {
rHomePage.GET("/index", home_page.HomePage) // 主页 rHomePage.GET("/index", home_page.HomePage) // 主页
rHomePage.GET("/adRule", home_page.HomePageWatchAdRule) // 可以观看广告列表 rHomePage.GET("/adRule", home_page.HomePageWatchAdRule) // 可以观看广告列表
rHomePage.GET("/realTimePrice", home_page.RealTimePrice) // 实时数据 rHomePage.GET("/realTimePrice", home_page.RealTimePrice) // 实时数据
rHomePage.GET("/isCanSignIn", home_page.IsCanSignIn) // 是否可以观看广告
} }


} }


+ 46
- 0
docs/docs.go View File

@@ -138,6 +138,44 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/homePage/isCanSignIn": {
"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.IsCanSignInResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/realTimePrice": { "/api/v1/homePage/realTimePrice": {
"get": { "get": {
"description": "实时数据(获取)", "description": "实时数据(获取)",
@@ -375,6 +413,14 @@ const docTemplate = `{
} }
} }
}, },
"md.IsCanSignInResp": {
"type": "object",
"properties": {
"is_can_sign_in": {
"type": "boolean"
}
}
},
"md.LoginReq": { "md.LoginReq": {
"type": "object", "type": "object",
"required": [ "required": [


+ 46
- 0
docs/swagger.json View File

@@ -132,6 +132,44 @@
} }
} }
}, },
"/api/v1/homePage/isCanSignIn": {
"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.IsCanSignInResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/homePage/realTimePrice": { "/api/v1/homePage/realTimePrice": {
"get": { "get": {
"description": "实时数据(获取)", "description": "实时数据(获取)",
@@ -369,6 +407,14 @@
} }
} }
}, },
"md.IsCanSignInResp": {
"type": "object",
"properties": {
"is_can_sign_in": {
"type": "boolean"
}
}
},
"md.LoginReq": { "md.LoginReq": {
"type": "object", "type": "object",
"required": [ "required": [


+ 30
- 0
docs/swagger.yaml View File

@@ -57,6 +57,11 @@ definitions:
description: 奖励X个活跃积分 description: 奖励X个活跃积分
type: string type: string
type: object type: object
md.IsCanSignInResp:
properties:
is_can_sign_in:
type: boolean
type: object
md.LoginReq: md.LoginReq:
properties: properties:
code: code:
@@ -219,6 +224,31 @@ paths:
summary: 蛋蛋星球-主页-基础信息(获取) summary: 蛋蛋星球-主页-基础信息(获取)
tags: tags:
- 主页 - 主页
/api/v1/homePage/isCanSignIn:
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.IsCanSignInResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 蛋蛋星球-主页-是否能签到(获取)
tags:
- 主页
/api/v1/homePage/realTimePrice: /api/v1/homePage/realTimePrice:
get: get:
consumes: consumes:


Loading…
Cancel
Save