feat: 增加商品目录导入记录 (#134)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"cmautobuy/admin/service"
|
||||
)
|
||||
|
||||
func (h *Handler) CatalogHistory(c *gin.Context) {
|
||||
result, err := service.ListCatalogHistory(h.db, c.Query("source"), c.Query("status"), service.ParsePage(c.Query("page")))
|
||||
if err != nil {
|
||||
fail(c, 500, "读取商品目录导入记录失败,数据没有被改动。请刷新后重试。")
|
||||
return
|
||||
}
|
||||
values := url.Values{}
|
||||
if result.Source != "" {
|
||||
values.Set("source", result.Source)
|
||||
}
|
||||
if result.Status != "" {
|
||||
values.Set("status", result.Status)
|
||||
}
|
||||
c.HTML(http.StatusOK, "catalog/list", page(c, "catalog", "商品目录导入记录", gin.H{"Rows": result.Rows, "Sources": result.Sources, "Source": result.Source, "StatusFilter": result.Status, "StatusOptions": service.CatalogStatusOptions(), "Status": fmt.Sprintf("共 %d 条 · 第 %d/%d 页", result.Total, result.Page, result.TotalPages), "Pagination": service.NewPaginationView(result.Page, result.TotalPages, values.Encode())}))
|
||||
}
|
||||
|
||||
func (h *Handler) CatalogHistoryDetail(c *gin.Context) {
|
||||
view, err := service.GetCatalogRunView(h.db, c.Query("source"), c.Query("batch_id"))
|
||||
if err != nil {
|
||||
fail(c, 500, "读取导入批次详情失败。")
|
||||
return
|
||||
}
|
||||
if view == nil {
|
||||
fail(c, 404, "导入批次不存在,请刷新页面。")
|
||||
return
|
||||
}
|
||||
c.HTML(200, "catalog/detail_modal", gin.H{"Run": view})
|
||||
}
|
||||
@@ -102,6 +102,11 @@ func Register(r *gin.Engine, db *sql.DB, onlineThreshold time.Duration) {
|
||||
users.POST("/create", h.UserCreate)
|
||||
users.POST("/status", h.UserSetStatus)
|
||||
users.POST("/reset-password", h.UserResetPassword)
|
||||
|
||||
// 7. 第三方商品目录导入记录:系统级审计仅管理员可见。
|
||||
integrations := pages.Group("/integrations", AdminRequired())
|
||||
integrations.GET("/catalog", h.CatalogHistory)
|
||||
integrations.GET("/catalog/detail", h.CatalogHistoryDetail)
|
||||
}
|
||||
|
||||
// page 组装每个页面都要的公共数据(导航高亮、标题、CSRF token)。
|
||||
|
||||
Reference in New Issue
Block a user