更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -11,16 +11,6 @@ import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// =============================================================
|
||||
// 平台官网 - 站点公告 /platform/website/notice/*
|
||||
// 表:yz_platform_website_notice
|
||||
// 建表 SQL:docs/sql/create_platform_website_notice.sql
|
||||
//
|
||||
// 公告状态:0 草稿 / 1 已发布 / 2 已下线。
|
||||
// 前台 GET /site/notices 只返回「已发布」且当前时间处于有效期内的公告,
|
||||
// 见 index_website.go 的 noticeVisibleCond。
|
||||
// =============================================================
|
||||
|
||||
const (
|
||||
noticeStatusDraft int8 = 0
|
||||
noticeStatusPublished int8 = 1
|
||||
@@ -45,8 +35,6 @@ type platformWebsiteNoticePayload struct {
|
||||
EndTime *string `json:"end_time"`
|
||||
}
|
||||
|
||||
// parseNoticeTime 解析前端时间字符串,支持 "2006-01-02 15:04:05"、RFC3339、"2006-01-02";
|
||||
// 空串或无法识别时返回 nil(对应数据库 NULL,表示不限制时间)。
|
||||
func parseNoticeTime(raw *string) *time.Time {
|
||||
if raw == nil {
|
||||
return nil
|
||||
@@ -63,8 +51,6 @@ func parseNoticeTime(raw *string) *time.Time {
|
||||
return nil
|
||||
}
|
||||
|
||||
// noticeVisibleCond 前台可见条件:未删除 + 已发布 + 当前时间落在 [start_time, end_time] 内
|
||||
// start_time / end_time 为 NULL 表示该侧不限制。
|
||||
func noticeVisibleCond() *orm.Condition {
|
||||
now := time.Now()
|
||||
return orm.NewCondition().
|
||||
@@ -74,7 +60,6 @@ func noticeVisibleCond() *orm.Condition {
|
||||
AndCond(orm.NewCondition().Or("end_time__isnull", true).Or("end_time__gte", now))
|
||||
}
|
||||
|
||||
// noticeFromPayload 依据请求体构造新公告,缺省:类型=通知公告、状态=草稿
|
||||
func noticeFromPayload(p platformWebsiteNoticePayload) models.PlatformWebsiteNotice {
|
||||
row := models.PlatformWebsiteNotice{
|
||||
Type: 1,
|
||||
@@ -112,7 +97,6 @@ func noticeFromPayload(p platformWebsiteNoticePayload) models.PlatformWebsiteNot
|
||||
return row
|
||||
}
|
||||
|
||||
// noticeUpdateMap 把请求体转成待更新字段,只包含显式传入的键(未传的字段保持原值)
|
||||
func noticeUpdateMap(p platformWebsiteNoticePayload) map[string]interface{} {
|
||||
up := map[string]interface{}{}
|
||||
if p.Title != nil {
|
||||
@@ -151,8 +135,6 @@ func noticeUpdateMap(p platformWebsiteNoticePayload) map[string]interface{} {
|
||||
return up
|
||||
}
|
||||
|
||||
// List GET /platform/website/notice/list
|
||||
// query: keyword(标题/摘要)、type、status、is_popup、page、pageSize
|
||||
func (c *PlatformWebsiteNoticeController) List() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -181,7 +163,6 @@ func (c *PlatformWebsiteNoticeController) List() {
|
||||
jsonErr(&c.Controller, 500, 500, "获取失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
// 列表不返回富文本正文,减小响应体
|
||||
var rows []models.PlatformWebsiteNotice
|
||||
if _, err = qs.OrderBy("-top", "sort", "-id").
|
||||
Limit(pageSize, (page-1)*pageSize).
|
||||
@@ -194,7 +175,6 @@ func (c *PlatformWebsiteNoticeController) List() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"list": rows, "total": total})
|
||||
}
|
||||
|
||||
// Get GET /platform/website/notice/:id — 含正文,供编辑回显
|
||||
func (c *PlatformWebsiteNoticeController) Get() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -214,7 +194,6 @@ func (c *PlatformWebsiteNoticeController) Get() {
|
||||
websiteOK(&c.Controller, row)
|
||||
}
|
||||
|
||||
// Create POST /platform/website/notice
|
||||
func (c *PlatformWebsiteNoticeController) Create() {
|
||||
claims, ok := websiteAuth(&c.Controller)
|
||||
if !ok {
|
||||
@@ -230,7 +209,6 @@ func (c *PlatformWebsiteNoticeController) Create() {
|
||||
}
|
||||
|
||||
row := noticeFromPayload(p)
|
||||
// 直接提交为已发布时同步补发布时间与发布人
|
||||
if row.Status == noticeStatusPublished {
|
||||
now := time.Now()
|
||||
uid := uint64(claims.UserID)
|
||||
@@ -246,7 +224,6 @@ func (c *PlatformWebsiteNoticeController) Create() {
|
||||
websiteOK(&c.Controller, map[string]interface{}{"id": id})
|
||||
}
|
||||
|
||||
// Update POST /platform/website/notice/:id
|
||||
func (c *PlatformWebsiteNoticeController) Update() {
|
||||
claims, ok := websiteAuth(&c.Controller)
|
||||
if !ok {
|
||||
@@ -265,7 +242,6 @@ func (c *PlatformWebsiteNoticeController) Update() {
|
||||
return
|
||||
}
|
||||
|
||||
// 先取原记录:既用于 404 判断,也用于判断是否「首次转为已发布」
|
||||
var row models.PlatformWebsiteNotice
|
||||
if err := models.Orm.QueryTable(new(models.PlatformWebsiteNotice)).
|
||||
Filter("id", id).
|
||||
@@ -281,7 +257,6 @@ func (c *PlatformWebsiteNoticeController) Update() {
|
||||
return
|
||||
}
|
||||
if p.Status != nil && *p.Status == noticeStatusPublished && row.Status != noticeStatusPublished {
|
||||
// 首次发布才写发布时间,避免每次保存覆盖发布时间
|
||||
now := time.Now()
|
||||
uid := uint64(claims.UserID)
|
||||
up["publish_time"] = now
|
||||
@@ -299,14 +274,12 @@ func (c *PlatformWebsiteNoticeController) Update() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// noticeToggle 更新单个开关字段(status / top / is_popup)
|
||||
func (c *PlatformWebsiteNoticeController) noticeToggle(claims *jwtutil.Claims, field string, value int8) {
|
||||
id, ok := websiteID(&c.Controller)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
up := map[string]interface{}{field: value, "update_time": time.Now()}
|
||||
// 发布时补发布时间与发布人(其余开关无需登录身份,claims 可能为 nil)
|
||||
if field == "status" && value == noticeStatusPublished {
|
||||
up["publish_time"] = time.Now()
|
||||
if claims != nil {
|
||||
@@ -328,7 +301,6 @@ func (c *PlatformWebsiteNoticeController) noticeToggle(claims *jwtutil.Claims, f
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// Publish POST /platform/website/notice/:id/publish — 状态置为已发布
|
||||
func (c *PlatformWebsiteNoticeController) Publish() {
|
||||
claims, ok := websiteAuth(&c.Controller)
|
||||
if !ok {
|
||||
@@ -337,7 +309,6 @@ func (c *PlatformWebsiteNoticeController) Publish() {
|
||||
c.noticeToggle(claims, "status", noticeStatusPublished)
|
||||
}
|
||||
|
||||
// UnPublish POST /platform/website/notice/:id/unpublish — 状态置为已下线
|
||||
func (c *PlatformWebsiteNoticeController) UnPublish() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -345,7 +316,6 @@ func (c *PlatformWebsiteNoticeController) UnPublish() {
|
||||
c.noticeToggle(nil, "status", noticeStatusOffline)
|
||||
}
|
||||
|
||||
// Top POST /platform/website/notice/:id/top
|
||||
func (c *PlatformWebsiteNoticeController) Top() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -353,7 +323,6 @@ func (c *PlatformWebsiteNoticeController) Top() {
|
||||
c.noticeToggle(nil, "top", 1)
|
||||
}
|
||||
|
||||
// UnTop POST /platform/website/notice/:id/untop
|
||||
func (c *PlatformWebsiteNoticeController) UnTop() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -361,7 +330,6 @@ func (c *PlatformWebsiteNoticeController) UnTop() {
|
||||
c.noticeToggle(nil, "top", 0)
|
||||
}
|
||||
|
||||
// Popup POST /platform/website/notice/:id/popup — 标记为弹窗公告
|
||||
func (c *PlatformWebsiteNoticeController) Popup() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -369,7 +337,6 @@ func (c *PlatformWebsiteNoticeController) Popup() {
|
||||
c.noticeToggle(nil, "is_popup", 1)
|
||||
}
|
||||
|
||||
// UnPopup POST /platform/website/notice/:id/unpopup
|
||||
func (c *PlatformWebsiteNoticeController) UnPopup() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -377,7 +344,6 @@ func (c *PlatformWebsiteNoticeController) UnPopup() {
|
||||
c.noticeToggle(nil, "is_popup", 0)
|
||||
}
|
||||
|
||||
// Delete DELETE /platform/website/notice/:id — 软删除
|
||||
func (c *PlatformWebsiteNoticeController) Delete() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
@@ -402,7 +368,6 @@ func (c *PlatformWebsiteNoticeController) Delete() {
|
||||
websiteOK(&c.Controller, nil)
|
||||
}
|
||||
|
||||
// BatchDelete POST /platform/website/notice/batchdelete — body { ids: [] }
|
||||
func (c *PlatformWebsiteNoticeController) BatchDelete() {
|
||||
if _, ok := websiteAuth(&c.Controller); !ok {
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user