代码优化

This commit is contained in:
2026-10-26 21:53:19 +08:00
parent 65fca60622
commit 4d010cdc79
8 changed files with 166 additions and 71 deletions
+10 -14
View File
@@ -26,26 +26,22 @@ 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
}
resp := MainWebLoginResp{}
// 成功保存token
if ok, _ := mwacc.SaveToken(c, accInfo.Id, accInfo.Token); ok != true {
common.ServerJSON(c, srvdef.GenerateTokenFailed, srvdef.GenerateTokenFailed.Msg())
}
if len(accInfo.Qurl) != 0 {
resp.Qurl = accInfo.Qurl
} else {
// 成功保存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
resp := MainWebLoginResp{
AccId: accInfo.Id,
Acc: accInfo.Acc,
RoleId: accInfo.RoleId,
Token: accInfo.Token,
}
common.ServerJSON(c, srvdef.Success, resp)
return
+33
View File
@@ -0,0 +1,33 @@
package web_seopush
import (
"strconv"
"videoweb/pub/common"
"videoweb/pub/common/srvdef"
"videoweb/web/service/srv_seopush"
"github.com/gin-gonic/gin"
)
// @Tags SEO推送
// @Summary IndexNow 批量提交(主页 + 专题)
// @Description 组装主页和前 N 个专题(按 Rank 降序)地址,提交到 IndexNow(Bing / Yandex 等)。
// @Produce json
// @Param limit query int false "URL 总数,含主页,默认 10"
// @Param host query string false "覆盖 sys_cfg.webAddr 的目标域名(支持带或不带 scheme)"
// @Success 200 {object} srv_seopush.BulkIndexNowResult
// @Router /api/web/seopush/indexnow/bulk [POST]
func SubmitHomeAndThemes(ctx *gin.Context) {
limit, _ := strconv.Atoi(ctx.Query("limit"))
if limit <= 0 {
limit = 10
}
host := ctx.Query("host")
resp, serr := srv_seopush.SubmitHomeAndThemes(ctx, limit, host)
if serr != nil {
common.ServerJSON(ctx, serr.Code, serr.Msg)
return
}
common.ServerJSON(ctx, srvdef.Success, resp)
}