42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"cmautobuy/admin/service"
|
|
)
|
|
|
|
func (h *Handler) CatalogHistory(c *gin.Context) {
|
|
pageSize := service.ParsePageSize(c.Query("page_size"))
|
|
result, err := service.ListCatalogHistoryWithPageSize(h.db, c.Query("source"), c.Query("status"), service.ParsePage(c.Query("page")), pageSize)
|
|
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), "CurrentPageSize": pageSize, "Pagination": service.NewPaginationView(result.Page, pageSize, 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})
|
|
}
|