Files
rootandClaude Opus 4.7 cd8dea8787 同步 web_hga 的五项改造
- 移除 买点 (user acquisition tracking) 子系统:dataReport SDK、eventmod
  事件模型、reportdata 定时上报 job、reportser/srv_report 包装层,以及业务
  侧的 ~20 处 Report* 调用点;去掉 proto.ConfigInfo 的 ReportSDKConfig
  字段、DataReport yaml 配置块和 pubdef.TrackerAppId。
- 广告获取改走 versionUrl /api/stat/advitise/v2/get(appId=12),移除
  adcenter(Jt) 调用;新增 POST /api/app/ads/click 异步上报;
  proto.AdvitiseData 别名 proxy.AdvitiseData,AList/BList 改名
  AppInfoAList/AppInfoBList。
- web 后台登录取消谷歌验证码(srv_mwacc.AccLogin 去掉 code 参数),密码
  正确即发放 token。
- app 端取消注册/登录/找回密码/游客登录接口及密码、token 相关代码;鉴权
  中间件按 X-User-Agent 中的 devID 识别用户,首次访问自动建号,Redis 缓存
  10 分钟;修改资料不再支持改密码。
- app m3u8 ticket 校验失败不再降级到 fallback 路径,仍按原 m3u8Name 返回。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-11-07 11:22:25 +08:00

90 lines
2.7 KiB
Go

package authapi
import (
"videoweb/app/service/authser"
"videoweb/app/service/wordsfilterser"
"videoweb/pub/common"
"videoweb/pub/common/srvdef"
"videoweb/pub/common/useragent"
"videoweb/pub/pubdef"
"github.com/gin-gonic/gin"
)
func requestUA(ctx *gin.Context) useragent.UA {
ua, _ := common.GetUA(ctx)
return ua
}
type updateProfileReq struct {
NickName *string `json:"nickName"` // 新昵称(可选)
Avatar *string `json:"avatar"` // 新头像 URL(可选)
Introduction *string `json:"introduction"` // 简介(可选)
PrivacyMode *bool `json:"privacyMode"` // 隐私模式:true-开启,false-关闭(可选)
}
// UpdateProfile 修改用户资料
// @Tags 用户认证
// @Summary 修改用户资料(昵称 / 头像 / 简介 / 隐私模式,可任意组合)
// @Description 按请求头 X-User-Agent 中的 devID 识别用户;nickName、avatar、introduction、privacyMode 均为可选,至少提供一项。
// @Accept json
// @Produce json
// @Param param body updateProfileReq true "修改资料参数"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Router /api/app/auth/profile [POST]
func UpdateProfile(ctx *gin.Context) {
userId := common.GetUserId(ctx)
if userId <= 0 {
common.ServerJSON(ctx, srvdef.InvalidToken, nil)
return
}
var req updateProfileReq
if err := ctx.ShouldBind(&req); err != nil {
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
return
}
if req.NickName != nil && !wordsfilterser.Validate(*req.NickName) {
common.ServerJSON(ctx, srvdef.ErrContainIllegalWord, "包含非法字符")
return
}
serr := authser.UpdateProfile(ctx, &authser.UpdateProfileReq{
UserId: userId,
NickName: req.NickName,
Avatar: req.Avatar,
Introduction: req.Introduction,
PrivacyMode: req.PrivacyMode,
})
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, "")
}
// GetInfo 获取当前用户信息
// @Tags 用户认证
// @Summary 获取当前用户信息
// @Description 按请求头 X-User-Agent 中的 devID 识别用户,返回最新用户信息,包含金币余额、VIP状态等
// @Produce json
// @Success 200 {object} authser.LoginResp "用户信息"
// @Failure 400 {string} string "失败"
// @Router /api/app/auth/getInfo [GET]
func GetInfo(ctx *gin.Context) {
userId := common.GetUserId(ctx)
if pubdef.IsCrawlerUser(userId) {
common.ServerJSON(ctx, srvdef.Success, authser.CrawlerLoginResp())
return
}
if userId <= 0 {
common.ServerJSON(ctx, srvdef.InvalidToken, nil)
return
}
resp, serr := authser.GetInfo(ctx, userId, requestUA(ctx))
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Tips)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}