feat: 大屏新增虚拟工位滚动栏与多订单轮播,附件表增加删除原因及彻底清除留痕字段
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/internal/backup"
|
||||
@@ -10,6 +12,19 @@ import (
|
||||
"bj_power_mes/internal/svc"
|
||||
)
|
||||
|
||||
// checkCleanupProtect 数据保护期校验:仅允许清理 N 天前的数据(默认 180 天,sys_config: archive.protect.days)。
|
||||
func checkCleanupProtect(svcCtx *svc.ServiceContext, r *http.Request, end int64) error {
|
||||
days := logic.New(svcCtx).CfgInt(r.Context(), logic.CfgArchiveProtectDays, 180)
|
||||
if days <= 0 {
|
||||
return nil
|
||||
}
|
||||
cutoff := time.Now().Unix() - int64(days)*86400
|
||||
if end > cutoff {
|
||||
return fmt.Errorf("保护期内的数据禁止删除(保护期 %d 天):清理窗口须结束于 %s 及之前", days, time.Unix(cutoff, 0).Format("2006-01-02"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackupItemsHandler GET /api/v1/backup/items 可选数据项(质量 4 表不出现)
|
||||
func BackupItemsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -76,6 +91,10 @@ func CleanupStartHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := checkCleanupProtect(svcCtx, r, req.End); err != nil {
|
||||
httpx.Fail(w, 2613, err.Error())
|
||||
return
|
||||
}
|
||||
req.Operator = operator(r, "")
|
||||
jobID, err := svcCtx.Backup.StartCleanup(req)
|
||||
if err != nil {
|
||||
@@ -152,6 +171,10 @@ func CleanupPreviewHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Fail(w, 2609, "时间窗不合法")
|
||||
return
|
||||
}
|
||||
if err := checkCleanupProtect(svcCtx, r, req.End); err != nil {
|
||||
httpx.Fail(w, 2613, err.Error())
|
||||
return
|
||||
}
|
||||
if len(req.Items) == 0 {
|
||||
httpx.Fail(w, 2610, "请至少选择一个数据项")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user