按意图重做在 huakui 代码底: - 删除数据埋点逻辑:移除 pub/dataReport、reportser、srv_report、 eventmod、上报定时任务及注册/登录/点赞/收藏/评论/解锁/订单处的 上报调用和 reportSdkConfig 配置下发 - app 认证改为按设备ID识别用户:去掉 token 校验、Register/Login/ ResetPassword/GuestLogin 接口,新增 ResolveDeviceUser 和设备缓存 - 广告改为按 AppId 从媒资中心拉取:pub/storage 新增 QueryAdvitise, UpdateAdvitiseData 替代 UpdateAdvitiseDataFromJt - 后台登录取消谷歌二次验证,密码正确即登录 - 短剧/专题 slug 改为 10 位大小写字母+数字混合 - 本地 app.yaml/web.yaml 保留 HKDJNET_* 模板(不提交生产凭据) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
111 lines
3.0 KiB
Go
111 lines
3.0 KiB
Go
package web_acc
|
|
|
|
import (
|
|
"hkdj-web-server/pub/common"
|
|
"hkdj-web-server/pub/common/srvdef"
|
|
"hkdj-web-server/pub/models/mwacc"
|
|
"hkdj-web-server/web/service/srv_mwacc"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// @Tags 登录
|
|
// @Summary 登录-登录
|
|
// @Description 登录-登录
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body MainWebLoginReq true "参数列表"
|
|
// @Success 200 {object} MainWebLoginResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Router /api/web/login/acc [POST]
|
|
func AccLogin(c *gin.Context) {
|
|
var req MainWebLoginReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(c, srvdef.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
|
|
accInfo, err := srv_mwacc.AccLogin(c, req.Acc, req.Pwd)
|
|
if err != nil || accInfo == nil {
|
|
common.ServerJSON(c, err.Code, err.Msg)
|
|
return
|
|
}
|
|
|
|
// 成功保存token
|
|
if ok, _ := mwacc.SaveToken(c, accInfo.Id, accInfo.Token); ok != true {
|
|
common.ServerJSON(c, srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg())
|
|
}
|
|
|
|
resp := MainWebLoginResp{
|
|
AccId: accInfo.Id,
|
|
Acc: accInfo.Acc,
|
|
RoleId: accInfo.RoleId,
|
|
Token: accInfo.Token,
|
|
}
|
|
common.ServerJSON(c, srvdef.Success, resp)
|
|
return
|
|
}
|
|
|
|
// SLogin doc
|
|
// @Summary 管理员sso登陆
|
|
// @Description 管理员sso登陆
|
|
// @Tags web-单点登陆
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Param name formData string true "账号"
|
|
// @Param password formData string true "密码"
|
|
// @Success 200 {string} json "{"msg": "管理员信息""}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/login/slogin [post]
|
|
func SLogin(c *gin.Context) {
|
|
var req MainWebLoginReq
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(c, srvdef.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
accInfo, err := srv_mwacc.AccSLogin(c, req.Acc, req.Pwd)
|
|
if err != nil || accInfo == nil {
|
|
common.ServerJSON(c, err.Code, err.Msg)
|
|
return
|
|
}
|
|
resp := MainWebLoginResp{}
|
|
// 成功保存token
|
|
if ok, _ := mwacc.SaveToken(c, accInfo.Id, accInfo.Token); ok != true {
|
|
common.ServerJSON(c, srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg())
|
|
}
|
|
resp.AccId = accInfo.Id
|
|
resp.Acc = accInfo.Acc
|
|
resp.RoleId = accInfo.RoleId
|
|
resp.Token = accInfo.Token
|
|
|
|
common.ServerJSON(c, srvdef.Success, resp)
|
|
return
|
|
}
|
|
|
|
// @Tags 登录
|
|
// @Summary 登录-绑定二维码
|
|
// @Description 登录-绑定二维码
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body BindQurlReq true "参数列表"
|
|
// @Success 200 {object} BindQurlResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Router /api/web/login/bind [POST]
|
|
func BindQurl(c *gin.Context) {
|
|
var req BindQurlReq
|
|
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
common.ServerJSON(c, srvdef.ErrParamError, "tone AccLogin arg error "+err.Error())
|
|
return
|
|
}
|
|
|
|
ok, _ := mwacc.BindAccQurl(c, req.Acc)
|
|
if !ok {
|
|
common.ServerJSON(c, srvdef.Failure, BindQurlResp{Result: false})
|
|
return
|
|
}
|
|
common.ServerJSON(c, srvdef.Success, BindQurlResp{Result: true})
|
|
return
|
|
}
|