forked from x/icebergs
opt team
This commit is contained in:
parent
012cce411a
commit
82dd8ddf77
@ -10,8 +10,9 @@ import (
|
||||
|
||||
const (
|
||||
ZONE = "zone"
|
||||
TASK = "task"
|
||||
PLAN = "plan"
|
||||
TASK = "task"
|
||||
MISS = "miss"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -25,9 +26,8 @@ func _task_list(m *ice.Message, zone string, id string, field ...interface{}) {
|
||||
m.Richs(TASK, nil, kit.Select("*", zone), func(key string, val map[string]interface{}) {
|
||||
if zone = kit.Format(kit.Value(val, "meta.zone")); id == "" {
|
||||
m.Grows(TASK, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
|
||||
m.Push(zone, value, []string{"begin_time"})
|
||||
m.Push("zone", zone)
|
||||
m.Push(zone, value, []string{"id", "status", "type", "name", "text"})
|
||||
m.Push(zone, value)
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -44,7 +44,8 @@ func _task_insert(m *ice.Message, zone, kind, name, text, begin_time, close_time
|
||||
m.Richs(TASK, nil, zone, func(key string, value map[string]interface{}) {
|
||||
id := m.Grow(TASK, kit.Keys("hash", key), kit.Dict(
|
||||
kit.MDB_TYPE, kind, kit.MDB_NAME, name, kit.MDB_TEXT, text,
|
||||
"begin_time", begin_time, "close_time", begin_time, "status", StatusPrepare,
|
||||
"begin_time", begin_time, "close_time", begin_time,
|
||||
"status", StatusPrepare, "level", 3, "score", 3,
|
||||
kit.MDB_EXTRA, kit.Dict(arg),
|
||||
))
|
||||
m.Log_INSERT("zone", zone, "id", id, "type", kind, "name", name)
|
||||
@ -83,13 +84,68 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
|
||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }},
|
||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save("task") }},
|
||||
|
||||
TASK: {Name: "task zone=auto id=auto auto", Help: "任务", Action: map[string]*ice.Action{
|
||||
"modify": {Name: "modify key value old", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, m.Option("zone"), m.Option("id"), arg[0], arg[1], arg[2])
|
||||
PLAN: {Name: "plan scale:select=day|week|month|year|long begin_time=@date end_time=@date auto", Help: "计划", Meta: kit.Dict(
|
||||
"display", "/plugin/local/team/miss.js", "detail", []string{"prepare", "process", "finish", "cancel"},
|
||||
), Action: map[string]*ice.Action{
|
||||
"insert": {Name: "insert zone type name text begin_time end_time", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Richs(TASK, nil, arg[0], nil) == nil {
|
||||
_task_create(m, arg[0])
|
||||
}
|
||||
_task_insert(m, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5])
|
||||
}},
|
||||
"delete": {Name: "delete key value", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_delete(m, m.Option("zone"), m.Option("id"))
|
||||
}},
|
||||
"modify": {Name: "modify key value old", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, m.Option("zone"), m.Option("id"), arg[0], arg[1], arg[2])
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
begin_time := time.Now()
|
||||
if len(arg) > 1 {
|
||||
begin_time, _ = time.ParseInLocation("2006-01-02 15:04:05", arg[1], time.Local)
|
||||
}
|
||||
end_time := begin_time
|
||||
|
||||
switch begin_time = begin_time.Add(-time.Duration(begin_time.UnixNano()) % (24 * time.Hour)); arg[0] {
|
||||
case "day":
|
||||
end_time = begin_time.AddDate(0, 0, 1)
|
||||
case "week":
|
||||
begin_time = begin_time.AddDate(0, 0, -int(begin_time.Weekday()))
|
||||
end_time = begin_time.AddDate(0, 0, 7)
|
||||
case "month":
|
||||
begin_time = begin_time.AddDate(0, 0, -begin_time.Day()+1)
|
||||
end_time = begin_time.AddDate(0, 1, 0)
|
||||
case "year":
|
||||
begin_time = begin_time.AddDate(0, 0, -begin_time.YearDay()+1)
|
||||
end_time = begin_time.AddDate(1, 0, 0)
|
||||
case "long":
|
||||
begin_time = begin_time.AddDate(0, 0, -begin_time.YearDay()+1)
|
||||
begin_time = begin_time.AddDate(-begin_time.Year()%5, 0, 0)
|
||||
end_time = begin_time.AddDate(5, 0, 0)
|
||||
}
|
||||
|
||||
begin_time = begin_time.Add(-8 * time.Hour)
|
||||
end_time = end_time.Add(-8 * time.Hour)
|
||||
m.Debug("begin: %v end: %v", begin_time, end_time)
|
||||
|
||||
m.Richs(TASK, nil, kit.Select("*", m.Option("zone")), func(key string, val map[string]interface{}) {
|
||||
zone := kit.Format(kit.Value(val, "meta.zone"))
|
||||
m.Grows(TASK, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
|
||||
begin, _ := time.ParseInLocation("2006-01-02 15:04:05", kit.Format(value["begin_time"]), time.Local)
|
||||
if begin_time.Before(begin) && begin.Before(end_time) {
|
||||
m.Push("zone", zone)
|
||||
m.Push(zone, value)
|
||||
}
|
||||
})
|
||||
})
|
||||
}},
|
||||
TASK: {Name: "task zone=auto id=auto auto", Help: "任务", Action: map[string]*ice.Action{
|
||||
"delete": {Name: "delete key value", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_delete(m, m.Option("zone"), m.Option("id"))
|
||||
}},
|
||||
"modify": {Name: "modify key value old", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, m.Option("zone"), m.Option("id"), arg[0], arg[1], arg[2])
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) < 3 {
|
||||
_task_list(m, kit.Select("", arg, 0), kit.Select("", arg, 1))
|
||||
@ -108,61 +164,8 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
|
||||
|
||||
_task_insert(m, arg[0], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7:]...)
|
||||
}},
|
||||
PLAN: {Name: "plan scale:select=day|week|month|year begin_time=@date end_time=@date auto", Help: "计划", Meta: kit.Dict(
|
||||
"display", "/plugin/local/team/miss.js", "detail", []string{"prepare", "process", "finish", "cancel"},
|
||||
), Action: map[string]*ice.Action{
|
||||
"insert": {Name: "insert begin_time type name text", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_insert(m, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5])
|
||||
}},
|
||||
"delete": {Name: "delete key value", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_delete(m, m.Option("zone"), m.Option("id"))
|
||||
}},
|
||||
"modify": {Name: "modify key value old", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
_task_modify(m, m.Option("zone"), m.Option("id"), arg[0], arg[1], arg[2])
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
begin_time := time.Now()
|
||||
if len(arg) > 1 {
|
||||
begin_time, _ = time.ParseInLocation("2006-01-02 15:04:05", arg[1], time.Local)
|
||||
}
|
||||
|
||||
end_time := begin_time
|
||||
if len(arg) > 2 {
|
||||
end_time, _ = time.ParseInLocation("2006-01-02 15:04:05", arg[2], time.Local)
|
||||
}
|
||||
|
||||
switch arg[0] {
|
||||
case "day":
|
||||
begin_time = begin_time.Add(-time.Duration(begin_time.UnixNano()) % (24 * time.Hour))
|
||||
end_time = begin_time.Add(24 * time.Hour)
|
||||
case "week":
|
||||
begin_time = begin_time.Add(-time.Duration(begin_time.UnixNano())%(24*time.Hour) - time.Duration(begin_time.Weekday())*24*time.Hour)
|
||||
end_time = begin_time.Add(7 * 24 * time.Hour)
|
||||
case "month":
|
||||
case "months":
|
||||
case "year":
|
||||
case "long":
|
||||
}
|
||||
|
||||
begin_time = begin_time.Add(-8 * time.Hour)
|
||||
end_time = end_time.Add(-8 * time.Hour)
|
||||
m.Debug("begin_time: %v %v", begin_time, end_time)
|
||||
|
||||
m.Richs(TASK, nil, kit.Select("*", m.Option("zone")), func(key string, val map[string]interface{}) {
|
||||
zone := kit.Format(kit.Value(val, "meta.zone"))
|
||||
m.Grows(TASK, kit.Keys("hash", key), "", "", func(index int, value map[string]interface{}) {
|
||||
begin, _ := time.ParseInLocation("2006-01-02 15:04:05", kit.Format(value["begin_time"]), time.Local)
|
||||
m.Debug("begin: %v", begin)
|
||||
|
||||
if begin_time.Before(begin) && begin.Before(end_time) {
|
||||
m.Push(zone, value, []string{"begin_time"})
|
||||
m.Push("zone", zone)
|
||||
m.Push(zone, value, []string{"id", "status", "type", "name", "text"})
|
||||
}
|
||||
})
|
||||
})
|
||||
MISS: {Name: "miss", Help: "miss", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}},
|
||||
"miss": {Name: "miss", Help: "miss"},
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user