1.增加按“时间”、“标题”、“企微状态”查询 2.增加数据统计在列表顶部 3.增加分页功能
This commit is contained in:
1 parent
0c471efb9f
commit
9d4092bc7f
14 files changed
+447
-108
No files matched your search
@@ -23,13 +23,13 @@ import (
|
||||
// trimSpace is a local strings.TrimSpace alias keeping call sites short.
|
||||
func trimSpace(raw string) string { return strings.TrimSpace(raw) }
|
||||
|
||||
// parseFlexibleTime accepts RFC3339 or "2006-01-02 15:04" / "2006-01-02".
|
||||
// parseFlexibleTime accepts RFC3339 or "2006-01-02 15:04:05" / "2006-01-02 15:04" / "2006-01-02".
|
||||
func parseFlexibleTime(raw string) *time.Time {
|
||||
raw = trimSpace(raw)
|
||||
if raw == "" {
|
||||
return nil
|
||||
}
|
||||
layouts := []string{time.RFC3339, "2006-01-02 15:04", "2006-01-02T15:04", "2006-01-02"}
|
||||
layouts := []string{time.RFC3339, "2006-01-02 15:04:05", "2006-01-02 15:04", "2006-01-02T15:04", "2006-01-02"}
|
||||
for _, layout := range layouts {
|
||||
if t, err := time.ParseInLocation(layout, raw, time.Local); err == nil {
|
||||
return &t
|
||||
@@ -835,8 +835,11 @@ func (h *Handler) RunWeeklyLecturerReminders(c *gin.Context) {
|
||||
}
|
||||
|
||||
// ListPushLogs GET /training/notifications/push-logs — 推送逐人明细(人事/课长):
|
||||
// 按场景集合(逗号分隔 scene 参数)与引用类型过滤,含收件人姓名/工号与企微
|
||||
// push_status(pending/sending/sent/skipped/dead;空=仅站内)。
|
||||
// 按时间范围(start_time/end_time,含 YYYY-MM-DD 与含时分秒格式)、标题模糊
|
||||
// (title)、企微状态(push_status:pending 含 sending/sent/skipped/dead/in_site,
|
||||
// 空=全部)、场景集合(逗号分隔 scenes)与引用类型(ref_type)过滤;
|
||||
// 返回当前页(items)、命中总数(total)与全量状态统计(stats,统计不受分页影响),
|
||||
// 含收件人姓名/工号与企微 push_status(空=仅站内)。
|
||||
func (h *Handler) ListPushLogs(c *gin.Context) {
|
||||
if !h.requireRoles(c, types.TrainingRoleHR, types.TrainingRoleSupervisor) {
|
||||
return
|
||||
@@ -849,12 +852,24 @@ func (h *Handler) ListPushLogs(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
limit, _ := strconv.Atoi(c.Query("limit"))
|
||||
items, err := h.svc.ListPushLogs(
|
||||
c.Request.Context(), callerTenantID(c), scenes, c.Query("ref_type"), limit)
|
||||
q := &types.TrainingPushLogQuery{
|
||||
Scenes: scenes,
|
||||
RefType: c.Query("ref_type"),
|
||||
Title: c.Query("title"),
|
||||
PushStatus: strings.TrimSpace(c.Query("push_status")),
|
||||
StartTime: parseFlexibleTime(c.Query("start_time")),
|
||||
EndTime: parseFlexibleTime(c.Query("end_time")),
|
||||
}
|
||||
if v, err := strconv.Atoi(c.Query("page")); err == nil {
|
||||
q.Page = v
|
||||
}
|
||||
if v, err := strconv.Atoi(c.Query("page_size")); err == nil {
|
||||
q.PageSize = v
|
||||
}
|
||||
page, err := h.svc.ListPushLogs(c.Request.Context(), callerTenantID(c), q)
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": items})
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": page})
|
||||
}
|
||||
Reference in new issue
Block a user