|
@@ -4,10 +4,11 @@ import (
|
|
|
"fmt"
|
|
|
qu "qfw/util"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
u "util"
|
|
|
)
|
|
|
|
|
|
-func (f *Front) SupplementList() {
|
|
|
+func (f *Front) SupplementDayList() {
|
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
|
if auth != u.Role_Admin {
|
|
|
f.ServeJson("没有权限!")
|
|
@@ -25,6 +26,7 @@ func (f *Front) SupplementList() {
|
|
|
"$gte": starttime,
|
|
|
"$lte": starttime + 12*3600,
|
|
|
},
|
|
|
+ "stype": "day",
|
|
|
}
|
|
|
if search != "" {
|
|
|
query["$or"] = []interface{}{
|
|
@@ -40,11 +42,68 @@ func (f *Front) SupplementList() {
|
|
|
orderType = -1
|
|
|
}
|
|
|
sort = fmt.Sprintf(sort, orderName, orderType)
|
|
|
- qu.Debug("supplement query:", query)
|
|
|
+ qu.Debug("supplement day query:", query)
|
|
|
count := u.MgoS.Count("spider_supplement", query)
|
|
|
list, _ := u.MgoS.Find("spider_supplement", query, sort, nil, false, start, limit)
|
|
|
f.ServeJson(map[string]interface{}{"draw": draw, "data": list, "recordsFiltered": count, "recordsTotal": count})
|
|
|
} else {
|
|
|
- f.Render("supplement.html", &f.T)
|
|
|
+ f.Render("supplement_day.html", &f.T)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func (f *Front) SupplementWeekList() {
|
|
|
+ auth := qu.IntAll(f.GetSession("auth"))
|
|
|
+ if auth != u.Role_Admin {
|
|
|
+ f.ServeJson("没有权限!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if f.Method() == "POST" {
|
|
|
+ start, _ := f.GetInteger("start")
|
|
|
+ limit, _ := f.GetInteger("length")
|
|
|
+ draw, _ := f.GetInteger("draw")
|
|
|
+ searchStr := f.GetString("search[value]") //搜索内容
|
|
|
+ search := strings.TrimSpace(searchStr)
|
|
|
+ starttime, _ := f.GetInt("starttime") //当天凌晨时间
|
|
|
+ starttime = getMondayInt64(starttime)
|
|
|
+ query := map[string]interface{}{
|
|
|
+ "comeintime": map[string]interface{}{
|
|
|
+ "$gte": starttime,
|
|
|
+ "$lte": starttime + 12*3600,
|
|
|
+ },
|
|
|
+ "stype": "week",
|
|
|
+ }
|
|
|
+ if search != "" {
|
|
|
+ query["$or"] = []interface{}{
|
|
|
+ map[string]interface{}{"spidercode": map[string]interface{}{"$regex": search}},
|
|
|
+ map[string]interface{}{"channel": map[string]interface{}{"$regex": search}},
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sort := `{"%s":%d}`
|
|
|
+ orderIndex := f.GetString("order[0][column]")
|
|
|
+ orderName := f.GetString(fmt.Sprintf("columns[%s][data]", orderIndex))
|
|
|
+ orderType := 1
|
|
|
+ if f.GetString("order[0][dir]") != "asc" {
|
|
|
+ orderType = -1
|
|
|
+ }
|
|
|
+ sort = fmt.Sprintf(sort, orderName, orderType)
|
|
|
+ qu.Debug("supplement week query:", query)
|
|
|
+ count := u.MgoS.Count("spider_supplement", query)
|
|
|
+ list, _ := u.MgoS.Find("spider_supplement", query, sort, nil, false, start, limit)
|
|
|
+ f.ServeJson(map[string]interface{}{"draw": draw, "data": list, "recordsFiltered": count, "recordsTotal": count})
|
|
|
+ } else {
|
|
|
+ f.Render("supplement_week.html", &f.T)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func getMondayInt64(t int64) int64 {
|
|
|
+ // 获取当前时间的星期几
|
|
|
+ currentTime := time.Unix(t, 0)
|
|
|
+ weekday := int(currentTime.Weekday())
|
|
|
+ // 计算今天距离周一的天数差
|
|
|
+ daysSinceMonday := (weekday + 6) % 7
|
|
|
+ // 计算本周一的时间戳
|
|
|
+ nowTime := currentTime.AddDate(0, 0, -daysSinceMonday)
|
|
|
+ timeStr := qu.FormatDate(&nowTime, qu.Date_Short_Layout)
|
|
|
+ result, _ := time.ParseInLocation(qu.Date_Short_Layout, timeStr, time.Local)
|
|
|
+ return result.Unix()
|
|
|
+}
|