Compare commits
14
Commits
d6599ae004
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea87fafb6b | ||
|
|
a1c12f0971 | ||
|
|
4a794a4ccc | ||
|
|
456ebdad45 | ||
|
|
7bf8bf3030 | ||
|
|
b0bbda3a55 | ||
|
|
813fc6aa01 | ||
|
|
2d5a890a14 | ||
|
|
ad016ee1ac | ||
|
|
5a6cd2a51b | ||
|
|
d378ddb0ab | ||
|
|
07fcde2148 | ||
|
|
442f0c0d1c | ||
|
|
4efdbfeffc |
@@ -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)
|
||||
}
|
||||
+4
-147
@@ -1,10 +1,8 @@
|
||||
package authapi
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"videoweb/app/service/authser"
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/ipaddr"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/common/useragent"
|
||||
"videoweb/pub/pubdef"
|
||||
@@ -17,132 +15,17 @@ func requestUA(ctx *gin.Context) useragent.UA {
|
||||
return ua
|
||||
}
|
||||
|
||||
func applyRequestDevID(ua useragent.UA, devID string) useragent.UA {
|
||||
if v := strings.TrimSpace(devID); v != "" {
|
||||
ua.DevID = v
|
||||
}
|
||||
return ua
|
||||
}
|
||||
|
||||
type registerReq struct {
|
||||
AccountNo string `json:"accountNo" binding:"required"` // 账号
|
||||
Email string `json:"email" binding:"required"` // 邮箱
|
||||
Password string `json:"password" binding:"required"` // 明文密码
|
||||
AgentInviteCode string `json:"agentInviteCode"` // 邀请人的邀请码(可选)
|
||||
DevID string `json:"devID"` // 设备唯一标示(可选)
|
||||
Channel string `json:"channel"` // 渠道码(可选,用户无商区码时写入)
|
||||
}
|
||||
|
||||
type loginReq struct {
|
||||
Account string `json:"account" binding:"required"` // 账号或邮箱
|
||||
Password string `json:"password" binding:"required"` // 明文密码
|
||||
DevID string `json:"devID"` // 设备唯一标示(可选)
|
||||
Channel string `json:"channel"` // 渠道码(可选,用户无商区码时写入)
|
||||
}
|
||||
|
||||
type resetPasswordReq struct {
|
||||
AccountNo string `json:"accountNo" binding:"required"` // 账号
|
||||
Email string `json:"email" binding:"required"` // 邮箱
|
||||
NewPassword string `json:"newPassword" binding:"required"` // 新密码
|
||||
}
|
||||
|
||||
type updateProfileReq struct {
|
||||
NickName *string `json:"nickName"` // 新昵称(可选)
|
||||
Avatar *string `json:"avatar"` // 新头像 URL(可选)
|
||||
Introduction *string `json:"introduction"` // 简介(可选)
|
||||
PrivacyMode *bool `json:"privacyMode"` // 隐私模式:true-开启,false-关闭(可选)
|
||||
OldPassword *string `json:"oldPassword"` // 旧密码明文(修改密码时必填)
|
||||
NewPassword *string `json:"newPassword"` // 新密码明文(修改密码时必填)
|
||||
}
|
||||
|
||||
// GuestLogin 游客登录
|
||||
// @Tags 用户认证
|
||||
// @Summary 游客登录
|
||||
// @Description 按设备ID创建或找回游客账号;请求头可带 Authorization 复用已有游客会话。需传 X-User-Agent
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body authser.GuestLoginReq true "游客登录参数"
|
||||
// @Success 200 {object} authser.LoginResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/app/auth/guest [POST]
|
||||
func GuestLogin(ctx *gin.Context) {
|
||||
var req authser.GuestLoginReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
ua, err := common.GetUA(ctx)
|
||||
if err != nil {
|
||||
common.ServerJSON(ctx, srvdef.NoUA, nil)
|
||||
return
|
||||
}
|
||||
if req.DevID == "" {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, "devID不能为空")
|
||||
return
|
||||
}
|
||||
ua.DevID = req.DevID
|
||||
resp, serr := authser.GuestLogin(ctx, common.GetUserId(ctx), ipaddr.ResolveClientIP(ctx), &req, ua)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// Register 用户注册
|
||||
// @Tags 用户认证
|
||||
// @Summary 注册
|
||||
// @Description 传入账号、邮箱、明文密码。请求头带游客 Authorization 时升级该游客为普通用户,否则新建用户
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body registerReq true "注册参数"
|
||||
// @Success 200 {object} authser.LoginResp "注册成功,返回 token 及用户基本信息"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/app/auth/register [POST]
|
||||
func Register(ctx *gin.Context) {
|
||||
var req registerReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
ua := applyRequestDevID(requestUA(ctx), req.DevID)
|
||||
resp, serr := authser.Register(ctx, common.GetUserId(ctx), req.AccountNo, req.Email, req.Password, req.AgentInviteCode, ua, ipaddr.ResolveClientIP(ctx), req.Channel)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// Login 用户登录
|
||||
// @Tags 用户认证
|
||||
// @Summary 登录
|
||||
// @Description 账号或邮箱均可作为登录凭证
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body loginReq true "登录参数"
|
||||
// @Success 200 {object} authser.LoginResp "登录成功,返回 token 及用户基本信息"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/app/auth/login [POST]
|
||||
func Login(ctx *gin.Context) {
|
||||
var req loginReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
ua := applyRequestDevID(requestUA(ctx), req.DevID)
|
||||
resp, serr := authser.Login(ctx, req.Account, req.Password, ua, ipaddr.ResolveClientIP(ctx), req.Channel)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// UpdateProfile 修改用户资料
|
||||
// @Tags 用户认证
|
||||
// @Summary 修改用户资料(头像 / 简介 / 密码,可任意组合)
|
||||
// @Description 用户信息通过 token 获取,无需传账号;nickName、avatar、introduction、oldPassword+newPassword 均为可选,至少提供一项。修改密码时旧密码和新密码必须同时提供。
|
||||
// @Summary 修改用户资料(昵称 / 头像 / 简介 / 隐私模式,可任意组合)
|
||||
// @Description 按请求头 X-User-Agent 中的 devID 识别用户;nickName、avatar、introduction、privacyMode 均为可选,至少提供一项。
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body updateProfileReq true "修改资料参数"
|
||||
@@ -166,8 +49,6 @@ func UpdateProfile(ctx *gin.Context) {
|
||||
Avatar: req.Avatar,
|
||||
Introduction: req.Introduction,
|
||||
PrivacyMode: req.PrivacyMode,
|
||||
OldPassword: req.OldPassword,
|
||||
NewPassword: req.NewPassword,
|
||||
})
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
@@ -179,7 +60,7 @@ func UpdateProfile(ctx *gin.Context) {
|
||||
// GetInfo 获取当前用户信息
|
||||
// @Tags 用户认证
|
||||
// @Summary 获取当前用户信息
|
||||
// @Description 通过 token 获取最新用户信息,包含金币余额、VIP状态等
|
||||
// @Description 按请求头 X-User-Agent 中的 devID 识别用户,返回最新用户信息,包含金币余额、VIP状态等
|
||||
// @Produce json
|
||||
// @Success 200 {object} authser.LoginResp "用户信息"
|
||||
// @Failure 400 {string} string "失败"
|
||||
@@ -187,7 +68,7 @@ func UpdateProfile(ctx *gin.Context) {
|
||||
func GetInfo(ctx *gin.Context) {
|
||||
userId := common.GetUserId(ctx)
|
||||
if pubdef.IsCrawlerUser(userId) {
|
||||
common.ServerJSON(ctx, srvdef.Success, authser.CrawlerLoginResp(""))
|
||||
common.ServerJSON(ctx, srvdef.Success, authser.CrawlerLoginResp())
|
||||
return
|
||||
}
|
||||
if userId <= 0 {
|
||||
@@ -201,27 +82,3 @@ func GetInfo(ctx *gin.Context) {
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
// ResetPassword 找回密码
|
||||
// @Tags 用户认证
|
||||
// @Summary 找回密码
|
||||
// @Description 通过账号和邮箱双重校验后重置密码,两者必须同时匹配同一用户
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body resetPasswordReq true "找回密码参数"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/app/auth/resetPassword [POST]
|
||||
func ResetPassword(ctx *gin.Context) {
|
||||
var req resetPasswordReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
serr := authser.ResetPassword(ctx, req.AccountNo, req.Email, req.NewPassword)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, "")
|
||||
}
|
||||
|
||||
+2
-19
@@ -13,22 +13,5 @@ type AdsClickInfo struct {
|
||||
Location int64 `json:"location,omitempty" binding:"required"` // 位置ID
|
||||
}
|
||||
|
||||
type AdvitiseData struct {
|
||||
HomeList []proxy.AdvitiseInfo `json:"homeList" bson:"homeList"` // 首页列表
|
||||
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"` // 暂停广告
|
||||
}
|
||||
// AdvitiseData 广告数据,直接使用媒资中心返回的结构
|
||||
type AdvitiseData = proxy.AdvitiseData
|
||||
|
||||
+12
-12
@@ -1,19 +1,19 @@
|
||||
redis:
|
||||
addr: "172.104.181.99:16789"
|
||||
db: 2
|
||||
passwd: "B6vJHlYiTseLj77z"
|
||||
addr: 139.162.47.194:6379
|
||||
db: 1
|
||||
passwd: "Redis@fish2026!"
|
||||
subscribe: true
|
||||
mongodb:
|
||||
addr: "mongodb://admin:TESTwfeZYP0kjBdy8DAUdwU@172.104.181.99:57017,172.104.181.99:57018,172.104.181.99:57019/web_qmdj?replicaSet=yctest&maxPoolSize=200&connectTimeout=30&authSource=admin"
|
||||
logaddr: "mongodb://admin:TESTwfeZYP0kjBdy8DAUdwU@172.104.181.99:57017,172.104.181.99:57018,172.104.181.99:57019/web_qmdj_log?replicaSet=yctest&maxPoolSize=200&connectTimeout=30&authSource=admin"
|
||||
addr: "mongodb://webhgdj:lQbmsIanlpZAj6au3Nh5gqWN6GV0@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/webhgdj?replicaSet=fish0&maxPoolSize=200&authSource=admin"
|
||||
logaddr: "mongodb://webhgdj:lQbmsIanlpZAj6au3Nh5gqWN6GV0@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/webhgdj_log?replicaSet=fish0&maxPoolSize=200&authSource=admin"
|
||||
es:
|
||||
addr: "http://172.104.181.99:9200"
|
||||
addr: "http://139.162.47.194:9200"
|
||||
user: "elastic"
|
||||
pass: "admin123456"
|
||||
pass: "Es@fish2026!"
|
||||
httpOptions:
|
||||
dcCtxTimeOut: 10
|
||||
jwtKey: "2311b15a4da1c80dc541b99abb622233"
|
||||
runMod: "debug"
|
||||
runMod: "prod"
|
||||
resKey: "vEukA&w15z4VAD3kAY#fkL#rBnU!WDhN"
|
||||
cdnKey: "vEukAw15z4VAD3kAYfkLrBnUWDhN123"
|
||||
tsAuthKey: "fT5xSg4hltHpzVy6aV9rVECDJ1J1pN"
|
||||
@@ -24,12 +24,12 @@ attack:
|
||||
h5key: "kaFttDJRcahRMTI7"
|
||||
windowDurationSeconds: 60
|
||||
pprof: false
|
||||
host: "172.104.181.99"
|
||||
listenAddr: "25119"
|
||||
host: "172.104.166.87"
|
||||
listenAddr: "20001"
|
||||
origDomain: "https://yuan.bbaazz.me/"
|
||||
trustedProxies: ""
|
||||
bucketVideoAddressV2: "http://139.162.22.207:24996"
|
||||
transactionUrl: "https://bill.ruishengces.com"
|
||||
bucketVideoAddressV2: "http://139.162.27.29:19996"
|
||||
versionUrl: "http://139.162.47.194:8089"
|
||||
adCenter:
|
||||
apiDomain: "https://adopenapi.adcs01.top"
|
||||
merchantCode: "1991129808640122880"
|
||||
|
||||
+8
-25
@@ -1,28 +1,11 @@
|
||||
#!/bin/bash
|
||||
FILE_NAME="web_mdcom_app"
|
||||
REMOTE_FILE_PATH="/home/server2/web_mdcom/app/"
|
||||
TAG_NAME="web_mdcom_app.tar.gz"
|
||||
echo "开始"
|
||||
rm -rf ./web_huangguo_app ./web_huangguo_app.tar.gz
|
||||
GOOS=linux GOARCH=amd64 go build -o web_huangguo_app
|
||||
tar zvcf web_huangguo_app.tar.gz web_huangguo_app
|
||||
|
||||
set -e
|
||||
set -o
|
||||
function send_msg() {
|
||||
msg="@jscdsndj @xiuyuan_Lee @steven0yu %0A服务:SERVER2 站点-91spz.com管理服务APP%0A更新内容:$content%0A创建时间: $(date +%F_%X)%0A操作人:$(git config user.name)"
|
||||
curl -X POST "https://api.telegram.org/bot6357085965:AAEmXfjZnZwnDTicL7Wjbd7cXvYv_G98w8A/sendMessage" -d "chat_id=$1&text=$msg" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
read -p "输入yes, 开始上传: " word
|
||||
if [[ ! "yes" =~ $word ]]; then
|
||||
echo "终止"
|
||||
else
|
||||
read -e -p "本次更新内容(输入q退出编辑): " -r content
|
||||
echo "开始"
|
||||
rm -rf ./$FILE_NAME ./$TAG_NAME ./yinsemd5.txt
|
||||
GOOS=linux GOARCH=amd64 go build -o $FILE_NAME
|
||||
md5sum $FILE_NAME | cut -d ' ' -f1 >yinsemd5.txt
|
||||
tar zvcf $TAG_NAME ./$FILE_NAME yinsemd5.txt
|
||||
md5sum $TAG_NAME | cut -d ' ' -f1 >yinsemd5.txt
|
||||
scp -i ~/.ssh/id_rsa -P 22889 ./yinsemd5.txt server2@116.212.120.2:$REMOTE_FILE_PATH
|
||||
scp -i ~/.ssh/id_rsa -P 22889 ./$TAG_NAME server2@116.212.120.2:$REMOTE_FILE_PATH
|
||||
send_msg -4791758991 #服务器小组
|
||||
fi
|
||||
rm -rf ./$FILE_NAME ./$TAG_NAME ./yinsemd5.txt
|
||||
scp web_huangguo_app.tar.gz root@172.104.166.87:/data/uzip
|
||||
ssh root@172.104.166.87 "/server/web_huangguo/app/up_app.sh"
|
||||
|
||||
rm -rf ./web_huangguo_app ./web_huangguo_app.tar.gz
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
sudo make test
|
||||
|
||||
scp -P 22889 web_91av_app.tar.gz root@172.104.181.99:/server/web_91av/app/
|
||||
ssh root@172.104.181.99 -p 22889 "cd /server/web_91av/app/ && /bin/tar -xf /server/web_91av/app/web_91av_app.tar.gz && /usr/bin/supervisorctl restart web_91av_app"
|
||||
if [ $? -eq 0 ];then
|
||||
echo -e "\033[32m 91spz.com H5更新成功 \033[0m"
|
||||
else
|
||||
echo -e "\033[31m 91spz.com H5更新失败 \033[0m"
|
||||
fi
|
||||
rm -f web_91av_app.tar.gz
|
||||
+117
-401
@@ -58,7 +58,7 @@ const docTemplate = `{
|
||||
},
|
||||
"/api/app/auth/getInfo": {
|
||||
"get": {
|
||||
"description": "通过 token 获取最新用户信息,包含金币余额、VIP状态等",
|
||||
"description": "按请求头 X-User-Agent 中的 devID 识别用户,返回最新用户信息,包含金币余额、VIP状态等",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -82,89 +82,9 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/guest": {
|
||||
"post": {
|
||||
"description": "按设备ID创建或找回游客账号;请求头可带 Authorization 复用已有游客会话。需传 X-User-Agent",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "游客登录",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "游客登录参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.GuestLoginReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.LoginResp"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/login": {
|
||||
"post": {
|
||||
"description": "账号或邮箱均可作为登录凭证",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "登录",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "登录参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authapi.loginReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "登录成功,返回 token 及用户基本信息",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.LoginResp"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/profile": {
|
||||
"post": {
|
||||
"description": "用户信息通过 token 获取,无需传账号;nickName、avatar、introduction、oldPassword+newPassword 均为可选,至少提供一项。修改密码时旧密码和新密码必须同时提供。",
|
||||
"description": "按请求头 X-User-Agent 中的 devID 识别用户;nickName、avatar、introduction、privacyMode 均为可选,至少提供一项。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -174,7 +94,7 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "修改用户资料(头像 / 简介 / 密码,可任意组合)",
|
||||
"summary": "修改用户资料(昵称 / 头像 / 简介 / 隐私模式,可任意组合)",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "修改资料参数",
|
||||
@@ -202,86 +122,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/register": {
|
||||
"post": {
|
||||
"description": "传入账号、邮箱、明文密码。请求头带游客 Authorization 时升级该游客为普通用户,否则新建用户",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "注册",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "注册参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authapi.registerReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "注册成功,返回 token 及用户基本信息",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.LoginResp"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/resetPassword": {
|
||||
"post": {
|
||||
"description": "通过账号和邮箱双重校验后重置密码,两者必须同时匹配同一用户",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "找回密码",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "找回密码参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authapi.resetPasswordReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/coin/buy": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2295,87 +2135,6 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"authapi.loginReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"account",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"account": {
|
||||
"description": "账号或邮箱",
|
||||
"type": "string"
|
||||
},
|
||||
"channel": {
|
||||
"description": "渠道码(可选,用户无商区码时写入)",
|
||||
"type": "string"
|
||||
},
|
||||
"devID": {
|
||||
"description": "设备唯一标示(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"description": "明文密码",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authapi.registerReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNo",
|
||||
"email",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"accountNo": {
|
||||
"description": "账号",
|
||||
"type": "string"
|
||||
},
|
||||
"agentInviteCode": {
|
||||
"description": "邀请人的邀请码(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"channel": {
|
||||
"description": "渠道码(可选,用户无商区码时写入)",
|
||||
"type": "string"
|
||||
},
|
||||
"devID": {
|
||||
"description": "设备唯一标示(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"description": "邮箱",
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"description": "明文密码",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authapi.resetPasswordReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNo",
|
||||
"email",
|
||||
"newPassword"
|
||||
],
|
||||
"properties": {
|
||||
"accountNo": {
|
||||
"description": "账号",
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"description": "邮箱",
|
||||
"type": "string"
|
||||
},
|
||||
"newPassword": {
|
||||
"description": "新密码",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authapi.updateProfileReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2387,45 +2146,16 @@ const docTemplate = `{
|
||||
"description": "简介(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"newPassword": {
|
||||
"description": "新密码明文(修改密码时必填)",
|
||||
"type": "string"
|
||||
},
|
||||
"nickName": {
|
||||
"description": "新昵称(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"oldPassword": {
|
||||
"description": "旧密码明文(修改密码时必填)",
|
||||
"type": "string"
|
||||
},
|
||||
"privacyMode": {
|
||||
"description": "隐私模式:true-开启,false-关闭(可选)",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authser.GuestLoginReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"channel": {
|
||||
"description": "渠道码(可选,用户无商区码时写入 DistrictCode)",
|
||||
"type": "string"
|
||||
},
|
||||
"devID": {
|
||||
"description": "设备唯一标示(必填)",
|
||||
"type": "string"
|
||||
},
|
||||
"deviceId": {
|
||||
"description": "备用设备ID(可选,写入 DevV2)",
|
||||
"type": "string"
|
||||
},
|
||||
"mac": {
|
||||
"description": "设备 Mac(可选)",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authser.LoginResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2451,10 +2181,6 @@ const docTemplate = `{
|
||||
"description": "邀请码",
|
||||
"type": "string"
|
||||
},
|
||||
"isNewUser": {
|
||||
"description": "本次是否新建游客",
|
||||
"type": "boolean"
|
||||
},
|
||||
"isRegister": {
|
||||
"description": "是否已注册",
|
||||
"type": "boolean"
|
||||
@@ -2493,9 +2219,6 @@ const docTemplate = `{
|
||||
"status": {
|
||||
"$ref": "#/definitions/pubdef.UserStatus"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"description": "身份类型:0游客 1普通用户",
|
||||
"allOf": [
|
||||
@@ -2585,123 +2308,6 @@ const docTemplate = `{
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2803,7 +2409,7 @@ const docTemplate = `{
|
||||
"description": "广告",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3424,7 +3030,7 @@ const docTemplate = `{
|
||||
"description": "广告配置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3719,7 +3325,7 @@ const docTemplate = `{
|
||||
"description": "广告",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -5634,7 +5240,7 @@ const docTemplate = `{
|
||||
"description": "广告",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -5775,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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+117
-401
@@ -56,7 +56,7 @@
|
||||
},
|
||||
"/api/app/auth/getInfo": {
|
||||
"get": {
|
||||
"description": "通过 token 获取最新用户信息,包含金币余额、VIP状态等",
|
||||
"description": "按请求头 X-User-Agent 中的 devID 识别用户,返回最新用户信息,包含金币余额、VIP状态等",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -80,89 +80,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/guest": {
|
||||
"post": {
|
||||
"description": "按设备ID创建或找回游客账号;请求头可带 Authorization 复用已有游客会话。需传 X-User-Agent",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "游客登录",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "游客登录参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.GuestLoginReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.LoginResp"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/login": {
|
||||
"post": {
|
||||
"description": "账号或邮箱均可作为登录凭证",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "登录",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "登录参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authapi.loginReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "登录成功,返回 token 及用户基本信息",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.LoginResp"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/profile": {
|
||||
"post": {
|
||||
"description": "用户信息通过 token 获取,无需传账号;nickName、avatar、introduction、oldPassword+newPassword 均为可选,至少提供一项。修改密码时旧密码和新密码必须同时提供。",
|
||||
"description": "按请求头 X-User-Agent 中的 devID 识别用户;nickName、avatar、introduction、privacyMode 均为可选,至少提供一项。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -172,7 +92,7 @@
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "修改用户资料(头像 / 简介 / 密码,可任意组合)",
|
||||
"summary": "修改用户资料(昵称 / 头像 / 简介 / 隐私模式,可任意组合)",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "修改资料参数",
|
||||
@@ -200,86 +120,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/register": {
|
||||
"post": {
|
||||
"description": "传入账号、邮箱、明文密码。请求头带游客 Authorization 时升级该游客为普通用户,否则新建用户",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "注册",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "注册参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authapi.registerReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "注册成功,返回 token 及用户基本信息",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authser.LoginResp"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/auth/resetPassword": {
|
||||
"post": {
|
||||
"description": "通过账号和邮箱双重校验后重置密码,两者必须同时匹配同一用户",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"用户认证"
|
||||
],
|
||||
"summary": "找回密码",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "找回密码参数",
|
||||
"name": "param",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/authapi.resetPasswordReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "失败",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/app/coin/buy": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2293,87 +2133,6 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"authapi.loginReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"account",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"account": {
|
||||
"description": "账号或邮箱",
|
||||
"type": "string"
|
||||
},
|
||||
"channel": {
|
||||
"description": "渠道码(可选,用户无商区码时写入)",
|
||||
"type": "string"
|
||||
},
|
||||
"devID": {
|
||||
"description": "设备唯一标示(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"description": "明文密码",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authapi.registerReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNo",
|
||||
"email",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"accountNo": {
|
||||
"description": "账号",
|
||||
"type": "string"
|
||||
},
|
||||
"agentInviteCode": {
|
||||
"description": "邀请人的邀请码(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"channel": {
|
||||
"description": "渠道码(可选,用户无商区码时写入)",
|
||||
"type": "string"
|
||||
},
|
||||
"devID": {
|
||||
"description": "设备唯一标示(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"description": "邮箱",
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"description": "明文密码",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authapi.resetPasswordReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"accountNo",
|
||||
"email",
|
||||
"newPassword"
|
||||
],
|
||||
"properties": {
|
||||
"accountNo": {
|
||||
"description": "账号",
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"description": "邮箱",
|
||||
"type": "string"
|
||||
},
|
||||
"newPassword": {
|
||||
"description": "新密码",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authapi.updateProfileReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2385,45 +2144,16 @@
|
||||
"description": "简介(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"newPassword": {
|
||||
"description": "新密码明文(修改密码时必填)",
|
||||
"type": "string"
|
||||
},
|
||||
"nickName": {
|
||||
"description": "新昵称(可选)",
|
||||
"type": "string"
|
||||
},
|
||||
"oldPassword": {
|
||||
"description": "旧密码明文(修改密码时必填)",
|
||||
"type": "string"
|
||||
},
|
||||
"privacyMode": {
|
||||
"description": "隐私模式:true-开启,false-关闭(可选)",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authser.GuestLoginReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"channel": {
|
||||
"description": "渠道码(可选,用户无商区码时写入 DistrictCode)",
|
||||
"type": "string"
|
||||
},
|
||||
"devID": {
|
||||
"description": "设备唯一标示(必填)",
|
||||
"type": "string"
|
||||
},
|
||||
"deviceId": {
|
||||
"description": "备用设备ID(可选,写入 DevV2)",
|
||||
"type": "string"
|
||||
},
|
||||
"mac": {
|
||||
"description": "设备 Mac(可选)",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"authser.LoginResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2449,10 +2179,6 @@
|
||||
"description": "邀请码",
|
||||
"type": "string"
|
||||
},
|
||||
"isNewUser": {
|
||||
"description": "本次是否新建游客",
|
||||
"type": "boolean"
|
||||
},
|
||||
"isRegister": {
|
||||
"description": "是否已注册",
|
||||
"type": "boolean"
|
||||
@@ -2491,9 +2217,6 @@
|
||||
"status": {
|
||||
"$ref": "#/definitions/pubdef.UserStatus"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"description": "身份类型:0游客 1普通用户",
|
||||
"allOf": [
|
||||
@@ -2583,123 +2306,6 @@
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2801,7 +2407,7 @@
|
||||
"description": "广告",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3422,7 +3028,7 @@
|
||||
"description": "广告配置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3717,7 +3323,7 @@
|
||||
"description": "广告",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -5632,7 +5238,7 @@
|
||||
"description": "广告",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/proto.AdvitiseData"
|
||||
"$ref": "#/definitions/proxy.AdvitiseData"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -5773,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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+86
-280
@@ -1,64 +1,5 @@
|
||||
basePath: /
|
||||
definitions:
|
||||
authapi.loginReq:
|
||||
properties:
|
||||
account:
|
||||
description: 账号或邮箱
|
||||
type: string
|
||||
channel:
|
||||
description: 渠道码(可选,用户无商区码时写入)
|
||||
type: string
|
||||
devID:
|
||||
description: 设备唯一标示(可选)
|
||||
type: string
|
||||
password:
|
||||
description: 明文密码
|
||||
type: string
|
||||
required:
|
||||
- account
|
||||
- password
|
||||
type: object
|
||||
authapi.registerReq:
|
||||
properties:
|
||||
accountNo:
|
||||
description: 账号
|
||||
type: string
|
||||
agentInviteCode:
|
||||
description: 邀请人的邀请码(可选)
|
||||
type: string
|
||||
channel:
|
||||
description: 渠道码(可选,用户无商区码时写入)
|
||||
type: string
|
||||
devID:
|
||||
description: 设备唯一标示(可选)
|
||||
type: string
|
||||
email:
|
||||
description: 邮箱
|
||||
type: string
|
||||
password:
|
||||
description: 明文密码
|
||||
type: string
|
||||
required:
|
||||
- accountNo
|
||||
- email
|
||||
- password
|
||||
type: object
|
||||
authapi.resetPasswordReq:
|
||||
properties:
|
||||
accountNo:
|
||||
description: 账号
|
||||
type: string
|
||||
email:
|
||||
description: 邮箱
|
||||
type: string
|
||||
newPassword:
|
||||
description: 新密码
|
||||
type: string
|
||||
required:
|
||||
- accountNo
|
||||
- email
|
||||
- newPassword
|
||||
type: object
|
||||
authapi.updateProfileReq:
|
||||
properties:
|
||||
avatar:
|
||||
@@ -67,34 +8,13 @@ definitions:
|
||||
introduction:
|
||||
description: 简介(可选)
|
||||
type: string
|
||||
newPassword:
|
||||
description: 新密码明文(修改密码时必填)
|
||||
type: string
|
||||
nickName:
|
||||
description: 新昵称(可选)
|
||||
type: string
|
||||
oldPassword:
|
||||
description: 旧密码明文(修改密码时必填)
|
||||
type: string
|
||||
privacyMode:
|
||||
description: 隐私模式:true-开启,false-关闭(可选)
|
||||
type: boolean
|
||||
type: object
|
||||
authser.GuestLoginReq:
|
||||
properties:
|
||||
channel:
|
||||
description: 渠道码(可选,用户无商区码时写入 DistrictCode)
|
||||
type: string
|
||||
devID:
|
||||
description: 设备唯一标示(必填)
|
||||
type: string
|
||||
deviceId:
|
||||
description: 备用设备ID(可选,写入 DevV2)
|
||||
type: string
|
||||
mac:
|
||||
description: 设备 Mac(可选)
|
||||
type: string
|
||||
type: object
|
||||
authser.LoginResp:
|
||||
properties:
|
||||
accountNo:
|
||||
@@ -113,9 +33,6 @@ definitions:
|
||||
inviteCode:
|
||||
description: 邀请码
|
||||
type: string
|
||||
isNewUser:
|
||||
description: 本次是否新建游客
|
||||
type: boolean
|
||||
isRegister:
|
||||
description: 是否已注册
|
||||
type: boolean
|
||||
@@ -142,8 +59,6 @@ definitions:
|
||||
type: string
|
||||
status:
|
||||
$ref: '#/definitions/pubdef.UserStatus'
|
||||
token:
|
||||
type: string
|
||||
type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/pubdef.UserType'
|
||||
@@ -207,89 +122,6 @@ definitions:
|
||||
- TranTypeDarkAlley
|
||||
- TranTypeVideoUnlock
|
||||
- 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:
|
||||
properties:
|
||||
content:
|
||||
@@ -362,7 +194,7 @@ definitions:
|
||||
properties:
|
||||
advitise:
|
||||
allOf:
|
||||
- $ref: '#/definitions/proto.AdvitiseData'
|
||||
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||
description: 广告
|
||||
category:
|
||||
allOf:
|
||||
@@ -804,7 +636,7 @@ definitions:
|
||||
properties:
|
||||
advitise:
|
||||
allOf:
|
||||
- $ref: '#/definitions/proto.AdvitiseData'
|
||||
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||
description: 广告配置
|
||||
config:
|
||||
allOf:
|
||||
@@ -1001,7 +833,7 @@ definitions:
|
||||
properties:
|
||||
advitise:
|
||||
allOf:
|
||||
- $ref: '#/definitions/proto.AdvitiseData'
|
||||
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||
description: 广告
|
||||
bottonTranslations:
|
||||
allOf:
|
||||
@@ -2351,7 +2183,7 @@ definitions:
|
||||
properties:
|
||||
advitise:
|
||||
allOf:
|
||||
- $ref: '#/definitions/proto.AdvitiseData'
|
||||
- $ref: '#/definitions/proxy.AdvitiseData'
|
||||
description: 广告
|
||||
coverImg:
|
||||
description: 封面
|
||||
@@ -2448,6 +2280,84 @@ definitions:
|
||||
description: 总共数量
|
||||
type: integer
|
||||
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:
|
||||
properties:
|
||||
id:
|
||||
@@ -3144,7 +3054,7 @@ paths:
|
||||
- 应用列表
|
||||
/api/app/auth/getInfo:
|
||||
get:
|
||||
description: 通过 token 获取最新用户信息,包含金币余额、VIP状态等
|
||||
description: 按请求头 X-User-Agent 中的 devID 识别用户,返回最新用户信息,包含金币余额、VIP状态等
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -3159,64 +3069,12 @@ paths:
|
||||
summary: 获取当前用户信息
|
||||
tags:
|
||||
- 用户认证
|
||||
/api/app/auth/guest:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 按设备ID创建或找回游客账号;请求头可带 Authorization 复用已有游客会话。需传 X-User-Agent
|
||||
parameters:
|
||||
- description: 游客登录参数
|
||||
in: body
|
||||
name: param
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/authser.GuestLoginReq'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
schema:
|
||||
$ref: '#/definitions/authser.LoginResp'
|
||||
"400":
|
||||
description: 失败
|
||||
schema:
|
||||
type: string
|
||||
summary: 游客登录
|
||||
tags:
|
||||
- 用户认证
|
||||
/api/app/auth/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 账号或邮箱均可作为登录凭证
|
||||
parameters:
|
||||
- description: 登录参数
|
||||
in: body
|
||||
name: param
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/authapi.loginReq'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 登录成功,返回 token 及用户基本信息
|
||||
schema:
|
||||
$ref: '#/definitions/authser.LoginResp'
|
||||
"400":
|
||||
description: 失败
|
||||
schema:
|
||||
type: string
|
||||
summary: 登录
|
||||
tags:
|
||||
- 用户认证
|
||||
/api/app/auth/profile:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 用户信息通过 token 获取,无需传账号;nickName、avatar、introduction、oldPassword+newPassword
|
||||
均为可选,至少提供一项。修改密码时旧密码和新密码必须同时提供。
|
||||
description: 按请求头 X-User-Agent 中的 devID 识别用户;nickName、avatar、introduction、privacyMode
|
||||
均为可选,至少提供一项。
|
||||
parameters:
|
||||
- description: 修改资料参数
|
||||
in: body
|
||||
@@ -3235,59 +3093,7 @@ paths:
|
||||
description: 失败
|
||||
schema:
|
||||
type: string
|
||||
summary: 修改用户资料(头像 / 简介 / 密码,可任意组合)
|
||||
tags:
|
||||
- 用户认证
|
||||
/api/app/auth/register:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 传入账号、邮箱、明文密码。请求头带游客 Authorization 时升级该游客为普通用户,否则新建用户
|
||||
parameters:
|
||||
- description: 注册参数
|
||||
in: body
|
||||
name: param
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/authapi.registerReq'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 注册成功,返回 token 及用户基本信息
|
||||
schema:
|
||||
$ref: '#/definitions/authser.LoginResp'
|
||||
"400":
|
||||
description: 失败
|
||||
schema:
|
||||
type: string
|
||||
summary: 注册
|
||||
tags:
|
||||
- 用户认证
|
||||
/api/app/auth/resetPassword:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 通过账号和邮箱双重校验后重置密码,两者必须同时匹配同一用户
|
||||
parameters:
|
||||
- description: 找回密码参数
|
||||
in: body
|
||||
name: param
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/authapi.resetPasswordReq'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
schema:
|
||||
type: string
|
||||
"400":
|
||||
description: 失败
|
||||
schema:
|
||||
type: string
|
||||
summary: 找回密码
|
||||
summary: 修改用户资料(昵称 / 头像 / 简介 / 隐私模式,可任意组合)
|
||||
tags:
|
||||
- 用户认证
|
||||
/api/app/coin/buy:
|
||||
|
||||
+26
-112
@@ -3,129 +3,43 @@ package auth
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"videoweb/app/appg"
|
||||
"videoweb/app/middleware/reptilerecord"
|
||||
"videoweb/app/service/authser"
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/enum/consts"
|
||||
"videoweb/pub/common/ipaddr"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/common/utils"
|
||||
"videoweb/pub/pubdef"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// gin 验证中间件
|
||||
|
||||
var (
|
||||
// 白名单,不需要验证token的api
|
||||
whiteList = []string{
|
||||
"/swagger",
|
||||
"/api/app/auth/guest",
|
||||
"/api/app/auth/register",
|
||||
"/api/app/auth/login",
|
||||
"/api/app/auth/resetPassword",
|
||||
"/api/app/video/list",
|
||||
"/api/app/video/detail",
|
||||
"/api/app/playlet/home",
|
||||
"/api/app/playlet/recommend/list",
|
||||
"/api/app/playlet/list",
|
||||
"/api/app/playlet/operate/list",
|
||||
"/api/app/playlet/rank",
|
||||
"/api/app/playlet/today-update",
|
||||
"/api/app/playlet/tag/list",
|
||||
"/api/app/playlet/search",
|
||||
"/api/app/playlet/hot-like",
|
||||
"/api/app/playlet/detail",
|
||||
"/api/app/playlet/chapter/detail",
|
||||
"/api/app/recharge/package/list",
|
||||
"/api/app/comment/list",
|
||||
"/api/app/theme/list",
|
||||
"/api/app/config/info",
|
||||
"/api/app/config/footer/info",
|
||||
"/api/app/config/richtext/list",
|
||||
"/api/app/applist",
|
||||
"/api/app/translation/category/list",
|
||||
"/api/app/health/ping",
|
||||
"/api/app/statcenter/sync",
|
||||
"/h5/m3u8",
|
||||
"/enkey",
|
||||
"/newenkey",
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
tokener = utils.NewTokenRedis()
|
||||
)
|
||||
|
||||
// gin 用户识别中间件:不再校验 token,按 X-User-Agent 中的 devID 识别用户,
|
||||
// 该设备首次访问时自动创建用户。没有 devID 的请求按匿名处理,
|
||||
// 需要用户身份的接口自行返回"请先登录"。
|
||||
func Auth(ctx *gin.Context) {
|
||||
dotoken := func() srvdef.CodeType {
|
||||
token := ctx.Request.Header.Get("Authorization")
|
||||
// 去掉Bearer,如果有
|
||||
token = utils.StripBearerPrefixFromTokenString(token)
|
||||
|
||||
if token == "" {
|
||||
for _, w := range whiteList {
|
||||
if strings.Contains(ctx.Request.URL.Path, w) {
|
||||
return srvdef.Success
|
||||
}
|
||||
}
|
||||
|
||||
log.Error("Auth:token is empty", log.Any("sysType", ctx.GetString(consts.CtxSysType)))
|
||||
return srvdef.InvalidToken
|
||||
}
|
||||
|
||||
userId, newToken, err := utils.ParseUserToken(token, appg.Conf.JwtKey)
|
||||
if err != nil {
|
||||
for _, w := range whiteList {
|
||||
if strings.Contains(ctx.Request.URL.Path, w) {
|
||||
return srvdef.Success
|
||||
}
|
||||
}
|
||||
|
||||
log.Error("Auth:ParseUserToken", log.Any("token", token), log.E(err))
|
||||
return srvdef.InvalidToken
|
||||
}
|
||||
|
||||
if pubdef.IsCrawlerUser(userId) {
|
||||
if len(newToken) > 0 {
|
||||
ctx.Writer.Header().Set("Refresh-Authorization", newToken)
|
||||
}
|
||||
ctx.Set(consts.CtxUserID, userId)
|
||||
ctx.Set(consts.CtxToken, token)
|
||||
return srvdef.Success
|
||||
}
|
||||
|
||||
has, err := tokener.Exists(userId, token)
|
||||
if err != nil {
|
||||
log.Error("Auth:Exists", log.Any("userId", userId), log.Any("token", token), log.E(err))
|
||||
return srvdef.InvalidToken
|
||||
}
|
||||
if !has {
|
||||
log.Error("Auth:Exists:token not exists", log.Any("userId", userId), log.Any("token", token), log.E(err))
|
||||
return srvdef.InvalidToken
|
||||
}
|
||||
|
||||
if len(newToken) > 0 {
|
||||
err = tokener.Save(userId, newToken)
|
||||
if err != nil {
|
||||
log.Error("Auth:Save", log.Any("userId", userId), log.Any("token", newToken), log.E(err))
|
||||
return srvdef.StoreLevel
|
||||
}
|
||||
ctx.Writer.Header().Set("Refresh-Authorization", newToken)
|
||||
}
|
||||
|
||||
ctx.Set(consts.CtxUserID, userId)
|
||||
ctx.Set(consts.CtxToken, token)
|
||||
|
||||
return srvdef.Success
|
||||
if reptilerecord.IsBot(ctx) {
|
||||
ctx.Set(consts.CtxUserID, pubdef.CrawlerUserId)
|
||||
return
|
||||
}
|
||||
|
||||
errType := dotoken()
|
||||
if errType != srvdef.Success {
|
||||
// log.Info("Auth bad request", log.Any("Path", ctx.Request.URL.Path), log.Any("ip", ctx.ClientIP()))
|
||||
ctx.AbortWithStatusJSON(http.StatusOK, gin.H{
|
||||
"code": errType,
|
||||
"msg": errType.Msg(),
|
||||
})
|
||||
ua, err := common.GetUA(ctx)
|
||||
if err != nil || strings.TrimSpace(ua.DevID) == "" {
|
||||
return
|
||||
}
|
||||
|
||||
userId, serr := authser.ResolveDeviceUser(ctx, ua, ipaddr.ResolveClientIP(ctx), ctx.GetHeader("channel"))
|
||||
if serr != nil {
|
||||
if serr.Code == srvdef.AccountErrAccessForbid {
|
||||
ctx.AbortWithStatusJSON(http.StatusOK, gin.H{
|
||||
"code": serr.Code,
|
||||
"msg": serr.Code.Msg(),
|
||||
})
|
||||
return
|
||||
}
|
||||
log.Error("Auth:ResolveDeviceUser", log.Any("devID", ua.DevID), log.Any("path", ctx.Request.URL.Path), log.E(serr))
|
||||
return
|
||||
}
|
||||
ctx.Set(consts.CtxUserID, userId)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -9,11 +9,7 @@ import (
|
||||
func authRouter(r *gin.Engine) {
|
||||
auth := r.Group("/api/app/auth")
|
||||
{
|
||||
auth.POST("/guest", authapi.GuestLogin)
|
||||
auth.POST("/register", authapi.Register)
|
||||
auth.POST("/login", authapi.Login)
|
||||
auth.GET("/getInfo", authapi.GetInfo)
|
||||
auth.POST("/profile", authapi.UpdateProfile)
|
||||
auth.POST("/resetPassword", authapi.ResetPassword)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -79,14 +79,14 @@ func registeMiddleware(engine *gin.Engine) {
|
||||
Methods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodHead, http.MethodDelete},
|
||||
AllowedHeaders: []string{
|
||||
"Content-Length", "Content-Type", "Authorization", "X-User-Agent",
|
||||
"device", "api_version", "x-api-key",
|
||||
"device", "api_version", "x-api-key", "channel",
|
||||
"sid",
|
||||
"device_brand", "device-brand",
|
||||
"device_model", "device-model",
|
||||
"system_name", "system-name",
|
||||
"system_version", "system-version",
|
||||
},
|
||||
ExposedHeaders: []string{"Content-Disposition", "Refresh-Authorization"},
|
||||
ExposedHeaders: []string{"Content-Disposition"},
|
||||
OptionsSuccessStatus: http.StatusOK,
|
||||
}),
|
||||
// 必须是此顺序, happens before原则
|
||||
@@ -119,6 +119,7 @@ func registeRouter(r *gin.Engine) {
|
||||
appInfoRouter(r)
|
||||
translationRouter(r)
|
||||
statcenterRouter(r)
|
||||
adsRouter(r)
|
||||
r.GET("/notpage", templatecache.WithCache(time.Minute*1), home.PageNotFound)
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func UpdateAppListCache(ctx context.Context) {
|
||||
}
|
||||
// 广告位 A(code=12)
|
||||
if category.Code == 12 {
|
||||
for _, ad := range advitise.AList {
|
||||
for _, ad := range advitise.AppInfoAList {
|
||||
apps = append(apps, proto.AppInfoData{
|
||||
AdvitiseId: ad.Id,
|
||||
CategoryId: category.Id,
|
||||
@@ -137,7 +137,7 @@ func UpdateAppListCache(ctx context.Context) {
|
||||
}
|
||||
// 广告位 B(code=13)
|
||||
if category.Code == 13 {
|
||||
for _, ad := range advitise.BList {
|
||||
for _, ad := range advitise.AppInfoBList {
|
||||
apps = append(apps, proto.AppInfoData{
|
||||
AdvitiseId: ad.Id,
|
||||
CategoryId: category.Id,
|
||||
|
||||
+7
-303
@@ -4,22 +4,16 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
"videoweb/app/appg"
|
||||
"videoweb/pub/common/enum/consts"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/common/useragent"
|
||||
"videoweb/pub/common/utils"
|
||||
"videoweb/pub/models/usermod"
|
||||
"videoweb/pub/mongos"
|
||||
"videoweb/pub/pubdef"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var tokener = utils.NewTokenRedis()
|
||||
|
||||
var defaultAvatars = []string{
|
||||
"v3/image/bo/ty/1016/girl1.jpeg",
|
||||
"v3/image/re/9y/1016/girl2.jpeg",
|
||||
@@ -47,9 +41,8 @@ func generateUniqueInviteCode(ctx context.Context) string {
|
||||
return strings.ToUpper(utils.GetRandomLetters(12))
|
||||
}
|
||||
|
||||
// LoginResp 登录/注册成功后的响应数据
|
||||
// LoginResp 用户信息
|
||||
type LoginResp struct {
|
||||
Token string `json:"token"`
|
||||
UserId int64 `json:"userId"`
|
||||
AccountNo string `json:"accountNo"`
|
||||
Email string `json:"email"`
|
||||
@@ -65,275 +58,27 @@ type LoginResp struct {
|
||||
Type pubdef.UserType `json:"type"` // 身份类型:0游客 1普通用户
|
||||
LoginType pubdef.LoginType `json:"loginType"` // 登陆方式
|
||||
IsRegister bool `json:"isRegister"` // 是否已注册
|
||||
IsNewUser bool `json:"isNewUser"` // 本次是否新建游客
|
||||
PrivacyMode bool `json:"privacyMode"` // 隐私模式
|
||||
Score int64 `json:"score"` // 积分
|
||||
Recharge int64 `json:"recharge"` // 金币余额
|
||||
}
|
||||
|
||||
// hashPassword 使用 bcrypt 对明文密码进行哈希
|
||||
func hashPassword(plain string) (string, error) {
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(plain), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(hash), nil
|
||||
}
|
||||
|
||||
// checkPassword 验证明文密码与 bcrypt 哈希是否匹配
|
||||
func checkPassword(plain, hash string) bool {
|
||||
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(plain)) == nil
|
||||
}
|
||||
|
||||
// generateAndSaveToken 生成 JWT 并存入 Redis
|
||||
func generateAndSaveToken(userId int64) (string, *srvdef.SrvErr) {
|
||||
token, err := utils.GenerateUserToken(utils.UserClaims{
|
||||
UserID: userId,
|
||||
Expire: consts.UserJwtTokenExpire,
|
||||
}, appg.Conf.JwtKey)
|
||||
if err != nil {
|
||||
return "", srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
if err = tokener.Save(userId, token); err != nil {
|
||||
return "", srvdef.New(srvdef.StoreLevel, "token存储失败", "")
|
||||
}
|
||||
return token, nil
|
||||
}
|
||||
|
||||
// generateCrawlerToken 签发爬虫观看 JWT,不写入 Redis,避免占用真实用户槽位。
|
||||
func generateCrawlerToken() (string, *srvdef.SrvErr) {
|
||||
token, err := utils.GenerateUserToken(utils.UserClaims{
|
||||
UserID: pubdef.CrawlerUserId,
|
||||
Expire: consts.UserJwtTokenExpire,
|
||||
}, appg.Conf.JwtKey)
|
||||
if err != nil {
|
||||
return "", srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
return token, nil
|
||||
}
|
||||
|
||||
// CrawlerLoginResp 爬虫虚拟游客资料,不对应任何数据库用户。
|
||||
func CrawlerLoginResp(token string) *LoginResp {
|
||||
func CrawlerLoginResp() *LoginResp {
|
||||
return &LoginResp{
|
||||
Token: token,
|
||||
UserId: pubdef.CrawlerUserId,
|
||||
NickName: "游客",
|
||||
Status: pubdef.UserStatusNormal,
|
||||
Type: pubdef.UserTypeGuest,
|
||||
LoginType: pubdef.LoginTypeDevice,
|
||||
IsRegister: false,
|
||||
IsNewUser: false,
|
||||
}
|
||||
}
|
||||
|
||||
// Register 用户注册
|
||||
// guestUserId:请求头 Authorization 解析出的用户ID;若为游客则升级该用户,否则新建
|
||||
// agentInviteCode:邀请人的邀请码,可为空
|
||||
func Register(ctx context.Context, guestUserId int64, accountNo, email, password, agentInviteCode string, ua useragent.UA, ip, channel string) (*LoginResp, *srvdef.SrvErr) {
|
||||
accountNo = strings.TrimSpace(accountNo)
|
||||
email = strings.TrimSpace(email)
|
||||
password = strings.TrimSpace(password)
|
||||
|
||||
// 检查账号是否已存在
|
||||
exist, _ := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.AccountNo: accountNo})
|
||||
if exist != nil {
|
||||
return nil, srvdef.New(srvdef.ErrDbInputExist, "账号已存在", "")
|
||||
}
|
||||
// 检查邮箱是否已存在
|
||||
exist, _ = usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Email: email})
|
||||
if exist != nil {
|
||||
return nil, srvdef.New(srvdef.ErrDbInputExist, "邮箱已被注册", "")
|
||||
}
|
||||
|
||||
hashed, err := hashPassword(password)
|
||||
if err != nil {
|
||||
return nil, srvdef.New(srvdef.Failure, "密码处理失败", "")
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
// 请求头带游客 token:升级当前游客为普通用户
|
||||
if guestUserId > 0 {
|
||||
guest, serr := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: guestUserId})
|
||||
if serr == nil && isGuestUser(guest) {
|
||||
setDoc := bson.M{
|
||||
usermod.FN.User.AccountNo: accountNo,
|
||||
usermod.FN.User.Email: email,
|
||||
usermod.FN.User.Password: hashed,
|
||||
usermod.FN.User.Type: pubdef.UserTypeNormal,
|
||||
usermod.FN.User.IsRegister: true,
|
||||
usermod.FN.User.LoginType: pubdef.LoginTypeAccount,
|
||||
usermod.FN.User.RegisterTime: now,
|
||||
usermod.FN.User.LastLoginAt: now,
|
||||
usermod.FN.User.UpdatedAt: now,
|
||||
usermod.FN.User.LastIp: ip,
|
||||
}
|
||||
if agentInviteCode != "" && guest.AgentInviteCode == "" {
|
||||
setDoc[usermod.FN.User.AgentInviteCode] = agentInviteCode
|
||||
setDoc[usermod.FN.User.IsDirect] = false
|
||||
guest.IsDirect = false
|
||||
}
|
||||
if v := strings.TrimSpace(ua.DevID); v != "" {
|
||||
setDoc[usermod.FN.User.DevID] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.DevType); v != "" {
|
||||
setDoc[usermod.FN.User.Device] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.SysType); v != "" {
|
||||
setDoc[usermod.FN.User.SysType] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.Ver); v != "" {
|
||||
setDoc[usermod.FN.User.AppVer] = v
|
||||
}
|
||||
mergeUAExtFieldsToSet(setDoc, guest, ua)
|
||||
applyChannelIfMissing(setDoc, guest, channel)
|
||||
if serr = usermod.UpdateOneUser(ctx, bson.M{usermod.FN.User.Id: guest.Id}, bson.M{"$set": setDoc}); serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
if agentInviteCode != "" && guest.AgentInviteCode == "" {
|
||||
_ = usermod.UpdateOneUser(ctx,
|
||||
bson.M{usermod.FN.User.InviteCode: agentInviteCode},
|
||||
bson.M{
|
||||
"$inc": bson.M{usermod.FN.User.Invites: 1},
|
||||
"$set": bson.M{usermod.FN.User.UpdatedAt: now},
|
||||
},
|
||||
)
|
||||
}
|
||||
guest.AccountNo = accountNo
|
||||
guest.Email = email
|
||||
guest.Type = pubdef.UserTypeNormal
|
||||
guest.IsRegister = true
|
||||
guest.LoginType = pubdef.LoginTypeAccount
|
||||
guest.RegisterTime = now
|
||||
token, serr := generateAndSaveToken(guest.Id)
|
||||
if serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
return toLoginResp(ctx, guest, token, true), nil
|
||||
}
|
||||
}
|
||||
|
||||
user := &usermod.User{
|
||||
Id: mongos.Lid.User.Get(),
|
||||
AccountNo: accountNo,
|
||||
Email: email,
|
||||
Password: hashed,
|
||||
NickName: appg.GenerateNickname(),
|
||||
Avatar: randomAvatar(),
|
||||
InviteCode: generateUniqueInviteCode(ctx),
|
||||
AgentInviteCode: agentInviteCode,
|
||||
Type: pubdef.UserTypeNormal,
|
||||
Status: pubdef.UserStatusNormal,
|
||||
IsRegister: true,
|
||||
LoginType: pubdef.LoginTypeAccount,
|
||||
RegIp: ip,
|
||||
LastIp: ip,
|
||||
DevID: ua.DevID,
|
||||
Device: ua.DevType,
|
||||
SysType: ua.SysType,
|
||||
AppVer: ua.Ver,
|
||||
OriVer: ua.Ver,
|
||||
SessionID: ua.SessionID,
|
||||
DeviceBrand: ua.DeviceBrand,
|
||||
DeviceModel: ua.DeviceModel,
|
||||
SystemName: ua.SystemName,
|
||||
SystemVersion: ua.SystemVersion,
|
||||
DistrictCode: normalizeChannel(channel),
|
||||
IsDirect: resolveUserDistrict(channel, agentInviteCode, ip, ua.SysType).IsDirect,
|
||||
LastLoginAt: now,
|
||||
RegisterTime: now,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if serr := usermod.InsertOneUser(ctx, user); serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
|
||||
// 若填写了邀请码,给对应用户的 invites +1
|
||||
if agentInviteCode != "" {
|
||||
_ = usermod.UpdateOneUser(ctx,
|
||||
bson.M{usermod.FN.User.InviteCode: agentInviteCode},
|
||||
bson.M{
|
||||
"$inc": bson.M{usermod.FN.User.Invites: 1},
|
||||
"$set": bson.M{usermod.FN.User.UpdatedAt: time.Now()},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
token, serr := generateAndSaveToken(user.Id)
|
||||
if serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
return toLoginResp(ctx, user, token, false), nil
|
||||
}
|
||||
|
||||
// Login 用户登录(账号或邮箱均可)
|
||||
func Login(ctx context.Context, account, password string, ua useragent.UA, ip, channel string) (*LoginResp, *srvdef.SrvErr) {
|
||||
// 账号或邮箱均可登录
|
||||
user, _ := usermod.FindOneUser(ctx, bson.M{
|
||||
"$or": []bson.M{
|
||||
{usermod.FN.User.AccountNo: account},
|
||||
{usermod.FN.User.Email: account},
|
||||
},
|
||||
})
|
||||
if user == nil {
|
||||
return nil, srvdef.New(srvdef.AccountIsNotExists, srvdef.AccountIsNotExists.Msg(), "")
|
||||
}
|
||||
|
||||
if user.Status == pubdef.UserStatusDisable {
|
||||
return nil, srvdef.New(srvdef.AccountErrAccessForbid, srvdef.AccountErrAccessForbid.Msg(), "")
|
||||
}
|
||||
|
||||
if !checkPassword(password, user.Password) {
|
||||
return nil, srvdef.New(srvdef.AccountErrPasswordError, srvdef.AccountErrPasswordError.Msg(), "")
|
||||
}
|
||||
|
||||
token, serr := generateAndSaveToken(user.Id)
|
||||
if serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
setDoc := bson.M{
|
||||
usermod.FN.User.LastLoginAt: now,
|
||||
usermod.FN.User.UpdatedAt: now,
|
||||
}
|
||||
if ip != "" {
|
||||
setDoc[usermod.FN.User.LastIp] = ip
|
||||
}
|
||||
if v := strings.TrimSpace(ua.DevID); v != "" {
|
||||
setDoc[usermod.FN.User.DevID] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.DevType); v != "" {
|
||||
setDoc[usermod.FN.User.Device] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.SysType); v != "" {
|
||||
setDoc[usermod.FN.User.SysType] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.Ver); v != "" {
|
||||
setDoc[usermod.FN.User.AppVer] = v
|
||||
}
|
||||
// 已有账号的历史用户统一修正为普通用户
|
||||
if strings.TrimSpace(user.AccountNo) != "" && user.Type != pubdef.UserTypeNormal {
|
||||
setDoc[usermod.FN.User.Type] = pubdef.UserTypeNormal
|
||||
setDoc[usermod.FN.User.IsRegister] = true
|
||||
user.Type = pubdef.UserTypeNormal
|
||||
user.IsRegister = true
|
||||
}
|
||||
mergeUAExtFieldsToSet(setDoc, user, ua)
|
||||
applyChannelIfMissing(setDoc, user, channel)
|
||||
_ = usermod.UpdateOneUser(ctx,
|
||||
bson.M{usermod.FN.User.Id: user.Id},
|
||||
bson.M{"$set": setDoc},
|
||||
)
|
||||
return toLoginResp(ctx, user, token, true), nil
|
||||
}
|
||||
|
||||
// GetInfo 获取当前登录用户的最新信息(不刷新 token)
|
||||
// GetInfo 获取当前用户的最新信息
|
||||
func GetInfo(ctx context.Context, userId int64, ua useragent.UA) (*LoginResp, *srvdef.SrvErr) {
|
||||
if pubdef.IsCrawlerUser(userId) {
|
||||
return CrawlerLoginResp(""), nil
|
||||
return CrawlerLoginResp(), nil
|
||||
}
|
||||
user, _ := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: userId})
|
||||
if user == nil {
|
||||
@@ -364,7 +109,7 @@ func GetInfo(ctx context.Context, userId int64, ua useragent.UA) (*LoginResp, *s
|
||||
setDoc[usermod.FN.User.UpdatedAt] = now
|
||||
_ = usermod.UpdateOneUser(ctx, bson.M{usermod.FN.User.Id: user.Id}, bson.M{"$set": setDoc})
|
||||
}
|
||||
return toLoginResp(ctx, user, "", true), nil
|
||||
return toLoginResp(ctx, user, true), nil
|
||||
}
|
||||
|
||||
func mergeUAExtFieldsToSet(setDoc bson.M, user *usermod.User, ua useragent.UA) {
|
||||
@@ -390,16 +135,14 @@ func mergeUAExtFieldsToSet(setDoc bson.M, user *usermod.User, ua useragent.UA) {
|
||||
|
||||
// UpdateProfileReq 修改用户资料的参数(所有字段均为可选)
|
||||
type UpdateProfileReq struct {
|
||||
UserId int64 // 用户ID(从 token 中获取)
|
||||
UserId int64 // 用户ID(按设备ID识别)
|
||||
NickName *string // 新昵称(可选)
|
||||
Avatar *string // 新头像 URL(可选)
|
||||
Introduction *string // 简介(可选)
|
||||
PrivacyMode *bool // 隐私模式:true-开启,false-关闭(可选)
|
||||
OldPassword *string // 旧密码明文(修改密码时必传)
|
||||
NewPassword *string // 新密码明文(修改密码时必传)
|
||||
}
|
||||
|
||||
// UpdateProfile 修改用户资料:支持修改头像、简介、密码,或组合修改
|
||||
// UpdateProfile 修改用户资料:支持修改昵称、头像、简介、隐私模式,或组合修改
|
||||
func UpdateProfile(ctx context.Context, req *UpdateProfileReq) *srvdef.SrvErr {
|
||||
user, _ := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: req.UserId})
|
||||
if user == nil {
|
||||
@@ -421,21 +164,6 @@ func UpdateProfile(ctx context.Context, req *UpdateProfileReq) *srvdef.SrvErr {
|
||||
setDoc[usermod.FN.User.PrivacyMode] = *req.PrivacyMode
|
||||
}
|
||||
|
||||
// 修改密码:两者必须同时提供
|
||||
if req.OldPassword != nil || req.NewPassword != nil {
|
||||
if req.OldPassword == nil || req.NewPassword == nil {
|
||||
return srvdef.New(srvdef.ErrParamError, "修改密码时旧密码和新密码均需提供", "")
|
||||
}
|
||||
if !checkPassword(*req.OldPassword, user.Password) {
|
||||
return srvdef.New(srvdef.AccountErrPasswordError, "旧密码错误", "")
|
||||
}
|
||||
hashed, err := hashPassword(*req.NewPassword)
|
||||
if err != nil {
|
||||
return srvdef.New(srvdef.Failure, "密码处理失败", "")
|
||||
}
|
||||
setDoc[usermod.FN.User.Password] = hashed
|
||||
}
|
||||
|
||||
// 没有任何需要更新的字段
|
||||
if len(setDoc) == 1 {
|
||||
return srvdef.New(srvdef.ErrParamError, "至少需要修改一项资料", "")
|
||||
@@ -446,27 +174,3 @@ func UpdateProfile(ctx context.Context, req *UpdateProfileReq) *srvdef.SrvErr {
|
||||
bson.M{"$set": setDoc},
|
||||
)
|
||||
}
|
||||
|
||||
// ResetPassword 通过账号+邮箱双重校验后重置密码
|
||||
func ResetPassword(ctx context.Context, accountNo, email, newPassword string) *srvdef.SrvErr {
|
||||
user, _ := usermod.FindOneUser(ctx, bson.M{
|
||||
usermod.FN.User.AccountNo: accountNo,
|
||||
usermod.FN.User.Email: email,
|
||||
})
|
||||
if user == nil {
|
||||
return srvdef.New(srvdef.ErrUserNotExsit, "账号或邮箱不匹配", "")
|
||||
}
|
||||
|
||||
hashed, err := hashPassword(newPassword)
|
||||
if err != nil {
|
||||
return srvdef.New(srvdef.Failure, "密码处理失败", "")
|
||||
}
|
||||
|
||||
return usermod.UpdateOneUser(ctx,
|
||||
bson.M{usermod.FN.User.Id: user.Id},
|
||||
bson.M{"$set": bson.M{
|
||||
usermod.FN.User.Password: hashed,
|
||||
usermod.FN.User.UpdatedAt: time.Now(),
|
||||
}},
|
||||
)
|
||||
}
|
||||
|
||||
+60
-141
@@ -3,12 +3,12 @@ package authser
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"videoweb/app/appg"
|
||||
"videoweb/app/middleware/reptilerecord"
|
||||
"videoweb/app/middleware/visit"
|
||||
"videoweb/app/service/configser"
|
||||
"videoweb/pub/common/enum/redisconst"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/netutil"
|
||||
"videoweb/pub/common/srvdef"
|
||||
@@ -16,76 +16,73 @@ import (
|
||||
"videoweb/pub/models/usermod"
|
||||
"videoweb/pub/mongos"
|
||||
"videoweb/pub/pubdef"
|
||||
"videoweb/pub/redis"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// GuestLoginReq 游客登录请求
|
||||
type GuestLoginReq struct {
|
||||
DevID string `json:"devID"` // 设备唯一标示(必填)
|
||||
Mac string `json:"mac"` // 设备 Mac(可选)
|
||||
DeviceId string `json:"deviceId"` // 备用设备ID(可选,写入 DevV2)
|
||||
Channel string `json:"channel"` // 渠道码(可选,用户无商区码时写入 DistrictCode)
|
||||
}
|
||||
const (
|
||||
deviceUserLockRetry = 10
|
||||
deviceUserLockInterval = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
// isGuestUser 是否为可升级的游客身份
|
||||
func isGuestUser(user *usermod.User) bool {
|
||||
if user == nil {
|
||||
return false
|
||||
// ResolveDeviceUser 按设备ID识别用户:先查缓存,再查库,都没有则自动创建
|
||||
func ResolveDeviceUser(ctx context.Context, ua useragent.UA, ip, channel string) (int64, *srvdef.SrvErr) {
|
||||
devID := strings.TrimSpace(ua.DevID)
|
||||
if devID == "" {
|
||||
return 0, srvdef.New(srvdef.ErrParamError, "devID不能为空", "")
|
||||
}
|
||||
if user.Type == pubdef.UserTypeNormal {
|
||||
return false
|
||||
}
|
||||
return !user.IsRegister && strings.TrimSpace(user.AccountNo) == ""
|
||||
}
|
||||
ua.DevID = devID
|
||||
|
||||
// GuestLogin 游客登录:按 token / DevID / Mac / DeviceId 查找,不存在则创建游客
|
||||
func GuestLogin(ctx context.Context, userId int64, ip string, req *GuestLoginReq, ua useragent.UA) (*LoginResp, *srvdef.SrvErr) {
|
||||
if isBotRequest(ctx) {
|
||||
return crawlerGuestLogin()
|
||||
}
|
||||
if req == nil || strings.TrimSpace(req.DevID) == "" {
|
||||
return nil, srvdef.New(srvdef.ErrParamError, "devID不能为空", "")
|
||||
}
|
||||
ua.DevID = strings.TrimSpace(req.DevID)
|
||||
|
||||
var user *usermod.User
|
||||
var serr *srvdef.SrvErr
|
||||
reuseToken := false
|
||||
|
||||
if userId > 0 {
|
||||
user, serr = usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Id: userId})
|
||||
if serr != nil {
|
||||
if serr.Code != srvdef.ErrUserNotExsit {
|
||||
return nil, serr
|
||||
}
|
||||
userId = 0
|
||||
user = nil
|
||||
} else {
|
||||
reuseToken = true
|
||||
cacheKey := redisconst.AppDeviceUserKey(devID)
|
||||
if v, err := redis.Get(cacheKey); err == nil && v != nil {
|
||||
if userId, perr := strconv.ParseInt(*v, 10, 64); perr == nil && userId > 0 {
|
||||
return userId, nil
|
||||
}
|
||||
}
|
||||
|
||||
isNewUser := false
|
||||
if userId == 0 {
|
||||
user, serr = findGuestUser(ctx, req)
|
||||
if serr != nil {
|
||||
if serr.Code != srvdef.ErrUserNotExsit {
|
||||
return nil, serr
|
||||
}
|
||||
user, serr = createGuestUser(ctx, ua, req, ip)
|
||||
if serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
isNewUser = true
|
||||
}
|
||||
user, serr := findOrCreateDeviceUser(ctx, ua, ip, channel)
|
||||
if serr != nil {
|
||||
return 0, serr
|
||||
}
|
||||
|
||||
if user.Status == pubdef.UserStatusDisable {
|
||||
return nil, srvdef.New(srvdef.AccountErrAccessForbid, srvdef.AccountErrAccessForbid.Msg(), "")
|
||||
return 0, srvdef.New(srvdef.AccountErrAccessForbid, srvdef.AccountErrAccessForbid.Msg(), "")
|
||||
}
|
||||
if err := redis.Set(cacheKey, user.Id, redisconst.AppDeviceUserExpire); err != nil {
|
||||
log.Warn("authser:ResolveDeviceUser cache set failed", log.Any("devID", devID), log.E(err))
|
||||
}
|
||||
return user.Id, nil
|
||||
}
|
||||
|
||||
// findOrCreateDeviceUser 按设备ID查找用户,不存在时加锁创建,避免同一设备并发请求建出多个用户
|
||||
func findOrCreateDeviceUser(ctx context.Context, ua useragent.UA, ip, channel string) (*usermod.User, *srvdef.SrvErr) {
|
||||
lockKey := redisconst.AppDeviceUserLockKey(ua.DevID)
|
||||
for i := 0; i < deviceUserLockRetry; i++ {
|
||||
user, serr := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.DevID: ua.DevID})
|
||||
if serr == nil {
|
||||
touchDeviceUser(ctx, user, ua, ip, channel)
|
||||
return user, nil
|
||||
}
|
||||
if serr.Code != srvdef.ErrUserNotExsit {
|
||||
return nil, serr
|
||||
}
|
||||
|
||||
ok, err := redis.Setnx_NewOK(lockKey, 1, redisconst.AppDeviceUserLockExpire)
|
||||
if err != nil {
|
||||
return nil, srvdef.New(srvdef.StoreLevel, "用户创建失败", "")
|
||||
}
|
||||
if ok {
|
||||
defer func() { _ = redis.Del(lockKey) }()
|
||||
return createGuestUser(ctx, ua, ip, channel)
|
||||
}
|
||||
// 其他请求正在为该设备建用户,稍后重查
|
||||
time.Sleep(deviceUserLockInterval)
|
||||
}
|
||||
return nil, srvdef.New(srvdef.StoreLevel, "用户创建失败", "")
|
||||
}
|
||||
|
||||
// touchDeviceUser 更新最近访问信息(缓存未命中时执行,频率受缓存时长限制)
|
||||
func touchDeviceUser(ctx context.Context, user *usermod.User, ua useragent.UA, ip, channel string) {
|
||||
now := time.Now()
|
||||
setDoc := bson.M{
|
||||
usermod.FN.User.LastLoginAt: now,
|
||||
@@ -93,9 +90,6 @@ func GuestLogin(ctx context.Context, userId int64, ip string, req *GuestLoginReq
|
||||
usermod.FN.User.LastIp: ip,
|
||||
usermod.FN.User.LoginType: pubdef.LoginTypeDevice,
|
||||
}
|
||||
if v := strings.TrimSpace(ua.DevID); v != "" {
|
||||
setDoc[usermod.FN.User.DevID] = v
|
||||
}
|
||||
if v := strings.TrimSpace(ua.DevType); v != "" {
|
||||
setDoc[usermod.FN.User.Device] = v
|
||||
}
|
||||
@@ -105,73 +99,15 @@ func GuestLogin(ctx context.Context, userId int64, ip string, req *GuestLoginReq
|
||||
if v := strings.TrimSpace(ua.Ver); v != "" {
|
||||
setDoc[usermod.FN.User.AppVer] = v
|
||||
}
|
||||
if v := strings.TrimSpace(req.Mac); v != "" {
|
||||
setDoc[usermod.FN.User.Mac] = v
|
||||
}
|
||||
if v := strings.TrimSpace(req.DeviceId); v != "" {
|
||||
setDoc[usermod.FN.User.DevV2] = v
|
||||
}
|
||||
// 历史用户 Type 为空/旧值时,未注册则归为游客
|
||||
if isGuestUser(user) && user.Type != pubdef.UserTypeGuest {
|
||||
setDoc[usermod.FN.User.Type] = pubdef.UserTypeGuest
|
||||
user.Type = pubdef.UserTypeGuest
|
||||
}
|
||||
mergeUAExtFieldsToSet(setDoc, user, ua)
|
||||
applyChannelIfMissing(setDoc, user, req.Channel)
|
||||
applyChannelIfMissing(setDoc, user, channel)
|
||||
_ = usermod.UpdateOneUser(ctx, bson.M{usermod.FN.User.Id: user.Id}, bson.M{"$set": setDoc})
|
||||
|
||||
var token string
|
||||
if reuseToken {
|
||||
if old, err := tokener.Get(user.Id); err == nil && len(old) > 0 {
|
||||
token = string(old)
|
||||
}
|
||||
}
|
||||
if token == "" {
|
||||
token, serr = generateAndSaveToken(user.Id)
|
||||
if serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
}
|
||||
|
||||
resp := toLoginResp(ctx, user, token, true)
|
||||
resp.IsNewUser = isNewUser
|
||||
if isNewUser {
|
||||
visit.RecordDailyVisit(ctx, user.Id, ua, ip)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func findGuestUser(ctx context.Context, req *GuestLoginReq) (*usermod.User, *srvdef.SrvErr) {
|
||||
user, serr := usermod.FindOneUser(ctx, bson.M{usermod.FN.User.DevID: req.DevID})
|
||||
if serr == nil {
|
||||
return user, nil
|
||||
}
|
||||
if serr.Code != srvdef.ErrUserNotExsit {
|
||||
return nil, serr
|
||||
}
|
||||
|
||||
mac := strings.TrimSpace(req.Mac)
|
||||
if mac != "" && !strings.Contains(mac, "00:00:00:00") {
|
||||
user, serr = usermod.FindOneUser(ctx, bson.M{usermod.FN.User.Mac: mac})
|
||||
if serr == nil {
|
||||
return user, nil
|
||||
}
|
||||
if serr.Code != srvdef.ErrUserNotExsit {
|
||||
return nil, serr
|
||||
}
|
||||
}
|
||||
|
||||
deviceId := strings.TrimSpace(req.DeviceId)
|
||||
if deviceId != "" && !strings.Contains(deviceId, "00:00:00:00") {
|
||||
return usermod.FindOneUser(ctx, bson.M{usermod.FN.User.DevV2: deviceId})
|
||||
}
|
||||
return nil, srvdef.New(srvdef.ErrUserNotExsit, "", "")
|
||||
}
|
||||
|
||||
func createGuestUser(ctx context.Context, ua useragent.UA, req *GuestLoginReq, ip string) (*usermod.User, *srvdef.SrvErr) {
|
||||
func createGuestUser(ctx context.Context, ua useragent.UA, ip, channel string) (*usermod.User, *srvdef.SrvErr) {
|
||||
now := time.Now()
|
||||
uid := mongos.Lid.User.Get()
|
||||
districtInfo := resolveUserDistrict(req.Channel, "", ip, ua.SysType)
|
||||
districtInfo := resolveUserDistrict(channel, "", ip, ua.SysType)
|
||||
user := &usermod.User{
|
||||
Id: uid,
|
||||
Type: pubdef.UserTypeGuest,
|
||||
@@ -181,13 +117,11 @@ func createGuestUser(ctx context.Context, ua useragent.UA, req *GuestLoginReq, i
|
||||
NickName: fmt.Sprintf("游客%d", uid),
|
||||
Avatar: randomAvatar(),
|
||||
InviteCode: generateUniqueInviteCode(ctx),
|
||||
DistrictCode: normalizeChannel(req.Channel),
|
||||
DistrictCode: normalizeChannel(channel),
|
||||
IsDirect: districtInfo.IsDirect,
|
||||
RegIp: ip,
|
||||
LastIp: ip,
|
||||
DevID: ua.DevID,
|
||||
Mac: strings.TrimSpace(req.Mac),
|
||||
DevV2: strings.TrimSpace(req.DeviceId),
|
||||
Device: ua.DevType,
|
||||
SysType: ua.SysType,
|
||||
AppVer: ua.Ver,
|
||||
@@ -211,14 +145,13 @@ func createGuestUser(ctx context.Context, ua useragent.UA, req *GuestLoginReq, i
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func toLoginResp(ctx context.Context, user *usermod.User, token string, withCDN bool) *LoginResp {
|
||||
func toLoginResp(ctx context.Context, user *usermod.User, withCDN bool) *LoginResp {
|
||||
avatar := user.Avatar
|
||||
if withCDN {
|
||||
cdn := configser.GetAppImageCdn(configser.ClientIPFromCtx(ctx))
|
||||
avatar = netutil.MergeURL(cdn, user.Avatar)
|
||||
}
|
||||
return &LoginResp{
|
||||
Token: token,
|
||||
UserId: user.Id,
|
||||
AccountNo: user.AccountNo,
|
||||
Email: user.Email,
|
||||
@@ -248,20 +181,6 @@ func hasDistrictCode(code string) bool {
|
||||
return strings.TrimSpace(code) != ""
|
||||
}
|
||||
|
||||
func isBotRequest(ctx context.Context) bool {
|
||||
gc, ok := ctx.(*gin.Context)
|
||||
return ok && reptilerecord.IsBot(gc)
|
||||
}
|
||||
|
||||
// crawlerGuestLogin 给爬虫签发可观看的虚拟游客 token,不建用户、不写日活、不上报。
|
||||
func crawlerGuestLogin() (*LoginResp, *srvdef.SrvErr) {
|
||||
token, serr := generateCrawlerToken()
|
||||
if serr != nil {
|
||||
return nil, serr
|
||||
}
|
||||
return CrawlerLoginResp(token), nil
|
||||
}
|
||||
|
||||
func applyChannelIfMissing(setDoc bson.M, user *usermod.User, channel string) {
|
||||
if user == nil || hasDistrictCode(user.DistrictCode) {
|
||||
return
|
||||
|
||||
@@ -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
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"videoweb/app/api/proto"
|
||||
"strings"
|
||||
"videoweb/app/appg"
|
||||
"videoweb/pub/adcenter"
|
||||
"videoweb/pub/common/httputil"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/netutil"
|
||||
"videoweb/pub/storage/proxy"
|
||||
)
|
||||
|
||||
// UpdateAdvitiseDataFromJt 从广告中心拉取福利页广告
|
||||
func UpdateAdvitiseDataFromJt() {
|
||||
config := GetConfigInfo()
|
||||
var resp proto.AdvitiseData
|
||||
jtAds, err := adcenter.JtAdvertiseThreeServer(appg.Conf.AdCenter.ApiDomain, appg.Conf.AdCenter.MerchantCode, appg.Conf.AdCenter.AppCode, appg.Conf.AdCenter.AesKey)
|
||||
// 广告中心应用ID(本站专用)
|
||||
const advertiseAppId int32 = 12
|
||||
|
||||
// advertiseInfo 广告中心 /api/stat/advitise/v2/get 的广告条目
|
||||
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 {
|
||||
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
|
||||
}
|
||||
adMap := make(map[string]adcenter.AdCacheInfo)
|
||||
for _, loc := range jtAds {
|
||||
pos, err := strconv.Atoi(loc.AdvertiseLocationCode)
|
||||
if len(resp.AdvertiseList) == 0 {
|
||||
resp, err = fetchAdvertiseList()
|
||||
if err != nil {
|
||||
log.Error("广告位置代码错误,必须为数字", log.Any("code", loc.AdvertiseLocationCode))
|
||||
continue
|
||||
log.Error("UpdateAdvitiseData fetchAdvertiseList retry fail", log.E(err))
|
||||
return
|
||||
}
|
||||
//if pos < 100001 {
|
||||
// continue
|
||||
//}
|
||||
ads := make([]proxy.AdvitiseInfo, 0)
|
||||
for _, ad := range loc.AdDetailInfoList {
|
||||
//extra := ad.GetExtraData()
|
||||
ads = append(ads, proxy.AdvitiseInfo{
|
||||
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,
|
||||
CustomerCode: ad.CustomerCode,
|
||||
AdvertiseName: ad.AdvertiseName,
|
||||
AdvertiseUrl: ad.AdvertiseUrl,
|
||||
AdvertiseIcon: ad.AdvertiseIcon,
|
||||
AdvertiseType: ad.AdvertiseType,
|
||||
AdMode: ad.AdMode,
|
||||
AppCode: ad.AppCode,
|
||||
LocationType: ad.LocationType,
|
||||
AdvertiseDesc: ad.AdvertiseDesc,
|
||||
PageType: ad.PageType,
|
||||
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,
|
||||
}
|
||||
}
|
||||
list := resp.AdvertiseList
|
||||
sort.SliceStable(list, func(i, j int) bool {
|
||||
if list[i].LocId != list[j].LocId {
|
||||
return list[i].LocId < list[j].LocId
|
||||
}
|
||||
return list[i].Sort < list[j].Sort
|
||||
})
|
||||
|
||||
config := GetConfigInfo()
|
||||
data := proxy.AdvitiseData{}
|
||||
|
||||
for _, v := range list {
|
||||
pos := int64(v.LocId)
|
||||
info := proxy.AdvitiseInfo{
|
||||
Id: strconv.FormatInt(v.Id, 10),
|
||||
Location: pos,
|
||||
Title: v.Title,
|
||||
Images: netutil.MergeURL(config.ImgCdn, strings.TrimLeft(v.CoverImg, "/")),
|
||||
Link: strings.ReplaceAll(v.Link, "inner://yinseinner/", "yinseinner://"),
|
||||
}
|
||||
switch pos {
|
||||
case 1: //弹窗
|
||||
resp.DialogList = ads
|
||||
case 2: // 应用
|
||||
resp.DetailTopList = ads
|
||||
case 3: // 横幅
|
||||
resp.NineGridList = ads
|
||||
resp.DetailbannerList = ads
|
||||
|
||||
case 1:
|
||||
data.DialogList = append(data.DialogList, info)
|
||||
case 2:
|
||||
data.NineGridList = append(data.NineGridList, info)
|
||||
case 3:
|
||||
data.VideoTopList = append(data.VideoTopList, info)
|
||||
data.VideoDownList = append(data.VideoDownList, info)
|
||||
case 12:
|
||||
resp.AList = ads
|
||||
data.AppInfoAList = append(data.AppInfoAList, info)
|
||||
case 13:
|
||||
resp.BList = ads
|
||||
data.AppInfoBList = append(data.AppInfoBList, info)
|
||||
}
|
||||
}
|
||||
|
||||
CacheMgr.Lock.Lock()
|
||||
defer CacheMgr.Lock.Unlock()
|
||||
CacheMgr.Advitise = resp
|
||||
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
|
||||
CacheMgr.Advitise = data
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"sync"
|
||||
"videoweb/app/api/proto"
|
||||
"videoweb/app/service/translationser"
|
||||
"videoweb/pub/adcenter"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/netutil"
|
||||
"videoweb/pub/common/srvdef"
|
||||
@@ -35,7 +34,6 @@ type CacheInfo struct {
|
||||
Lock sync.RWMutex // 读写锁
|
||||
Config proto.ConfigInfo // 系统配置缓存
|
||||
Advitise proto.AdvitiseData
|
||||
AdvitiseMap map[string]adcenter.AdCacheInfo
|
||||
TagCategoryList []proto.VideoTagCategoryData
|
||||
TotalHistory int64
|
||||
IpBlackMaps map[string]struct{}
|
||||
@@ -61,14 +59,14 @@ func init() {
|
||||
func Start() {
|
||||
ctx := context.Background()
|
||||
UpdateConfigInfo(ctx)
|
||||
UpdateAdvitiseDataFromJt()
|
||||
UpdateAdvitiseData(ctx)
|
||||
updateIpBlack()
|
||||
updateTagsCache()
|
||||
updateAppRichTexts()
|
||||
updateAnnouncements()
|
||||
_, _ = skdCron.AddFunc("0 */5 * * * ?", func() {
|
||||
UpdateConfigInfo(ctx)
|
||||
UpdateAdvitiseDataFromJt()
|
||||
UpdateAdvitiseData(ctx)
|
||||
updateIpBlack()
|
||||
updateTagsCache()
|
||||
updateAppRichTexts()
|
||||
|
||||
@@ -123,14 +123,14 @@ func GetM3U8Ex(ctx *gin.Context) {
|
||||
mediaID, expireAt, origM3u8Name, ip, ticket,
|
||||
)
|
||||
|
||||
if !ticketOK {
|
||||
m3u8Name = H5M3U8FallbackPath
|
||||
log.Warn("【GetM3U8Ex】H5播放票据无效",
|
||||
log.Any("mediaId", mediaID),
|
||||
log.Any("expireAt", expireAt),
|
||||
log.Any("ip", ip),
|
||||
log.Any("hasTicket", ticket != ""))
|
||||
}
|
||||
// if !ticketOK {
|
||||
// m3u8Name = H5M3U8FallbackPath
|
||||
// log.Warn("【GetM3U8Ex】H5播放票据无效",
|
||||
// log.Any("mediaId", mediaID),
|
||||
// log.Any("expireAt", expireAt),
|
||||
// log.Any("ip", ip),
|
||||
// log.Any("hasTicket", ticket != ""))
|
||||
// }
|
||||
|
||||
countTowardDailyLimit := ticketOK && ticketInfo.Playable && !ticketInfo.Preview
|
||||
if countTowardDailyLimit && appg.Conf.RunMod == string(consts.RunModeProd) {
|
||||
@@ -152,7 +152,7 @@ func GetM3U8Ex(ctx *gin.Context) {
|
||||
log.Any("vipValid", vipValid),
|
||||
log.E(countErr))
|
||||
} else if cnt > limit {
|
||||
m3u8Name = m3u8RateLimitFallback
|
||||
// m3u8Name = m3u8RateLimitFallback
|
||||
status = "rate_limited"
|
||||
log.Warn("GetM3U8Ex daily rate limit, use fallback m3u8",
|
||||
log.Any("ip", ip),
|
||||
|
||||
@@ -2,11 +2,14 @@ package sitemap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/utils"
|
||||
"videoweb/pub/models/playletcategorymod"
|
||||
"videoweb/pub/models/playletchaptermod"
|
||||
"videoweb/pub/models/playletmod"
|
||||
"videoweb/pub/models/playlettagmod"
|
||||
"videoweb/pub/models/playletthememod"
|
||||
@@ -16,9 +19,10 @@ import (
|
||||
)
|
||||
|
||||
type idWithTime struct {
|
||||
Id int64
|
||||
Slug string
|
||||
LastMod time.Time
|
||||
Id int64
|
||||
Slug string
|
||||
LastMod time.Time
|
||||
IsOriginal bool // 仅短剧使用:原创剧只算已加水印的剧集
|
||||
}
|
||||
|
||||
type staticPageEntry struct {
|
||||
@@ -144,7 +148,7 @@ func getURL(sg *SitemapGenerator) {
|
||||
if urls := buildPlayletPathURLs(webAddr, listed.items, "/detail", "weekly", 0.7); len(urls) > 0 {
|
||||
_ = 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)
|
||||
}
|
||||
}
|
||||
@@ -194,6 +198,78 @@ func buildPlayletPathURLs(webAddr string, items []idWithTime, prefix string, cha
|
||||
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 {
|
||||
if t.IsZero() {
|
||||
return ""
|
||||
@@ -226,6 +302,7 @@ func getPlayletList(ctx context.Context) listedPlaylets {
|
||||
playletmod.FN.Playlet.ThemeIds: 1,
|
||||
playletmod.FN.Playlet.TagIds: 1,
|
||||
playletmod.FN.Playlet.CategoryIds: 1,
|
||||
playletmod.FN.Playlet.IsOriginal: 1,
|
||||
}))
|
||||
for _, info := range list {
|
||||
if info == nil || info.Id <= 0 {
|
||||
@@ -235,7 +312,7 @@ func getPlayletList(ctx context.Context) listedPlaylets {
|
||||
if lastMod.IsZero() {
|
||||
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.tagIDs, info.TagIds)
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,10 @@ const (
|
||||
FiveMVisit = "bd_visitFmt:%s"
|
||||
BloomUser = "bd_bloom_user:%d"
|
||||
AppUserToken = "bd_app_user_token:%d"
|
||||
appDeviceUserFmt = "app:device:user:%s"
|
||||
appDeviceUserLockFmt = "app:device:user:lock:%s"
|
||||
AppDeviceUserExpire = 10 * time.Minute
|
||||
AppDeviceUserLockExpire = 5 * time.Second
|
||||
captchaKey = "bd_captcha_mobile_%s"
|
||||
CaptchaExpire = 5 * time.Minute
|
||||
replayNonceKey = "bd_replay:nonce:_%s"
|
||||
@@ -88,6 +92,16 @@ func AppUserTokenKey(userId int64) string {
|
||||
return fmt.Sprintf(AppUserToken, userId)
|
||||
}
|
||||
|
||||
// AppDeviceUserKey 设备ID到用户ID的缓存
|
||||
func AppDeviceUserKey(devID string) string {
|
||||
return fmt.Sprintf(appDeviceUserFmt, devID)
|
||||
}
|
||||
|
||||
// AppDeviceUserLockKey 按设备ID创建用户时的并发锁
|
||||
func AppDeviceUserLockKey(devID string) string {
|
||||
return fmt.Sprintf(appDeviceUserLockFmt, devID)
|
||||
}
|
||||
|
||||
func MediaM3U8Key(name string) string {
|
||||
return fmt.Sprintf(mediaM3U8Fmt, name)
|
||||
}
|
||||
|
||||
@@ -113,6 +113,19 @@ func IsSlugAllDigits(s string) bool {
|
||||
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 表示已被占用。生成结果不能全是数字。
|
||||
func MakeUniqueSlug(source string, exists func(string) bool) string {
|
||||
pinyin := GetSlugInfo(source)
|
||||
|
||||
@@ -156,6 +156,30 @@ func QueryMedia(baseInfo *MediaQueryeReq, domain string) (result *VideoQueryResu
|
||||
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) {
|
||||
result = &VideoQuerysResult{
|
||||
Data: make([]MediaResp, 0),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"time"
|
||||
"videoweb/pub/models/videoinformationmod"
|
||||
@@ -408,6 +409,33 @@ type AdvitiseInfo struct {
|
||||
Images string `json:"images" bson:"images"` // 视频banner
|
||||
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 {
|
||||
DialogList []AdvitiseInfo `json:"dialogList" bson:"dialogList"` // 弹窗广告
|
||||
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)
|
||||
}
|
||||
|
||||
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) {
|
||||
return proxy.QueryMedias(in, domain)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func AccLogin(c *gin.Context) {
|
||||
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 {
|
||||
common.ServerJSON(c, err.Code, err.Msg)
|
||||
return
|
||||
|
||||
+31
-21
@@ -1,30 +1,40 @@
|
||||
redis:
|
||||
addr: 172.104.181.99:16789
|
||||
db: 2
|
||||
passwd: "B6vJHlYiTseLj77z"
|
||||
addr: 139.162.47.194:6379
|
||||
db: 1
|
||||
passwd: "Redis@fish2026!"
|
||||
subscribe: true
|
||||
mongodb:
|
||||
addr: "mongodb://admin:TESTwfeZYP0kjBdy8DAUdwU@172.104.181.99:57017,103.3.61.140:57020,103.3.61.140:57021/web_91av?replicaSet=yctest&maxPoolSize=200&connectTimeout=30&authSource=admin"
|
||||
logaddr: "mongodb://admin:TESTwfeZYP0kjBdy8DAUdwU@172.104.181.99:57017,103.3.61.140:57020,103.3.61.140:57021/web_91av_log?replicaSet=yctest&maxPoolSize=200&connectTimeout=30&authSource=admin"
|
||||
addr: "mongodb://webhgdj:lQbmsIanlpZAj6au3Nh5gqWN6GV0@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/webhgdj?replicaSet=fish0&maxPoolSize=200&authSource=admin"
|
||||
logaddr: "mongodb://webhgdj:lQbmsIanlpZAj6au3Nh5gqWN6GV0@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/webhgdj_log?replicaSet=fish0&maxPoolSize=200&authSource=admin"
|
||||
es:
|
||||
addr: "http://172.104.181.99:9200"
|
||||
addr: "http://139.162.47.194:9200"
|
||||
user: "elastic"
|
||||
pass: "admin123456"
|
||||
pass: "Es@fish2026!"
|
||||
httpOptions:
|
||||
dcCtxTimeOut: 10
|
||||
jwtKey: "2311b15a4da1c80dc541b99abb622233"
|
||||
tgToken: ""
|
||||
runMod: "dev"
|
||||
runMod: "prod"
|
||||
resKey: "vEukA&w15z4VAD3kAY#fkL#rBnU!WDhN"
|
||||
cdnKey: "vEukAw15z4VAD3kAYfkLrBnUWDhN123"
|
||||
tsAuthKey: "fT5xSg4hltHpzVy6aV9rVECDJ1J1pN"
|
||||
tgToken: ""
|
||||
attack:
|
||||
enable: false
|
||||
appkey: "kaFtkDJRcchRMTI9"
|
||||
h5key: "kaFttDJRcahRMTI7"
|
||||
windowDurationSeconds: 60
|
||||
pprof: false
|
||||
host: "172.104.181.99"
|
||||
listenAddr: "25120"
|
||||
prefetchSubmitUrl: "http://172.104.171.80:9067/master/submit"
|
||||
aiCenterAppId: 25311
|
||||
aiUndressingCallbackUrl: "https://web_mdcomtest-ht.80sygtm.com/api/web/aiorder/strip/callback"
|
||||
host: "172.104.166.87"
|
||||
listenAddr: "20002"
|
||||
origDomain: "https://yuan.bbaazz.me/"
|
||||
trustedProxies: ""
|
||||
bucketVideoAddressV2: "http://139.162.27.29:19996"
|
||||
upAppId: 8
|
||||
swagger:
|
||||
host: "172.104.181.99"
|
||||
user: "mdc"
|
||||
pass: "2@6A1#9e%9c2"
|
||||
bucketVideoAddressV2: "http://139.162.22.207:24996"
|
||||
adCenter:
|
||||
apiDomain: "https://adopenapi.adcs01.top"
|
||||
merchantCode: "1991129808640122880"
|
||||
appCode: "JHA-1009"
|
||||
aesKey: "gD4+rmbX5TS5cLbb3wAN5uEAYp/1j4hkQrS9SzuSjc8"
|
||||
lsjMediaConf:
|
||||
appId: "430696"
|
||||
apiKey: "ed48e96ce490bc94bd5eb5133dd542d0"
|
||||
@@ -34,8 +44,8 @@ lsjMediaConf:
|
||||
m3u8Yuan: "https://zhlsaj.zrr4ij4.site"
|
||||
tsYuan: "https://tssdaa.hlvwcn.cn"
|
||||
|
||||
# 媒资配置
|
||||
# 媒资配置
|
||||
mediaResourceDBCfg:
|
||||
baseUrl: "https://mediav2-api.htycpc.com"
|
||||
merchat: "91porn"
|
||||
secret: "08f1c3ab5e11e9b6c18aa24c06d1eb77"
|
||||
secret: "08f1c3ab5e11e9b6c18aa24c06d1eb77"
|
||||
+8
-25
@@ -1,28 +1,11 @@
|
||||
#!/bin/bash
|
||||
FILE_NAME="web_mdcom_web"
|
||||
REMOTE_FILE_PATH="/home/server2/web_mdcom/web/"
|
||||
TAG_NAME="web_mdcom_web.tar.gz"
|
||||
echo "开始"
|
||||
rm -rf ./web_huangguo_web ./web_huangguo_web.tar.gz
|
||||
GOOS=linux GOARCH=amd64 go build -o web_huangguo_web
|
||||
tar zvcf web_huangguo_web.tar.gz web_huangguo_web
|
||||
|
||||
set -e
|
||||
set -o
|
||||
function send_msg() {
|
||||
msg="@jscdsndj @xiuyuan_Lee @steven0yu %0A服务:SERVER2 站点-91spz.com管理服务(WEB)%0A更新内容:$content%0A创建时间: $(date +%F_%X)%0A操作人:$(git config user.name)"
|
||||
curl -X POST "https://api.telegram.org/bot6357085965:AAEmXfjZnZwnDTicL7Wjbd7cXvYv_G98w8A/sendMessage" -d "chat_id=$1&text=$msg" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
read -p "输入yes, 开始上传: " word
|
||||
if [[ ! "yes" =~ $word ]]; then
|
||||
echo "终止"
|
||||
else
|
||||
read -e -p "本次更新内容(输入q退出编辑): " -r content
|
||||
echo "开始"
|
||||
rm -rf ./$FILE_NAME ./$TAG_NAME ./yinsemd5.txt
|
||||
GOOS=linux GOARCH=amd64 go build -o $FILE_NAME
|
||||
md5sum $FILE_NAME | cut -d ' ' -f1 >yinsemd5.txt
|
||||
tar zvcf $TAG_NAME ./$FILE_NAME yinsemd5.txt
|
||||
md5sum $TAG_NAME | cut -d ' ' -f1 >yinsemd5.txt
|
||||
scp -i ~/.ssh/id_rsa -P 22889 ./yinsemd5.txt server2@116.212.120.2:$REMOTE_FILE_PATH
|
||||
scp -i ~/.ssh/id_rsa -P 22889 ./$TAG_NAME server2@116.212.120.2:$REMOTE_FILE_PATH
|
||||
send_msg -4791758991 #服务器小组
|
||||
fi
|
||||
rm -rf ./$FILE_NAME ./$TAG_NAME ./yinsemd5.txt
|
||||
scp web_huangguo_web.tar.gz root@172.104.166.87:/data/uzip
|
||||
ssh root@172.104.166.87 "/server/web_huangguo/web/up_app.sh"
|
||||
|
||||
rm -rf ./web_huangguo_web ./web_huangguo_web.tar.gz
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
sudo make test
|
||||
|
||||
scp -P 22889 web_91av_web.tar.gz root@172.104.181.99:/server/web_91av/web/
|
||||
ssh root@172.104.181.99 -p 22889 "cd /server/web_91av/web/ && /bin/tar -xf /server/web_91av/web/web_91av_web.tar.gz && /usr/bin/supervisorctl restart web_91av_web"
|
||||
if [ $? -eq 0 ];then
|
||||
echo -e "\033[32m 91spz.com web更新成功 \033[0m"
|
||||
else
|
||||
echo -e "\033[31m 91spz.com web更新失败 \033[0m"
|
||||
fi
|
||||
rm -f web_91av_web.tar.gz
|
||||
@@ -1276,8 +1276,7 @@ func ensureImportedPlayletSlug(ctx context.Context, playlet *playletmod.Playlet)
|
||||
if playlet == nil {
|
||||
return srvdef.New(srvdef.ErrParamError, "短剧数据为空", "")
|
||||
}
|
||||
source := utils.SlugSourceFromKeywordsOrTitle(playlet.SeoInfo.Keyworld, playlet.Title)
|
||||
playlet.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
|
||||
playlet.Slug = utils.MakeRandomSlug(func(slug string) bool {
|
||||
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
|
||||
playletmod.FN.Playlet.Slug: slug,
|
||||
})
|
||||
|
||||
@@ -9,11 +9,9 @@ import (
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/srvdef"
|
||||
"videoweb/pub/common/utils"
|
||||
"videoweb/pub/google"
|
||||
"videoweb/pub/models/mwacc"
|
||||
"videoweb/web/webg"
|
||||
|
||||
"github.com/skip2/go-qrcode"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
@@ -78,8 +76,8 @@ func isCustomerServiceRole(ctx context.Context, acc *mwacc.MwAcc) bool {
|
||||
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
|
||||
res, dataErr := mwacc.FindOneAccByFilter(ctx, bson.M{
|
||||
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(), "")
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Id: res.Id,
|
||||
}, bson.M{
|
||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||
})
|
||||
// 更新最近登录时间
|
||||
data = res
|
||||
data.Token = getToken
|
||||
getToken, err := generateToken(res.Id)
|
||||
if err != nil {
|
||||
return data, srvdef.New(srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg(), "")
|
||||
}
|
||||
// 更新最近登录时间
|
||||
_ = mwacc.UpOneAccByFilter(ctx, bson.M{
|
||||
mwacc.FN.MwAcc.Id: res.Id,
|
||||
}, bson.M{
|
||||
mwacc.FN.MwAcc.LastTime: time.Now(),
|
||||
})
|
||||
data = res
|
||||
data.Token = getToken
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ func ensureThemeSlug(ctx context.Context, ac *playletthememod.PlayletTheme, excl
|
||||
}
|
||||
return nil
|
||||
}
|
||||
source := utils.SlugSourceFromKeywordsOrTitle(ac.SeoInfo.Keyworld, ac.Name)
|
||||
ac.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
|
||||
ac.Slug = utils.MakeRandomSlug(func(slug string) bool {
|
||||
filter := bson.M{playletthememod.FN.PlayletTheme.Slug: slug}
|
||||
if excludeId > 0 {
|
||||
filter[playletthememod.FN.PlayletTheme.Id] = bson.M{"$ne": excludeId}
|
||||
@@ -81,16 +80,7 @@ func prepareThemeSlugOnUpdate(ctx context.Context, id int64, info *playletthemem
|
||||
}
|
||||
return nil
|
||||
}
|
||||
name := info.Name
|
||||
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 {
|
||||
newSlug := utils.MakeRandomSlug(func(s string) bool {
|
||||
exist, _ := playletthememod.FindOnePlayletTheme(ctx, bson.M{
|
||||
playletthememod.FN.PlayletTheme.Slug: s,
|
||||
playletthememod.FN.PlayletTheme.Id: bson.M{"$ne": id},
|
||||
@@ -186,8 +176,7 @@ func ensurePlayletSlug(ctx context.Context, ac *playletmod.Playlet, excludeId in
|
||||
}
|
||||
return nil
|
||||
}
|
||||
source := utils.SlugSourceFromKeywordsOrTitle(ac.SeoInfo.Keyworld, ac.Title)
|
||||
ac.Slug = utils.MakeUniqueSlug(source, func(slug string) bool {
|
||||
ac.Slug = utils.MakeRandomSlug(func(slug string) bool {
|
||||
filter := bson.M{playletmod.FN.Playlet.Slug: slug}
|
||||
if excludeId > 0 {
|
||||
filter[playletmod.FN.Playlet.Id] = bson.M{"$ne": excludeId}
|
||||
@@ -219,16 +208,7 @@ func preparePlayletSlugOnUpdate(ctx context.Context, id int64, info *playletmod.
|
||||
}
|
||||
return nil
|
||||
}
|
||||
title := info.Title
|
||||
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 {
|
||||
newSlug := utils.MakeRandomSlug(func(s string) bool {
|
||||
exist, _ := playletmod.FindOnePlaylet(ctx, bson.M{
|
||||
playletmod.FN.Playlet.Slug: s,
|
||||
playletmod.FN.Playlet.Id: bson.M{"$ne": id},
|
||||
|
||||
Reference in New Issue
Block a user