Commit 9f3d744b by 朱继来

temp

parent 0f3776a9
......@@ -11,7 +11,7 @@ require (
github.com/golang/snappy v0.0.1 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75
github.com/mongodb/mongo-go-driver v1.2.0
github.com/mongodb/mongo-go-driver v1.2.1
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.2.0
......
......@@ -36,6 +36,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mongodb/mongo-go-driver v1.2.0 h1:0/Qg6sZ+mVjB1C1IPFhAyRNvuT8WOIpZaQJOu/AnS6A=
github.com/mongodb/mongo-go-driver v1.2.0/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU=
github.com/mongodb/mongo-go-driver v1.2.1 h1:QtCZFfMl2khU0kUNih0H1i0gxq9OO29JTTCLh3pI/Z8=
github.com/mongodb/mongo-go-driver v1.2.1/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
......
......@@ -34,6 +34,7 @@ func handleJobSave(resp http.ResponseWriter, req *http.Request) {
if err = req.ParseForm(); err != nil {
goto ERR
}
// 2, 取表单中的job字段
postJob = req.PostForm.Get("job")
// 3, 反序列化job
......@@ -51,7 +52,7 @@ func handleJobSave(resp http.ResponseWriter, req *http.Request) {
return
ERR:
// 6, 返回异常应答
if bytes, err = common.BuildResponse(-1, err.Error(), nil); err == nil {
if bytes, err = common.BuildResponse(-1, req.PostForm.Get("job_name"), nil); err == nil {
resp.Write(bytes)
}
}
......
......@@ -39,38 +39,38 @@ func InitLogMgr() (err error) {
// 查看任务日志
func (logMgr *LogMgr) ListLog(name string, skip int, limit int) (logArr []*common.JobLog, err error){
var (
filter *common.JobLogFilter
logSort *common.SortLogByStartTime
cursor mongo.Cursor
jobLog *common.JobLog
)
// len(logArr)
logArr = make([]*common.JobLog, 0)
// 过滤条件
filter = &common.JobLogFilter{JobName: name}
// 按照任务开始时间倒排
logSort = &common.SortLogByStartTime{SortOrder: -1}
//var (
// filter *common.JobLogFilter
// logSort *common.SortLogByStartTime
// cursor mongo.Cursor
// jobLog *common.JobLog
//)
//
//// len(logArr)
//logArr = make([]*common.JobLog, 0)
//
//// 过滤条件
//filter = &common.JobLogFilter{JobName: name}
//
//// 按照任务开始时间倒排
//logSort = &common.SortLogByStartTime{SortOrder: -1}
// 查询
if cursor, err = logMgr.logCollection.Find(context.TODO(), filter, findopt.Sort(logSort), findopt.Skip(int64(skip)), findopt.Limit(int64(limit))); err != nil {
return
}
//if cursor, err = logMgr.logCollection.Find(context.TODO(), filter, findopt.Sort(logSort), findopt.Skip(int64(skip)), findopt.Limit(int64(limit))); err != nil {
// return
//}
// 延迟释放游标
defer cursor.Close(context.TODO())
for cursor.Next(context.TODO()) {
jobLog = &common.JobLog{}
// 反序列化BSON
if err = cursor.Decode(jobLog); err != nil {
continue // 有日志不合法
}
logArr = append(logArr, jobLog)
}
//defer cursor.Close(context.TODO())
//
//for cursor.Next(context.TODO()) {
// jobLog = &common.JobLog{}
//
// // 反序列化BSON
// if err = cursor.Decode(jobLog); err != nil {
// continue // 有日志不合法
// }
//
// logArr = append(logArr, jobLog)
//}
return
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment