1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-11-16 21:35:40 +08:00
parent 4d34d67ddd
commit 61828d28f5
4 changed files with 55 additions and 6 deletions

View File

@ -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
}

View File

@ -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))
}
})
}},
}
}

View File

@ -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":

31
core/team/house.go Normal file
View File

@ -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...)
}},
})
}