diff --git a/base/nfs/save.go b/base/nfs/save.go index e605a13d..d4fc52a8 100644 --- a/base/nfs/save.go +++ b/base/nfs/save.go @@ -7,6 +7,7 @@ import ( "path" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" ) @@ -209,3 +210,13 @@ func Pipe(m *ice.Message, cb ice.Any) io.WriteCloser { } return w } + +func Temp(m *ice.Message, cb func(p string)) { + p := path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ)) + defer os.Remove(p) + cb(p) +} + +var ImageResize = func(m *ice.Message, p string, height, width uint) bool { + return false +} diff --git a/base/web/cache.go b/base/web/cache.go index cdc3503d..77799964 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -131,10 +131,10 @@ func init() { }}, DOWNLOAD: {Name: "download type name*", Hand: func(m *ice.Message, arg ...string) { if res, ok := m.Optionv(RESPONSE).(*http.Response); !m.Warn(!ok, ice.ErrNotValid, RESPONSE) { - p := path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ)) - defer os.Remove(p) - file, size := _cache_catch(m, _cache_download(m, res, p, m.OptionCB(""))) - _cache_save(m, m.Option(mdb.TYPE), m.Option(mdb.NAME), "", file, size) + nfs.Temp(m, func(p string) { + file, size := _cache_catch(m, _cache_download(m, res, p, m.OptionCB(""))) + _cache_save(m, m.Option(mdb.TYPE), m.Option(mdb.NAME), "", file, size) + }) } }}, nfs.PS: {Hand: func(m *ice.Message, arg ...string) { @@ -228,5 +228,13 @@ func ExportCacheAction(field string) ice.Actions { value[field] = kit.Join(kit.Simple(kit.For(kit.Split(kit.Format(value[field])), func(p string) string { return kit.Select(p, list[p]) }))) }) }}, + UPLOAD: {Hand: func(m *ice.Message, arg ...string) { + nfs.Temp(m, func(p string) { + msg := m.Cmd(CACHE, Upload(m)[0]) + if os.Link(msg.Append(nfs.FILE), p); nfs.ImageResize(m, p, 390, 390) { + m.Echo(m.Cmd(CACHE, CATCH, p, msg.Append(mdb.TYPE)).Append(mdb.HASH)) + } + }) + }}, } } diff --git a/core/mall/goods.go b/core/mall/goods.go index 87d5857a..b10b458f 100644 --- a/core/mall/goods.go +++ b/core/mall/goods.go @@ -22,8 +22,7 @@ func init() { GOODS: {Help: "商品", Icon: "mall.png", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create zone* name* text price* count*=1 units*=件 image*=4@img"}, // mdb.MODIFY: {Name: "modify zone* name* text price* count*=1 units*=件 image*=4@img"}, - ORDER: {Name: "order count*=1", Help: "选购", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CART, mdb.INSERT, arg) }}, - web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { m.Echo(web.Upload(m)[0]) }}, + ORDER: {Name: "order count*=1", Help: "选购", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CART, mdb.INSERT, arg) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch mdb.HashInputs(m, arg); arg[0] { case "units": diff --git a/core/team/house.go b/core/team/house.go new file mode 100644 index 00000000..79e17055 --- /dev/null +++ b/core/team/house.go @@ -0,0 +1,31 @@ +package team + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" + "shylinux.com/x/icebergs/base/web" + "shylinux.com/x/icebergs/base/web/html" + kit "shylinux.com/x/toolkits" +) + +const HOUSE = "house" + +func init() { + const ( + AREA = "area" + ROOM = "room" + PRICE = "price" + BUILD = "build" + ) + Index.MergeCommands(ice.Commands{ + HOUSE: {Help: "房子", Meta: kit.Dict(ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict( + mdb.ZONE, "区域", mdb.NAME, "小区", AREA, "面积", ROOM, "户型", PRICE, "总价", BUILD, "建成时间", + ))), Actions: ice.MergeActions(ice.Actions{ + mdb.CREATE: {Name: "create zone* type* price* area* room* name* build text link image=9@img"}, + }, web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(mdb.FIELD, "time,hash,zone,type,price,area,room,name,build,text,link,image", mdb.SORT, "zone,name")), Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelect(m, arg...) + web.PushPodCmd(m, "", arg...) + }}, + }) +}