Compare commits
12
Commits
442f0c0d1c
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea87fafb6b | ||
|
|
a1c12f0971 | ||
|
|
4a794a4ccc | ||
|
|
456ebdad45 | ||
|
|
7bf8bf3030 | ||
|
|
b0bbda3a55 | ||
|
|
813fc6aa01 | ||
|
|
2d5a890a14 | ||
|
|
ad016ee1ac | ||
|
|
5a6cd2a51b | ||
|
|
d378ddb0ab | ||
|
|
07fcde2148 |
@@ -0,0 +1,31 @@
|
|||||||
|
package adsapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"videoweb/app/api/proto"
|
||||||
|
"videoweb/app/service/configser"
|
||||||
|
"videoweb/pub/common"
|
||||||
|
"videoweb/pub/common/srvdef"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Click 广告点击上报
|
||||||
|
// @Tags 广告
|
||||||
|
// @Summary 广告点击上报
|
||||||
|
// @Description 用户点击广告时异步上报到广告中心。请求可带 appId 覆盖默认,缺省时按本站 appId 上报。
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param param body proto.AdsClickInfo true "参数"
|
||||||
|
// @Success 200 {string} json
|
||||||
|
// @Router /api/app/ads/click [POST]
|
||||||
|
func Click(c *gin.Context) {
|
||||||
|
var req proto.AdsClickInfo
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
common.ServerJSON(c, srvdef.ErrParamError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
configser.AsyncAdvertiseClick(strconv.FormatInt(req.AdsId, 10), int32(req.AppId))
|
||||||
|
common.ServerJSON(c, srvdef.Success, nil)
|
||||||
|
}
|
||||||
+2
-19
@@ -13,22 +13,5 @@ type AdsClickInfo struct {
|
|||||||
Location int64 `json:"location,omitempty" binding:"required"` // 位置ID
|
Location int64 `json:"location,omitempty" binding:"required"` // 位置ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdvitiseData struct {
|
// AdvitiseData 广告数据,直接使用媒资中心返回的结构
|
||||||
HomeList []proxy.AdvitiseInfo `json:"homeList" bson:"homeList"` // 首页列表
|
type AdvitiseData = proxy.AdvitiseData
|
||||||
DetailTopList []proxy.AdvitiseInfo `json:"detailTopList" bson:"detailTopList"` // 详情页顶部广告
|
|
||||||
NineGridList []proxy.AdvitiseInfo `json:"nineGridList" bson:"nineGridList"` // 9宫格
|
|
||||||
DetailbannerList []proxy.AdvitiseInfo `json:"detailbannerList" bson:"detailbannerList"` // 详情banner
|
|
||||||
LaunchScreenList []proxy.AdvitiseInfo `json:"launchScreenList"` // 启动页广告
|
|
||||||
FloatingList []proxy.AdvitiseInfo `json:"floatingList" bson:"floatingList"` // 悬浮小方块
|
|
||||||
AList []proxy.AdvitiseInfo `json:"AList"` // 固定12广告位
|
|
||||||
BList []proxy.AdvitiseInfo `json:"BList"` // 固定13广告位
|
|
||||||
DialogList []proxy.AdvitiseInfo `json:"dialogList" bson:"dialogList"` // 弹窗广告
|
|
||||||
BottomBanner []proxy.AdvitiseInfo `json:"bottomBanner" bson:"bottomBanner"` // 底部banner
|
|
||||||
|
|
||||||
VideoInfoList []proxy.AdvitiseInfo `json:"videoInfoList" bson:"videoInfoList"` // 视频详情
|
|
||||||
DownList []proxy.AdvitiseInfo `json:"downList" bson:"downList"` // 底部广告
|
|
||||||
FriendList []proxy.AdvitiseInfo `json:"friendList" bson:"friendList"` // 友链
|
|
||||||
TitleList []proxy.AdvitiseInfo `json:"titleList" bson:"titleList"` // 标题广告
|
|
||||||
PlayList []proxy.AdvitiseInfo `json:"playList" bson:"playList"` // 播放强制跳转
|
|
||||||
PauseyList []proxy.AdvitiseInfo `json:"pauseyList" bson:"pauseyList"` // 暂停广告
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-1
@@ -24,11 +24,12 @@ attack:
|
|||||||
h5key: "kaFttDJRcahRMTI7"
|
h5key: "kaFttDJRcahRMTI7"
|
||||||
windowDurationSeconds: 60
|
windowDurationSeconds: 60
|
||||||
pprof: false
|
pprof: false
|
||||||
host: "172.104.181.99"
|
host: "172.104.166.87"
|
||||||
listenAddr: "20001"
|
listenAddr: "20001"
|
||||||
origDomain: "https://yuan.bbaazz.me/"
|
origDomain: "https://yuan.bbaazz.me/"
|
||||||
trustedProxies: ""
|
trustedProxies: ""
|
||||||
bucketVideoAddressV2: "http://139.162.27.29:19996"
|
bucketVideoAddressV2: "http://139.162.27.29:19996"
|
||||||
|
versionUrl: "http://139.162.47.194:8089"
|
||||||
adCenter:
|
adCenter:
|
||||||
apiDomain: "https://adopenapi.adcs01.top"
|
apiDomain: "https://adopenapi.adcs01.top"
|
||||||
merchantCode: "1991129808640122880"
|
merchantCode: "1991129808640122880"
|
||||||
|
|||||||
+114
-121
@@ -2308,123 +2308,6 @@ const docTemplate = `{
|
|||||||
"TranTypeAdminAdjust"
|
"TranTypeAdminAdjust"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"proto.AdvitiseData": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"AList": {
|
|
||||||
"description": "固定12广告位",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"BList": {
|
|
||||||
"description": "固定13广告位",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bottomBanner": {
|
|
||||||
"description": "底部banner",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"detailTopList": {
|
|
||||||
"description": "详情页顶部广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"detailbannerList": {
|
|
||||||
"description": "详情banner",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dialogList": {
|
|
||||||
"description": "弹窗广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"downList": {
|
|
||||||
"description": "底部广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"floatingList": {
|
|
||||||
"description": "悬浮小方块",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"friendList": {
|
|
||||||
"description": "友链",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"homeList": {
|
|
||||||
"description": "首页列表",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"launchScreenList": {
|
|
||||||
"description": "启动页广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nineGridList": {
|
|
||||||
"description": "9宫格",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pauseyList": {
|
|
||||||
"description": "暂停广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"playList": {
|
|
||||||
"description": "播放强制跳转",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"titleList": {
|
|
||||||
"description": "标题广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"videoInfoList": {
|
|
||||||
"description": "视频详情",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"proto.AnnouncementItem": {
|
"proto.AnnouncementItem": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -2526,7 +2409,7 @@ const docTemplate = `{
|
|||||||
"description": "广告",
|
"description": "广告",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -3147,7 +3030,7 @@ const docTemplate = `{
|
|||||||
"description": "广告配置",
|
"description": "广告配置",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -3442,7 +3325,7 @@ const docTemplate = `{
|
|||||||
"description": "广告",
|
"description": "广告",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -5357,7 +5240,7 @@ const docTemplate = `{
|
|||||||
"description": "广告",
|
"description": "广告",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -5498,6 +5381,116 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"proxy.AdvitiseData": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"appInfoAList": {
|
||||||
|
"description": "应用管理广告A",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"appInfoBList": {
|
||||||
|
"description": "应用管理广告B",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dialogList": {
|
||||||
|
"description": "弹窗广告",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"forcedJumpList": {
|
||||||
|
"description": "强制跳转广告",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"friendList": {
|
||||||
|
"description": "友链",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"homeList": {
|
||||||
|
"description": "首页列表",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hotAppList": {
|
||||||
|
"description": "热门应用",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mustAppList": {
|
||||||
|
"description": "必备精品",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"newAppList": {
|
||||||
|
"description": "最新上架",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nineGridList": {
|
||||||
|
"description": "9宫格",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"stopList": {
|
||||||
|
"description": "暂停广告",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"titleAppList": {
|
||||||
|
"description": "标题广告(APP名称)",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"videoDownList": {
|
||||||
|
"description": "帖子详情(下)",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"videoList": {
|
||||||
|
"description": "视频列表",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"videoTopList": {
|
||||||
|
"description": "帖子详情(上)",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"proxy.AdvitiseInfo": {
|
"proxy.AdvitiseInfo": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
+114
-121
@@ -2306,123 +2306,6 @@
|
|||||||
"TranTypeAdminAdjust"
|
"TranTypeAdminAdjust"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"proto.AdvitiseData": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"AList": {
|
|
||||||
"description": "固定12广告位",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"BList": {
|
|
||||||
"description": "固定13广告位",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bottomBanner": {
|
|
||||||
"description": "底部banner",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"detailTopList": {
|
|
||||||
"description": "详情页顶部广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"detailbannerList": {
|
|
||||||
"description": "详情banner",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dialogList": {
|
|
||||||
"description": "弹窗广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"downList": {
|
|
||||||
"description": "底部广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"floatingList": {
|
|
||||||
"description": "悬浮小方块",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"friendList": {
|
|
||||||
"description": "友链",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"homeList": {
|
|
||||||
"description": "首页列表",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"launchScreenList": {
|
|
||||||
"description": "启动页广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nineGridList": {
|
|
||||||
"description": "9宫格",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pauseyList": {
|
|
||||||
"description": "暂停广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"playList": {
|
|
||||||
"description": "播放强制跳转",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"titleList": {
|
|
||||||
"description": "标题广告",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"videoInfoList": {
|
|
||||||
"description": "视频详情",
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"proto.AnnouncementItem": {
|
"proto.AnnouncementItem": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -2524,7 +2407,7 @@
|
|||||||
"description": "广告",
|
"description": "广告",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -3145,7 +3028,7 @@
|
|||||||
"description": "广告配置",
|
"description": "广告配置",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -3440,7 +3323,7 @@
|
|||||||
"description": "广告",
|
"description": "广告",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -5355,7 +5238,7 @@
|
|||||||
"description": "广告",
|
"description": "广告",
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/proto.AdvitiseData"
|
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -5496,6 +5379,116 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"proxy.AdvitiseData": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"appInfoAList": {
|
||||||
|
"description": "应用管理广告A",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"appInfoBList": {
|
||||||
|
"description": "应用管理广告B",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dialogList": {
|
||||||
|
"description": "弹窗广告",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"forcedJumpList": {
|
||||||
|
"description": "强制跳转广告",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"friendList": {
|
||||||
|
"description": "友链",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"homeList": {
|
||||||
|
"description": "首页列表",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hotAppList": {
|
||||||
|
"description": "热门应用",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mustAppList": {
|
||||||
|
"description": "必备精品",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"newAppList": {
|
||||||
|
"description": "最新上架",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nineGridList": {
|
||||||
|
"description": "9宫格",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"stopList": {
|
||||||
|
"description": "暂停广告",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"titleAppList": {
|
||||||
|
"description": "标题广告(APP名称)",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"videoDownList": {
|
||||||
|
"description": "帖子详情(下)",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"videoList": {
|
||||||
|
"description": "视频列表",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"videoTopList": {
|
||||||
|
"description": "帖子详情(上)",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/proxy.AdvitiseInfo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"proxy.AdvitiseInfo": {
|
"proxy.AdvitiseInfo": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
+82
-87
@@ -122,89 +122,6 @@ definitions:
|
|||||||
- TranTypeDarkAlley
|
- TranTypeDarkAlley
|
||||||
- TranTypeVideoUnlock
|
- TranTypeVideoUnlock
|
||||||
- TranTypeAdminAdjust
|
- TranTypeAdminAdjust
|
||||||
proto.AdvitiseData:
|
|
||||||
properties:
|
|
||||||
AList:
|
|
||||||
description: 固定12广告位
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
BList:
|
|
||||||
description: 固定13广告位
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
bottomBanner:
|
|
||||||
description: 底部banner
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
detailTopList:
|
|
||||||
description: 详情页顶部广告
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
detailbannerList:
|
|
||||||
description: 详情banner
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
dialogList:
|
|
||||||
description: 弹窗广告
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
downList:
|
|
||||||
description: 底部广告
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
floatingList:
|
|
||||||
description: 悬浮小方块
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
friendList:
|
|
||||||
description: 友链
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
homeList:
|
|
||||||
description: 首页列表
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
launchScreenList:
|
|
||||||
description: 启动页广告
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
nineGridList:
|
|
||||||
description: 9宫格
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
pauseyList:
|
|
||||||
description: 暂停广告
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
playList:
|
|
||||||
description: 播放强制跳转
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
titleList:
|
|
||||||
description: 标题广告
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
videoInfoList:
|
|
||||||
description: 视频详情
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/proxy.AdvitiseInfo'
|
|
||||||
type: array
|
|
||||||
type: object
|
|
||||||
proto.AnnouncementItem:
|
proto.AnnouncementItem:
|
||||||
properties:
|
properties:
|
||||||
content:
|
content:
|
||||||
@@ -277,7 +194,7 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
advitise:
|
advitise:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/proto.AdvitiseData'
|
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||||
description: 广告
|
description: 广告
|
||||||
category:
|
category:
|
||||||
allOf:
|
allOf:
|
||||||
@@ -719,7 +636,7 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
advitise:
|
advitise:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/proto.AdvitiseData'
|
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||||
description: 广告配置
|
description: 广告配置
|
||||||
config:
|
config:
|
||||||
allOf:
|
allOf:
|
||||||
@@ -916,7 +833,7 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
advitise:
|
advitise:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/proto.AdvitiseData'
|
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||||
description: 广告
|
description: 广告
|
||||||
bottonTranslations:
|
bottonTranslations:
|
||||||
allOf:
|
allOf:
|
||||||
@@ -2266,7 +2183,7 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
advitise:
|
advitise:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/definitions/proto.AdvitiseData'
|
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||||
description: 广告
|
description: 广告
|
||||||
coverImg:
|
coverImg:
|
||||||
description: 封面
|
description: 封面
|
||||||
@@ -2363,6 +2280,84 @@ definitions:
|
|||||||
description: 总共数量
|
description: 总共数量
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
proxy.AdvitiseData:
|
||||||
|
properties:
|
||||||
|
appInfoAList:
|
||||||
|
description: 应用管理广告A
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
appInfoBList:
|
||||||
|
description: 应用管理广告B
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
dialogList:
|
||||||
|
description: 弹窗广告
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
forcedJumpList:
|
||||||
|
description: 强制跳转广告
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
friendList:
|
||||||
|
description: 友链
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
homeList:
|
||||||
|
description: 首页列表
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
hotAppList:
|
||||||
|
description: 热门应用
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
mustAppList:
|
||||||
|
description: 必备精品
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
newAppList:
|
||||||
|
description: 最新上架
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
nineGridList:
|
||||||
|
description: 9宫格
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
stopList:
|
||||||
|
description: 暂停广告
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
titleAppList:
|
||||||
|
description: 标题广告(APP名称)
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
videoDownList:
|
||||||
|
description: 帖子详情(下)
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
videoList:
|
||||||
|
description: 视频列表
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
videoTopList:
|
||||||
|
description: 帖子详情(上)
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/proxy.AdvitiseInfo'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
proxy.AdvitiseInfo:
|
proxy.AdvitiseInfo:
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
|
"videoweb/app/api/adsapi"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func adsRouter(r *gin.Engine) {
|
||||||
|
r.POST("/api/app/ads/click", adsapi.Click)
|
||||||
|
}
|
||||||
@@ -119,6 +119,7 @@ func registeRouter(r *gin.Engine) {
|
|||||||
appInfoRouter(r)
|
appInfoRouter(r)
|
||||||
translationRouter(r)
|
translationRouter(r)
|
||||||
statcenterRouter(r)
|
statcenterRouter(r)
|
||||||
|
adsRouter(r)
|
||||||
r.GET("/notpage", templatecache.WithCache(time.Minute*1), home.PageNotFound)
|
r.GET("/notpage", templatecache.WithCache(time.Minute*1), home.PageNotFound)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func UpdateAppListCache(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
// 广告位 A(code=12)
|
// 广告位 A(code=12)
|
||||||
if category.Code == 12 {
|
if category.Code == 12 {
|
||||||
for _, ad := range advitise.AList {
|
for _, ad := range advitise.AppInfoAList {
|
||||||
apps = append(apps, proto.AppInfoData{
|
apps = append(apps, proto.AppInfoData{
|
||||||
AdvitiseId: ad.Id,
|
AdvitiseId: ad.Id,
|
||||||
CategoryId: category.Id,
|
CategoryId: category.Id,
|
||||||
@@ -137,7 +137,7 @@ func UpdateAppListCache(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
// 广告位 B(code=13)
|
// 广告位 B(code=13)
|
||||||
if category.Code == 13 {
|
if category.Code == 13 {
|
||||||
for _, ad := range advitise.BList {
|
for _, ad := range advitise.AppInfoBList {
|
||||||
apps = append(apps, proto.AppInfoData{
|
apps = append(apps, proto.AppInfoData{
|
||||||
AdvitiseId: ad.Id,
|
AdvitiseId: ad.Id,
|
||||||
CategoryId: category.Id,
|
CategoryId: category.Id,
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package configser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"videoweb/app/appg"
|
||||||
|
"videoweb/pub/common/godef"
|
||||||
|
"videoweb/pub/common/httputil"
|
||||||
|
"videoweb/pub/common/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type advertiseClickReq struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
AppId int32 `json:"appId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type advertiseClickResp struct {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolveAdvertiseAppId 请求带了 AppId 用请求的,否则回落到默认 advertiseAppId
|
||||||
|
func resolveAdvertiseAppId(reqAppId int32) int32 {
|
||||||
|
if reqAppId > 0 {
|
||||||
|
return reqAppId
|
||||||
|
}
|
||||||
|
return advertiseAppId
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdvertiseClickCenter 同步上报单条广告点击到广告中心。
|
||||||
|
// appId<=0 时回落到默认 advertiseAppId。
|
||||||
|
func AdvertiseClickCenter(advertiseId int64, appId int32) error {
|
||||||
|
versionUrl := strings.TrimRight(strings.TrimSpace(appg.Conf.VersionUrl), "/")
|
||||||
|
if versionUrl == "" {
|
||||||
|
return fmt.Errorf("versionUrl 未配置")
|
||||||
|
}
|
||||||
|
url := versionUrl + "/api/stat/advitise/v2/click"
|
||||||
|
body, _ := json.Marshal(advertiseClickReq{Id: advertiseId, AppId: resolveAdvertiseAppId(appId)})
|
||||||
|
var resp advertiseClickResp
|
||||||
|
code, err := httputil.Client().POSTJsonWithJResp(&resp, url, map[string]string{"Content-Type": "application/json"}, body)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("AdvertiseClickCenter POST fail", log.Any("url", url), log.Any("id", advertiseId), log.E(err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if code != http.StatusOK {
|
||||||
|
log.Error("AdvertiseClickCenter response status", log.Any("code", code), log.Any("id", advertiseId))
|
||||||
|
return fmt.Errorf("response status %d", code)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AsyncAdvertiseClick 异步上报广告点击,非数字 id 忽略。
|
||||||
|
// appId<=0 时回落到默认 advertiseAppId。
|
||||||
|
func AsyncAdvertiseClick(id string, appId int32) {
|
||||||
|
advertiseId, err := strconv.ParseInt(strings.TrimSpace(id), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("AsyncAdvertiseClick invalid id", log.Any("id", id))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
godef.Go(func() {
|
||||||
|
_ = AdvertiseClickCenter(advertiseId, appId)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,97 +1,113 @@
|
|||||||
package configser
|
package configser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"videoweb/app/api/proto"
|
"strings"
|
||||||
"videoweb/app/appg"
|
"videoweb/app/appg"
|
||||||
"videoweb/pub/adcenter"
|
"videoweb/pub/common/httputil"
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/netutil"
|
"videoweb/pub/common/netutil"
|
||||||
"videoweb/pub/storage/proxy"
|
"videoweb/pub/storage/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UpdateAdvitiseDataFromJt 从广告中心拉取福利页广告
|
// 广告中心应用ID(本站专用)
|
||||||
func UpdateAdvitiseDataFromJt() {
|
const advertiseAppId int32 = 12
|
||||||
config := GetConfigInfo()
|
|
||||||
var resp proto.AdvitiseData
|
// advertiseInfo 广告中心 /api/stat/advitise/v2/get 的广告条目
|
||||||
jtAds, err := adcenter.JtAdvertiseThreeServer(appg.Conf.AdCenter.ApiDomain, appg.Conf.AdCenter.MerchantCode, appg.Conf.AdCenter.AppCode, appg.Conf.AdCenter.AesKey)
|
type advertiseInfo struct {
|
||||||
|
Id int64 `json:"id"` // 广告id
|
||||||
|
Title string `json:"title"` // 广告标题
|
||||||
|
CoverImg string `json:"coverImg"` // 封面
|
||||||
|
LocId int32 `json:"locId"` // 位置id
|
||||||
|
JumpType int32 `json:"jumpType"` // 跳转方式
|
||||||
|
Link string `json:"link"` // 链接地址
|
||||||
|
Sort int64 `json:"sort"` // 排序
|
||||||
|
Tags string `json:"tags"` // 标签
|
||||||
|
Remark string `json:"remark"` // 备注描述
|
||||||
|
}
|
||||||
|
|
||||||
|
type advertiseReq struct {
|
||||||
|
AppId int32 `json:"appId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type advertiseRes struct {
|
||||||
|
AdvertiseList []advertiseInfo `json:"advertiseList"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchAdvertiseList 请求广告中心 /api/stat/advitise/v2/get
|
||||||
|
func fetchAdvertiseList() (*advertiseRes, error) {
|
||||||
|
versionUrl := strings.TrimRight(strings.TrimSpace(appg.Conf.VersionUrl), "/")
|
||||||
|
if versionUrl == "" {
|
||||||
|
return nil, fmt.Errorf("versionUrl 未配置")
|
||||||
|
}
|
||||||
|
url := versionUrl + "/api/stat/advitise/v2/get"
|
||||||
|
body, _ := json.Marshal(advertiseReq{AppId: advertiseAppId})
|
||||||
|
var resp advertiseRes
|
||||||
|
code, err := httputil.Client().POSTJsonWithJResp(&resp, url, map[string]string{"Content-Type": "application/json"}, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("JtAdvertiseThreeServer error occur", log.E(err))
|
return nil, err
|
||||||
|
}
|
||||||
|
if code != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("response status %d", code)
|
||||||
|
}
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAdvitiseData 从广告中心拉取广告并更新内存缓存,列表为空时重试一次
|
||||||
|
func UpdateAdvitiseData(ctx context.Context) {
|
||||||
|
resp, err := fetchAdvertiseList()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("UpdateAdvitiseData fetchAdvertiseList fail", log.E(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
adMap := make(map[string]adcenter.AdCacheInfo)
|
if len(resp.AdvertiseList) == 0 {
|
||||||
for _, loc := range jtAds {
|
resp, err = fetchAdvertiseList()
|
||||||
pos, err := strconv.Atoi(loc.AdvertiseLocationCode)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("广告位置代码错误,必须为数字", log.Any("code", loc.AdvertiseLocationCode))
|
log.Error("UpdateAdvitiseData fetchAdvertiseList retry fail", log.E(err))
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
//if pos < 100001 {
|
}
|
||||||
// continue
|
list := resp.AdvertiseList
|
||||||
//}
|
sort.SliceStable(list, func(i, j int) bool {
|
||||||
ads := make([]proxy.AdvitiseInfo, 0)
|
if list[i].LocId != list[j].LocId {
|
||||||
for _, ad := range loc.AdDetailInfoList {
|
return list[i].LocId < list[j].LocId
|
||||||
//extra := ad.GetExtraData()
|
}
|
||||||
ads = append(ads, proxy.AdvitiseInfo{
|
return list[i].Sort < list[j].Sort
|
||||||
Id: ad.AdvertiseCode,
|
|
||||||
Location: int64(pos),
|
|
||||||
Title: ad.AdvertiseName,
|
|
||||||
Images: netutil.MergeURL(config.ImgCdn, ad.GetCoverLsj()),
|
|
||||||
Link: ad.GetRealLink(),
|
|
||||||
})
|
})
|
||||||
adMap[ad.AdvertiseCode] = adcenter.AdCacheInfo{
|
|
||||||
AdvertiseCode: ad.AdvertiseCode,
|
config := GetConfigInfo()
|
||||||
CustomerCode: ad.CustomerCode,
|
data := proxy.AdvitiseData{}
|
||||||
AdvertiseName: ad.AdvertiseName,
|
|
||||||
AdvertiseUrl: ad.AdvertiseUrl,
|
for _, v := range list {
|
||||||
AdvertiseIcon: ad.AdvertiseIcon,
|
pos := int64(v.LocId)
|
||||||
AdvertiseType: ad.AdvertiseType,
|
info := proxy.AdvitiseInfo{
|
||||||
AdMode: ad.AdMode,
|
Id: strconv.FormatInt(v.Id, 10),
|
||||||
AppCode: ad.AppCode,
|
Location: pos,
|
||||||
LocationType: ad.LocationType,
|
Title: v.Title,
|
||||||
AdvertiseDesc: ad.AdvertiseDesc,
|
Images: netutil.MergeURL(config.ImgCdn, strings.TrimLeft(v.CoverImg, "/")),
|
||||||
PageType: ad.PageType,
|
Link: strings.ReplaceAll(v.Link, "inner://yinseinner/", "yinseinner://"),
|
||||||
StartTimeStamp: ad.StartTimeStamp,
|
|
||||||
EndTimeStamp: ad.EndTimeStamp,
|
|
||||||
Sort: ad.Sort,
|
|
||||||
AdExtData: ad.AdExtData,
|
|
||||||
DeptCode: loc.DeptCode,
|
|
||||||
MerchantCode: loc.MerchantCode,
|
|
||||||
AdvertiseLocationCode: loc.AdvertiseLocationCode,
|
|
||||||
AdvertiseLocationName: loc.AdvertiseLocationName,
|
|
||||||
DisplayMode: loc.DisplayMode,
|
|
||||||
AdvertiseHeight: loc.AdvertiseHeight,
|
|
||||||
AdvertiseWidth: loc.AdvertiseWidth,
|
|
||||||
MaterialType: loc.MaterialType,
|
|
||||||
AdLimit: loc.AdLimit,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
switch pos {
|
switch pos {
|
||||||
case 1: //弹窗
|
case 1:
|
||||||
resp.DialogList = ads
|
data.DialogList = append(data.DialogList, info)
|
||||||
case 2: // 应用
|
case 2:
|
||||||
resp.DetailTopList = ads
|
data.NineGridList = append(data.NineGridList, info)
|
||||||
case 3: // 横幅
|
case 3:
|
||||||
resp.NineGridList = ads
|
data.VideoTopList = append(data.VideoTopList, info)
|
||||||
resp.DetailbannerList = ads
|
data.VideoDownList = append(data.VideoDownList, info)
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
resp.AList = ads
|
data.AppInfoAList = append(data.AppInfoAList, info)
|
||||||
case 13:
|
case 13:
|
||||||
resp.BList = ads
|
data.AppInfoBList = append(data.AppInfoBList, info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheMgr.Lock.Lock()
|
CacheMgr.Lock.Lock()
|
||||||
defer CacheMgr.Lock.Unlock()
|
defer CacheMgr.Lock.Unlock()
|
||||||
CacheMgr.Advitise = resp
|
CacheMgr.Advitise = data
|
||||||
CacheMgr.AdvitiseMap = adMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetAdvertiseLocation(adverId string) (res adcenter.AdCacheInfo) {
|
|
||||||
CacheMgr.Lock.RLock()
|
|
||||||
defer CacheMgr.Lock.RUnlock()
|
|
||||||
if ad, ok := CacheMgr.AdvitiseMap[adverId]; ok {
|
|
||||||
res = ad
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"videoweb/app/api/proto"
|
"videoweb/app/api/proto"
|
||||||
"videoweb/app/service/translationser"
|
"videoweb/app/service/translationser"
|
||||||
"videoweb/pub/adcenter"
|
|
||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/netutil"
|
"videoweb/pub/common/netutil"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
@@ -35,7 +34,6 @@ type CacheInfo struct {
|
|||||||
Lock sync.RWMutex // 读写锁
|
Lock sync.RWMutex // 读写锁
|
||||||
Config proto.ConfigInfo // 系统配置缓存
|
Config proto.ConfigInfo // 系统配置缓存
|
||||||
Advitise proto.AdvitiseData
|
Advitise proto.AdvitiseData
|
||||||
AdvitiseMap map[string]adcenter.AdCacheInfo
|
|
||||||
TagCategoryList []proto.VideoTagCategoryData
|
TagCategoryList []proto.VideoTagCategoryData
|
||||||
TotalHistory int64
|
TotalHistory int64
|
||||||
IpBlackMaps map[string]struct{}
|
IpBlackMaps map[string]struct{}
|
||||||
@@ -61,14 +59,14 @@ func init() {
|
|||||||
func Start() {
|
func Start() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
UpdateConfigInfo(ctx)
|
UpdateConfigInfo(ctx)
|
||||||
UpdateAdvitiseDataFromJt()
|
UpdateAdvitiseData(ctx)
|
||||||
updateIpBlack()
|
updateIpBlack()
|
||||||
updateTagsCache()
|
updateTagsCache()
|
||||||
updateAppRichTexts()
|
updateAppRichTexts()
|
||||||
updateAnnouncements()
|
updateAnnouncements()
|
||||||
_, _ = skdCron.AddFunc("0 */5 * * * ?", func() {
|
_, _ = skdCron.AddFunc("0 */5 * * * ?", func() {
|
||||||
UpdateConfigInfo(ctx)
|
UpdateConfigInfo(ctx)
|
||||||
UpdateAdvitiseDataFromJt()
|
UpdateAdvitiseData(ctx)
|
||||||
updateIpBlack()
|
updateIpBlack()
|
||||||
updateTagsCache()
|
updateTagsCache()
|
||||||
updateAppRichTexts()
|
updateAppRichTexts()
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ func GetM3U8Ex(ctx *gin.Context) {
|
|||||||
mediaID, expireAt, origM3u8Name, ip, ticket,
|
mediaID, expireAt, origM3u8Name, ip, ticket,
|
||||||
)
|
)
|
||||||
|
|
||||||
if !ticketOK {
|
// if !ticketOK {
|
||||||
m3u8Name = H5M3U8FallbackPath
|
// m3u8Name = H5M3U8FallbackPath
|
||||||
log.Warn("【GetM3U8Ex】H5播放票据无效",
|
// log.Warn("【GetM3U8Ex】H5播放票据无效",
|
||||||
log.Any("mediaId", mediaID),
|
// log.Any("mediaId", mediaID),
|
||||||
log.Any("expireAt", expireAt),
|
// log.Any("expireAt", expireAt),
|
||||||
log.Any("ip", ip),
|
// log.Any("ip", ip),
|
||||||
log.Any("hasTicket", ticket != ""))
|
// log.Any("hasTicket", ticket != ""))
|
||||||
}
|
// }
|
||||||
|
|
||||||
countTowardDailyLimit := ticketOK && ticketInfo.Playable && !ticketInfo.Preview
|
countTowardDailyLimit := ticketOK && ticketInfo.Playable && !ticketInfo.Preview
|
||||||
if countTowardDailyLimit && appg.Conf.RunMod == string(consts.RunModeProd) {
|
if countTowardDailyLimit && appg.Conf.RunMod == string(consts.RunModeProd) {
|
||||||
@@ -152,7 +152,7 @@ func GetM3U8Ex(ctx *gin.Context) {
|
|||||||
log.Any("vipValid", vipValid),
|
log.Any("vipValid", vipValid),
|
||||||
log.E(countErr))
|
log.E(countErr))
|
||||||
} else if cnt > limit {
|
} else if cnt > limit {
|
||||||
m3u8Name = m3u8RateLimitFallback
|
// m3u8Name = m3u8RateLimitFallback
|
||||||
status = "rate_limited"
|
status = "rate_limited"
|
||||||
log.Warn("GetM3U8Ex daily rate limit, use fallback m3u8",
|
log.Warn("GetM3U8Ex daily rate limit, use fallback m3u8",
|
||||||
log.Any("ip", ip),
|
log.Any("ip", ip),
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package sitemap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/utils"
|
"videoweb/pub/common/utils"
|
||||||
"videoweb/pub/models/playletcategorymod"
|
"videoweb/pub/models/playletcategorymod"
|
||||||
|
"videoweb/pub/models/playletchaptermod"
|
||||||
"videoweb/pub/models/playletmod"
|
"videoweb/pub/models/playletmod"
|
||||||
"videoweb/pub/models/playlettagmod"
|
"videoweb/pub/models/playlettagmod"
|
||||||
"videoweb/pub/models/playletthememod"
|
"videoweb/pub/models/playletthememod"
|
||||||
@@ -19,6 +22,7 @@ type idWithTime struct {
|
|||||||
Id int64
|
Id int64
|
||||||
Slug string
|
Slug string
|
||||||
LastMod time.Time
|
LastMod time.Time
|
||||||
|
IsOriginal bool // 仅短剧使用:原创剧只算已加水印的剧集
|
||||||
}
|
}
|
||||||
|
|
||||||
type staticPageEntry struct {
|
type staticPageEntry struct {
|
||||||
@@ -144,7 +148,7 @@ func getURL(sg *SitemapGenerator) {
|
|||||||
if urls := buildPlayletPathURLs(webAddr, listed.items, "/detail", "weekly", 0.7); len(urls) > 0 {
|
if urls := buildPlayletPathURLs(webAddr, listed.items, "/detail", "weekly", 0.7); len(urls) > 0 {
|
||||||
_ = sg.writeSitemapFiles("sitemap-playletdetail", urls)
|
_ = sg.writeSitemapFiles("sitemap-playletdetail", urls)
|
||||||
}
|
}
|
||||||
if urls := buildPlayletPathURLs(webAddr, listed.items, "/play", "weekly", 0.6); len(urls) > 0 {
|
if urls := buildPlayletPlayURLs(webAddr, listed.items, firstPlayletChapterIDs(ctx, listed.items), "weekly", 0.6); len(urls) > 0 {
|
||||||
_ = sg.writeSitemapFiles("sitemap-playletplay", urls)
|
_ = sg.writeSitemapFiles("sitemap-playletplay", urls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,6 +198,78 @@ func buildPlayletPathURLs(webAddr string, items []idWithTime, prefix string, cha
|
|||||||
return urls
|
return urls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildPlayletPlayURLs 播放页直接写第一集的规范地址 /play/{slug}/{chapterId}/,
|
||||||
|
// 避免 /play/{slug}/ 在 h5 再 301 一次;没有可播放剧集的短剧不写入(h5 会返回 404)。
|
||||||
|
func buildPlayletPlayURLs(webAddr string, items []idWithTime, firstChapter map[int64]int64, changeFreq string, priority float32) []URL {
|
||||||
|
urls := make([]URL, 0, len(items))
|
||||||
|
for _, item := range items {
|
||||||
|
chapterID := firstChapter[item.Id]
|
||||||
|
if chapterID <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lastMod := formatLastMod(item.LastMod)
|
||||||
|
if lastMod == "" {
|
||||||
|
lastMod = time.Now().Format(time.DateOnly)
|
||||||
|
}
|
||||||
|
urls = append(urls, URL{
|
||||||
|
Loc: utils.JoinUrlPathKeepSlash(webAddr, entityPath("/play", item.Slug, item.Id)+strconv.FormatInt(chapterID, 10)+"/"),
|
||||||
|
LastMod: lastMod,
|
||||||
|
ChangeFreq: changeFreq,
|
||||||
|
Priority: priority,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return urls
|
||||||
|
}
|
||||||
|
|
||||||
|
// firstPlayletChapterIDs 取每部短剧的第一集 ID,规则与 app 详情接口的选集列表一致
|
||||||
|
// (按集号、ID 升序;原创剧只算已加水印的剧集),h5 播放页跳转也取这一集。
|
||||||
|
func firstPlayletChapterIDs(ctx context.Context, items []idWithTime) map[int64]int64 {
|
||||||
|
result := make(map[int64]int64, len(items))
|
||||||
|
original := make(map[int64]bool, len(items))
|
||||||
|
ids := make([]int64, 0, len(items))
|
||||||
|
for _, item := range items {
|
||||||
|
if item.Id > 0 {
|
||||||
|
ids = append(ids, item.Id)
|
||||||
|
original[item.Id] = item.IsOriginal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const batch = 500
|
||||||
|
for start := 0; start < len(ids); start += batch {
|
||||||
|
end := start + batch
|
||||||
|
if end > len(ids) {
|
||||||
|
end = len(ids)
|
||||||
|
}
|
||||||
|
list, err := playletchaptermod.FindManyPlayletChapter(ctx, bson.M{
|
||||||
|
playletchaptermod.FN.PlayletChapter.PlayletId: bson.M{"$in": ids[start:end]},
|
||||||
|
}, options.Find().
|
||||||
|
SetSort(bson.D{
|
||||||
|
{Key: playletchaptermod.FN.PlayletChapter.PlayletId, Value: 1},
|
||||||
|
{Key: playletchaptermod.FN.PlayletChapter.CurrentEpisode, Value: 1},
|
||||||
|
{Key: playletchaptermod.FN.PlayletChapter.Id, Value: 1},
|
||||||
|
}).
|
||||||
|
SetProjection(bson.M{
|
||||||
|
playletchaptermod.FN.PlayletChapter.Id: 1,
|
||||||
|
playletchaptermod.FN.PlayletChapter.PlayletId: 1,
|
||||||
|
playletchaptermod.FN.PlayletChapter.CurrentEpisode: 1,
|
||||||
|
playletchaptermod.FN.PlayletChapter.WatermarkVideoUrl: 1,
|
||||||
|
}))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("sitemap 查询短剧第一集失败", log.E(err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, ch := range list {
|
||||||
|
if ch == nil || ch.Id <= 0 || result[ch.PlayletId] > 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if original[ch.PlayletId] && ch.WatermarkVideoUrl == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
result[ch.PlayletId] = ch.Id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func formatLastMod(t time.Time) string {
|
func formatLastMod(t time.Time) string {
|
||||||
if t.IsZero() {
|
if t.IsZero() {
|
||||||
return ""
|
return ""
|
||||||
@@ -226,6 +302,7 @@ func getPlayletList(ctx context.Context) listedPlaylets {
|
|||||||
playletmod.FN.Playlet.ThemeIds: 1,
|
playletmod.FN.Playlet.ThemeIds: 1,
|
||||||
playletmod.FN.Playlet.TagIds: 1,
|
playletmod.FN.Playlet.TagIds: 1,
|
||||||
playletmod.FN.Playlet.CategoryIds: 1,
|
playletmod.FN.Playlet.CategoryIds: 1,
|
||||||
|
playletmod.FN.Playlet.IsOriginal: 1,
|
||||||
}))
|
}))
|
||||||
for _, info := range list {
|
for _, info := range list {
|
||||||
if info == nil || info.Id <= 0 {
|
if info == nil || info.Id <= 0 {
|
||||||
@@ -235,7 +312,7 @@ func getPlayletList(ctx context.Context) listedPlaylets {
|
|||||||
if lastMod.IsZero() {
|
if lastMod.IsZero() {
|
||||||
lastMod = info.OnlineAt
|
lastMod = info.OnlineAt
|
||||||
}
|
}
|
||||||
result.items = append(result.items, idWithTime{Id: info.Id, Slug: info.Slug, LastMod: lastMod})
|
result.items = append(result.items, idWithTime{Id: info.Id, Slug: info.Slug, LastMod: lastMod, IsOriginal: info.IsOriginal})
|
||||||
addListedIDs(result.themeIDs, info.ThemeIds)
|
addListedIDs(result.themeIDs, info.ThemeIds)
|
||||||
addListedIDs(result.tagIDs, info.TagIds)
|
addListedIDs(result.tagIDs, info.TagIds)
|
||||||
addListedIDs(result.categoryIDs, info.CategoryIds)
|
addListedIDs(result.categoryIDs, info.CategoryIds)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package sitemap
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestBuildPlayletPlayURLs(t *testing.T) {
|
||||||
|
items := []idWithTime{
|
||||||
|
{Id: 12, Slug: "xionnhge"},
|
||||||
|
{Id: 13, Slug: "nochapter"},
|
||||||
|
}
|
||||||
|
urls := buildPlayletPlayURLs("https://hgaidj.net", items, map[int64]int64{12: 27939}, "weekly", 0.6)
|
||||||
|
if len(urls) != 1 {
|
||||||
|
t.Fatalf("got %d urls, want 1 (playlet without chapters must be skipped)", len(urls))
|
||||||
|
}
|
||||||
|
if urls[0].Loc != "https://hgaidj.net/play/xionnhge/27939/" {
|
||||||
|
t.Errorf("Loc = %q", urls[0].Loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,6 +113,19 @@ func IsSlugAllDigits(s string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RandomSlugLength 随机 slug 长度
|
||||||
|
const RandomSlugLength = 8
|
||||||
|
|
||||||
|
// MakeRandomSlug 生成唯一的随机 slug(8 位小写字母);exists 返回 true 表示已被占用。
|
||||||
|
func MakeRandomSlug(exists func(string) bool) string {
|
||||||
|
for {
|
||||||
|
s := strings.ToLower(GetRandomLetters(RandomSlugLength))
|
||||||
|
if !exists(s) {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MakeUniqueSlug 生成唯一 slug;exists 返回 true 表示已被占用。生成结果不能全是数字。
|
// MakeUniqueSlug 生成唯一 slug;exists 返回 true 表示已被占用。生成结果不能全是数字。
|
||||||
func MakeUniqueSlug(source string, exists func(string) bool) string {
|
func MakeUniqueSlug(source string, exists func(string) bool) string {
|
||||||
pinyin := GetSlugInfo(source)
|
pinyin := GetSlugInfo(source)
|
||||||
|
|||||||
@@ -156,6 +156,30 @@ func QueryMedia(baseInfo *MediaQueryeReq, domain string) (result *VideoQueryResu
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryAdvitise(baseInfo *AppAdvitiseInfoReq, domain string) (result *AdvitiseQuerysResult, err error) {
|
||||||
|
result = &AdvitiseQuerysResult{}
|
||||||
|
paramJson, err := json.Marshal(baseInfo)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(domain) == 0 {
|
||||||
|
domain = DomainAddressRepair(domain, BucketVideoAddressV2)
|
||||||
|
}
|
||||||
|
url := domain
|
||||||
|
if !strings.Contains(domain, "/media/web/app/advitise") {
|
||||||
|
url = domain + "/media/web/app/advitise"
|
||||||
|
}
|
||||||
|
fr, err := http.Post(url, header, bytes.NewReader(paramJson))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(fr.Data, result); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func QueryMedias(baseInfo *MediaQueryesReq, domain string) (result *VideoQuerysResult, err error) {
|
func QueryMedias(baseInfo *MediaQueryesReq, domain string) (result *VideoQuerysResult, err error) {
|
||||||
result = &VideoQuerysResult{
|
result = &VideoQuerysResult{
|
||||||
Data: make([]MediaResp, 0),
|
Data: make([]MediaResp, 0),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package proxy
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"videoweb/pub/models/videoinformationmod"
|
"videoweb/pub/models/videoinformationmod"
|
||||||
@@ -408,6 +409,33 @@ type AdvitiseInfo struct {
|
|||||||
Images string `json:"images" bson:"images"` // 视频banner
|
Images string `json:"images" bson:"images"` // 视频banner
|
||||||
Link string `json:"link" bson:"link"` // 链接
|
Link string `json:"link" bson:"link"` // 链接
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON 兼容远端 id 返回数字或字符串两种格式,统一解析为字符串,避免大整数(雪花ID)在 JS 端丢精度
|
||||||
|
func (a *AdvitiseInfo) UnmarshalJSON(data []byte) error {
|
||||||
|
type alias AdvitiseInfo
|
||||||
|
aux := &struct {
|
||||||
|
Id json.RawMessage `json:"id"`
|
||||||
|
*alias
|
||||||
|
}{alias: (*alias)(a)}
|
||||||
|
if err := json.Unmarshal(data, aux); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
raw := strings.TrimSpace(string(aux.Id))
|
||||||
|
switch {
|
||||||
|
case raw == "" || raw == "null":
|
||||||
|
a.Id = ""
|
||||||
|
case strings.HasPrefix(raw, `"`):
|
||||||
|
var s string
|
||||||
|
if err := json.Unmarshal([]byte(raw), &s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
a.Id = s
|
||||||
|
default:
|
||||||
|
a.Id = raw
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type AdvitiseData struct {
|
type AdvitiseData struct {
|
||||||
DialogList []AdvitiseInfo `json:"dialogList" bson:"dialogList"` // 弹窗广告
|
DialogList []AdvitiseInfo `json:"dialogList" bson:"dialogList"` // 弹窗广告
|
||||||
HomeList []AdvitiseInfo `json:"homeList" bson:"homeList"` // 首页列表
|
HomeList []AdvitiseInfo `json:"homeList" bson:"homeList"` // 首页列表
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ func UploadImage(ctx context.Context, f *multipart.FileHeader, domain string) (p
|
|||||||
return proxy.UploadImg(f.Filename, buffer.Bytes(), domain)
|
return proxy.UploadImg(f.Filename, buffer.Bytes(), domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryAdvitiseList(ctx context.Context, in *proxy.AppAdvitiseInfoReq, domain string) (*proxy.AdvitiseQuerysResult, error) {
|
||||||
|
return proxy.QueryAdvitise(in, domain)
|
||||||
|
}
|
||||||
|
|
||||||
func QueryMedias(ctx context.Context, in *proxy.MediaQueryesReq, domain string) (*proxy.VideoQuerysResult, error) {
|
func QueryMedias(ctx context.Context, in *proxy.MediaQueryesReq, domain string) (*proxy.VideoQuerysResult, error) {
|
||||||
return proxy.QueryMedias(in, domain)
|
return proxy.QueryMedias(in, domain)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func AccLogin(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd, req.Code)
|
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd)
|
||||||
if err != nil || accInfo == nil {
|
if err != nil || accInfo == nil {
|
||||||
common.ServerJSON(c, err.Code, err.Msg)
|
common.ServerJSON(c, err.Code, err.Msg)
|
||||||
return
|
return
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ attack:
|
|||||||
h5key: "kaFttDJRcahRMTI7"
|
h5key: "kaFttDJRcahRMTI7"
|
||||||
windowDurationSeconds: 60
|
windowDurationSeconds: 60
|
||||||
pprof: false
|
pprof: false
|
||||||
host: "139.162.47.194"
|
host: "172.104.166.87"
|
||||||
listenAddr: "20002"
|
listenAddr: "20002"
|
||||||
origDomain: "https://yuan.bbaazz.me/"
|
origDomain: "https://yuan.bbaazz.me/"
|
||||||
trustedProxies: ""
|
trustedProxies: ""
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,6 @@ tar zvcf web_huangguo_web.tar.gz web_huangguo_web
|
|||||||
|
|
||||||
|
|
||||||
scp web_huangguo_web.tar.gz root@172.104.166.87:/data/uzip
|
scp web_huangguo_web.tar.gz root@172.104.166.87:/data/uzip
|
||||||
ssh root@172.104.166.87 "/server/web_huangguo/app/up_app.sh"
|
ssh root@172.104.166.87 "/server/web_huangguo/web/up_app.sh"
|
||||||
|
|
||||||
rm -rf ./web_huangguo_web ./web_huangguo_web.tar.gz
|
rm -rf ./web_huangguo_web ./web_huangguo_web.tar.gz
|
||||||
@@ -1276,8 +1276,7 @@ func ensureImportedPlayletSlug(ctx context.Context, playlet *playletmod.Playlet)
|
|||||||
if playlet == nil {
|
if playlet == nil {
|
||||||
return srvdef.New(srvdef.ErrParamError, "短剧数据为空", "")
|
return srvdef.New(srvdef.ErrParamError, "短剧数据为空", "")
|
||||||
}
|
}
|
||||||
source := utils.SlugSourceFromKeywordsOrTitle(playlet.SeoInfo.Keyworld, playlet.Title)
|
playlet.Slug = utils.MakeRandomSlug(func(slug string) bool {
|
||||||
playlet.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
|
|
||||||
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
|
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
|
||||||
playletmod.FN.Playlet.Slug: slug,
|
playletmod.FN.Playlet.Slug: slug,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import (
|
|||||||
"videoweb/pub/common/log"
|
"videoweb/pub/common/log"
|
||||||
"videoweb/pub/common/srvdef"
|
"videoweb/pub/common/srvdef"
|
||||||
"videoweb/pub/common/utils"
|
"videoweb/pub/common/utils"
|
||||||
"videoweb/pub/google"
|
|
||||||
"videoweb/pub/models/mwacc"
|
"videoweb/pub/models/mwacc"
|
||||||
"videoweb/web/webg"
|
"videoweb/web/webg"
|
||||||
|
|
||||||
"github.com/skip2/go-qrcode"
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -78,8 +76,8 @@ func isCustomerServiceRole(ctx context.Context, acc *mwacc.MwAcc) bool {
|
|||||||
return strings.Contains(roleName, "客服")
|
return strings.Contains(roleName, "客服")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 账号登录
|
// 账号登录(已取消谷歌验证,密码正确即登录)
|
||||||
func AccLogin(ctx context.Context, acc string, pwd string, code string) (*mwacc.MwAcc, *srvdef.SrvErr) {
|
func AccLogin(ctx context.Context, acc string, pwd string) (*mwacc.MwAcc, *srvdef.SrvErr) {
|
||||||
var data *mwacc.MwAcc
|
var data *mwacc.MwAcc
|
||||||
res, dataErr := mwacc.FindOneAccByFilter(ctx, bson.M{
|
res, dataErr := mwacc.FindOneAccByFilter(ctx, bson.M{
|
||||||
mwacc.FN.MwAcc.Acc: acc,
|
mwacc.FN.MwAcc.Acc: acc,
|
||||||
@@ -99,43 +97,18 @@ func AccLogin(ctx context.Context, acc string, pwd string, code string) (*mwacc.
|
|||||||
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !res.IsBase32 {
|
|
||||||
// 谷歌绑定二维码
|
|
||||||
googleUrl := google.NewGoogleAuth().GetQrcode(acc, res.Base32)
|
|
||||||
qrCodePNG, _ := qrcode.Encode(googleUrl, qrcode.Medium, 256)
|
|
||||||
|
|
||||||
bq := &mwacc.MwAcc{}
|
|
||||||
bq.Qurl = qrCodePNG
|
|
||||||
data = bq
|
|
||||||
} else {
|
|
||||||
// hf屏蔽
|
|
||||||
if webg.Conf.RunMod == "prod" && (res.RoleId != 46761 && res.RoleId != 29601) {
|
|
||||||
if code == "" {
|
|
||||||
return data, srvdef.New(srvdef.ErrCaptcha, srvdef.ErrCaptcha.Msg(), "")
|
|
||||||
}
|
|
||||||
result, Verr := google.NewGoogleAuth().VerifyCode(res.Base32, code)
|
|
||||||
if Verr != nil || !result {
|
|
||||||
return data, srvdef.New(srvdef.ErrCaptchaInvalid, srvdef.ErrCaptchaInvalid.Msg(), "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 通过验证,再次验证密码是否正确
|
|
||||||
pwd := crypt.StrToMd5(pwd)
|
|
||||||
if res.Pwd != pwd {
|
|
||||||
return data, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
|
||||||
}
|
|
||||||
getToken, err := generateToken(res.Id)
|
getToken, err := generateToken(res.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||||
}
|
}
|
||||||
|
// 更新最近登录时间
|
||||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||||
mwacc.FN.MwAcc.Id: res.Id,
|
mwacc.FN.MwAcc.Id: res.Id,
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||||
})
|
})
|
||||||
// 更新最近登录时间
|
|
||||||
data = res
|
data = res
|
||||||
data.Token = getToken
|
data.Token = getToken
|
||||||
}
|
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ func ensureThemeSlug(ctx context.Context, ac *playletthememod.PlayletTheme, excl
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
source := utils.SlugSourceFromKeywordsOrTitle(ac.SeoInfo.Keyworld, ac.Name)
|
ac.Slug = utils.MakeRandomSlug(func(slug string) bool {
|
||||||
ac.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
|
|
||||||
filter := bson.M{playletthememod.FN.PlayletTheme.Slug: slug}
|
filter := bson.M{playletthememod.FN.PlayletTheme.Slug: slug}
|
||||||
if excludeId > 0 {
|
if excludeId > 0 {
|
||||||
filter[playletthememod.FN.PlayletTheme.Id] = bson.M{"$ne": excludeId}
|
filter[playletthememod.FN.PlayletTheme.Id] = bson.M{"$ne": excludeId}
|
||||||
@@ -81,16 +80,7 @@ func prepareThemeSlugOnUpdate(ctx context.Context, id int64, info *playletthemem
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
name := info.Name
|
newSlug := utils.MakeRandomSlug(func(s string) bool {
|
||||||
if req.Name != nil {
|
|
||||||
name = strings.TrimSpace(*req.Name)
|
|
||||||
}
|
|
||||||
keywords := info.SeoInfo.Keyworld
|
|
||||||
if req.SeoInfo != nil {
|
|
||||||
keywords = normalizeSeoValue(*req.SeoInfo).Keyworld
|
|
||||||
}
|
|
||||||
source := utils.SlugSourceFromKeywordsOrTitle(keywords, name)
|
|
||||||
newSlug := utils.MakeUniqueSlug(source, func(s string) bool {
|
|
||||||
exist, _ := playletthememod.FindOnePlayletTheme(ctx, bson.M{
|
exist, _ := playletthememod.FindOnePlayletTheme(ctx, bson.M{
|
||||||
playletthememod.FN.PlayletTheme.Slug: s,
|
playletthememod.FN.PlayletTheme.Slug: s,
|
||||||
playletthememod.FN.PlayletTheme.Id: bson.M{"$ne": id},
|
playletthememod.FN.PlayletTheme.Id: bson.M{"$ne": id},
|
||||||
@@ -186,8 +176,7 @@ func ensurePlayletSlug(ctx context.Context, ac *playletmod.Playlet, excludeId in
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
source := utils.SlugSourceFromKeywordsOrTitle(ac.SeoInfo.Keyworld, ac.Title)
|
ac.Slug = utils.MakeRandomSlug(func(slug string) bool {
|
||||||
ac.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
|
|
||||||
filter := bson.M{playletmod.FN.Playlet.Slug: slug}
|
filter := bson.M{playletmod.FN.Playlet.Slug: slug}
|
||||||
if excludeId > 0 {
|
if excludeId > 0 {
|
||||||
filter[playletmod.FN.Playlet.Id] = bson.M{"$ne": excludeId}
|
filter[playletmod.FN.Playlet.Id] = bson.M{"$ne": excludeId}
|
||||||
@@ -219,16 +208,7 @@ func preparePlayletSlugOnUpdate(ctx context.Context, id int64, info *playletmod.
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
title := info.Title
|
newSlug := utils.MakeRandomSlug(func(s string) bool {
|
||||||
if req.Title != nil {
|
|
||||||
title = strings.TrimSpace(*req.Title)
|
|
||||||
}
|
|
||||||
keywords := info.SeoInfo.Keyworld
|
|
||||||
if req.SeoInfo != nil {
|
|
||||||
keywords = normalizeSeoValue(*req.SeoInfo).Keyworld
|
|
||||||
}
|
|
||||||
source := utils.SlugSourceFromKeywordsOrTitle(keywords, title)
|
|
||||||
newSlug := utils.MakeUniqueSlug(source, func(s string) bool {
|
|
||||||
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
|
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
|
||||||
playletmod.FN.Playlet.Slug: s,
|
playletmod.FN.Playlet.Slug: s,
|
||||||
playletmod.FN.Playlet.Id: bson.M{"$ne": id},
|
playletmod.FN.Playlet.Id: bson.M{"$ne": id},
|
||||||
|
|||||||
Reference in New Issue
Block a user