feat:多项功能优化
This commit is contained in:
@@ -81,16 +81,29 @@ func ListAlertRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ListAlertsHandler GET /alerts?status= 预警消息收件箱
|
||||
// ListAlertsHandler GET /alerts?status=&type=&from=&to=&page=&pageSize=
|
||||
// 预警消息收件箱:支持 状态/类型/时间范围(YYYY-MM-DD) 筛选;带 page 返回分页对象,否则返回全量数组(顶部铃铛未读数复用)。
|
||||
func ListAlertsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
status := r.URL.Query().Get("status")
|
||||
data, err := logic.New(svcCtx).ListAlerts(r.Context(), status)
|
||||
q := r.URL.Query()
|
||||
query := logic.AlertQuery{
|
||||
Status: q.Get("status"),
|
||||
Type: q.Get("type"),
|
||||
From: q.Get("from"),
|
||||
To: q.Get("to"),
|
||||
Page: atoiDefault(q.Get("page"), 0),
|
||||
PageSize: atoiDefault(q.Get("pageSize"), 20),
|
||||
}
|
||||
list, total, err := logic.New(svcCtx).ListAlerts(r.Context(), query)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3305, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
if query.Page > 0 {
|
||||
httpx.Ok(w, map[string]any{"list": list, "total": total, "page": query.Page, "pageSize": query.PageSize})
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ func ExportProductTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+url.PathEscape("产品型号.xlsx"))
|
||||
w.Header().Set("Content-Disposition", "attachment; filename*=UTF-8''"+url.PathEscape("物料档案.xlsx"))
|
||||
_, _ = w.Write(b)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user