更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -9,12 +9,6 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// =============================================================
|
||||
// 平台官网 - 文章管理 /platform/website/article/*
|
||||
// - 分类管理 /platform/website/category/*
|
||||
// 表:yz_platform_website_article / yz_platform_website_category
|
||||
// =============================================================
|
||||
|
||||
type PlatformWebsiteArticleController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -33,7 +27,6 @@ type platformWebsiteArticlePayload struct {
|
||||
Tags []uint64 `json:"tags"`
|
||||
}
|
||||
|
||||
// articleCateID 兼容前端 cate / cate_id 两种传参
|
||||
func (p *platformWebsiteArticlePayload) articleCateID() (uint64, bool) {
|
||||
if p.Cate != nil {
|
||||
return *p.Cate, true
|
||||
@@ -44,8 +37,6 @@ func (p *platformWebsiteArticlePayload) articleCateID() (uint64, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// List GET /platform/website/article/list
|
||||
// query: keyword、cate、status、startDate、endDate、page、pageSize
|
||||
func (c *PlatformWebsiteArticleController) List() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -120,7 +111,6 @@ func (c *PlatformWebsiteArticleController) List() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"list": list, "total": total})
|
||||
}
|
||||
|
||||
// ListAll GET /platform/website/article/all — 不分页,供选择/关联使用
|
||||
func (c *PlatformWebsiteArticleController) ListAll() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -141,7 +131,6 @@ func (c *PlatformWebsiteArticleController) ListAll() {
|
||||
websiteOK(&c.Controller, rows)
|
||||
}
|
||||
|
||||
// Recycle GET /platform/website/article/recycle — 回收站(已软删除的文章)
|
||||
func (c *PlatformWebsiteArticleController) Recycle() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -202,7 +191,6 @@ func (c *PlatformWebsiteArticleController) Recycle() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"list": list, "total": total})
|
||||
}
|
||||
|
||||
// Restore POST /platform/website/article/:id/restore — 从回收站恢复
|
||||
func (c *PlatformWebsiteArticleController) Restore() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -211,7 +199,6 @@ func (c *PlatformWebsiteArticleController) Restore() {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
// 清空 delete_time 属于「反软删除」,beego 的 Update(map) 不便表达,直接走 SQL
|
||||
res, err := models.Orm.Raw(
|
||||
"UPDATE yz_platform_website_article SET delete_time = NULL, update_time = ? WHERE id = ? AND delete_time IS NOT NULL",
|
||||
time.Now(), id,
|
||||
@@ -227,7 +214,6 @@ func (c *PlatformWebsiteArticleController) Restore() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Purge DELETE /platform/website/article/:id/purge — 彻底删除(仅限回收站中的记录)
|
||||
func (c *PlatformWebsiteArticleController) Purge() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -252,7 +238,6 @@ func (c *PlatformWebsiteArticleController) Purge() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Get GET /platform/website/article/:id — 详情(含标签ID列表)
|
||||
func (c *PlatformWebsiteArticleController) Get() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -304,7 +289,6 @@ func (c *PlatformWebsiteArticleController) Get() {
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// Create POST /platform/website/article
|
||||
func (c *PlatformWebsiteArticleController) Create() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -348,7 +332,6 @@ func (c *PlatformWebsiteArticleController) Create() {
|
||||
if p.Status != nil {
|
||||
row.Status = *p.Status
|
||||
}
|
||||
// 直接提交待审核时同步记录发布时间
|
||||
if row.Status == 2 {
|
||||
now := time.Now()
|
||||
row.PublishTime = &now
|
||||
@@ -366,7 +349,6 @@ func (c *PlatformWebsiteArticleController) Create() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"id": id})
|
||||
}
|
||||
|
||||
// Update POST /platform/website/article/:id
|
||||
func (c *PlatformWebsiteArticleController) Update() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -435,7 +417,6 @@ func (c *PlatformWebsiteArticleController) Update() {
|
||||
jsonErr(&c.Controller, 404, 404, "文章不存在")
|
||||
return
|
||||
}
|
||||
// tags 传了才覆盖,未传则保持原有关联
|
||||
if p.Tags != nil {
|
||||
if err = models.SetPlatformWebsiteArticleTags(id, p.Tags); err != nil {
|
||||
jsonErr(&c.Controller, 500, 500, "标签保存失败: "+err.Error())
|
||||
@@ -445,7 +426,6 @@ func (c *PlatformWebsiteArticleController) Update() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Delete DELETE /platform/website/article/:id
|
||||
func (c *PlatformWebsiteArticleController) Delete() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -471,8 +451,6 @@ func (c *PlatformWebsiteArticleController) Delete() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Publish POST /platform/website/article/:id/publish
|
||||
// body: { uid } 选填,用于记录发布人(平台管理员ID)
|
||||
func (c *PlatformWebsiteArticleController) Publish() {
|
||||
claims, ok := websiteAuth(&c.Controller)
|
||||
if !ok {
|
||||
@@ -485,7 +463,6 @@ func (c *PlatformWebsiteArticleController) Publish() {
|
||||
var p struct {
|
||||
UID *uint64 `json:"uid"`
|
||||
}
|
||||
// 发布人参数可选,缺失时回退为当前登录管理员
|
||||
websiteBindOptional(&c.Controller, &p)
|
||||
|
||||
publisher := uint64(claims.UserID)
|
||||
@@ -514,7 +491,6 @@ func (c *PlatformWebsiteArticleController) Publish() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// UnPublish POST /platform/website/article/:id/unpublish — 下架后状态置为「已隐藏」
|
||||
func (c *PlatformWebsiteArticleController) UnPublish() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -538,7 +514,6 @@ func (c *PlatformWebsiteArticleController) UnPublish() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// updateArticleFlag 统一处理推荐/置顶标记
|
||||
func (c *PlatformWebsiteArticleController) updateArticleFlag(field string, value int8, failMsg string) {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -562,30 +537,22 @@ func (c *PlatformWebsiteArticleController) updateArticleFlag(field string, value
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Recommend POST /platform/website/article/:id/recommend
|
||||
func (c *PlatformWebsiteArticleController) Recommend() {
|
||||
c.updateArticleFlag("recommend", 1, "推荐失败")
|
||||
}
|
||||
|
||||
// UnRecommend POST /platform/website/article/:id/unrecommend
|
||||
func (c *PlatformWebsiteArticleController) UnRecommend() {
|
||||
c.updateArticleFlag("recommend", 0, "取消推荐失败")
|
||||
}
|
||||
|
||||
// Top POST /platform/website/article/:id/top
|
||||
func (c *PlatformWebsiteArticleController) Top() {
|
||||
c.updateArticleFlag("top", 1, "置顶失败")
|
||||
}
|
||||
|
||||
// UnTop POST /platform/website/article/:id/untop
|
||||
func (c *PlatformWebsiteArticleController) UnTop() {
|
||||
c.updateArticleFlag("top", 0, "取消置顶失败")
|
||||
}
|
||||
|
||||
// =============================================================
|
||||
// 分类管理
|
||||
// =============================================================
|
||||
|
||||
type PlatformWebsiteCategoryController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -599,7 +566,6 @@ type platformWebsiteCategoryPayload struct {
|
||||
Status *int8 `json:"status"`
|
||||
}
|
||||
|
||||
// All GET /platform/website/category/all — 全量返回(前端自行组树),支持 keyword
|
||||
func (c *PlatformWebsiteCategoryController) All() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -617,7 +583,6 @@ func (c *PlatformWebsiteCategoryController) All() {
|
||||
websiteOK(&c.Controller, rows)
|
||||
}
|
||||
|
||||
// List GET /platform/website/category/list — 分页
|
||||
func (c *PlatformWebsiteCategoryController) List() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -641,7 +606,6 @@ func (c *PlatformWebsiteCategoryController) List() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"list": rows, "total": total})
|
||||
}
|
||||
|
||||
// Get GET /platform/website/category/:id
|
||||
func (c *PlatformWebsiteCategoryController) Get() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -661,7 +625,6 @@ func (c *PlatformWebsiteCategoryController) Get() {
|
||||
websiteOK(&c.Controller, row)
|
||||
}
|
||||
|
||||
// Create POST /platform/website/category
|
||||
func (c *PlatformWebsiteCategoryController) Create() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -701,7 +664,6 @@ func (c *PlatformWebsiteCategoryController) Create() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"id": id})
|
||||
}
|
||||
|
||||
// Update POST /platform/website/category/:id
|
||||
func (c *PlatformWebsiteCategoryController) Update() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -763,7 +725,6 @@ func (c *PlatformWebsiteCategoryController) Update() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// UpdateStatus PATCH /platform/website/category/:id/status — body { status }
|
||||
func (c *PlatformWebsiteCategoryController) UpdateStatus() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -794,7 +755,6 @@ func (c *PlatformWebsiteCategoryController) UpdateStatus() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Delete DELETE /platform/website/category/:id — 存在子分类时禁止删除
|
||||
func (c *PlatformWebsiteCategoryController) Delete() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user