mirror of
https://shylinux.com/x/community
synced 2025-04-25 17:48:06 +08:00
add some
This commit is contained in:
parent
97b422fa01
commit
fe1bc4bc60
@ -11,21 +11,18 @@ type apply struct {
|
|||||||
Table
|
Table
|
||||||
user user
|
user user
|
||||||
userPlace userPlace
|
userPlace userPlace
|
||||||
place place
|
|
||||||
street street
|
street street
|
||||||
|
city city
|
||||||
|
place place
|
||||||
event event
|
event event
|
||||||
portal string `data:"true"`
|
portal string `data:"true"`
|
||||||
create string `name:"create place_uid*:select user_place_role*:select begin_time:select@date end_time:select@date" role:"void"`
|
create string `name:"create place_uid* user_place_role*:select begin_time:select@date end_time:select@date" role:"void"`
|
||||||
cancel string `name:"cancel" role:"void"`
|
cancel string `name:"cancel" role:"void"`
|
||||||
submit string `name:"submit" role:"void"`
|
submit string `name:"submit" role:"void"`
|
||||||
list string `name:"list place_uid uid auto" role:"void"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s apply) Inputs(m *ice.Message, arg ...string) {
|
func (s apply) Inputs(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case model.PLACE_UID:
|
|
||||||
m.Cmdy(s.userPlace, m.Option(model.USER_UID))
|
|
||||||
m.Cut(model.PLACE_UID, model.PLACE_NAME).DisplayInputKeyNameIconTitle()
|
|
||||||
case model.USER_PLACE_ROLE:
|
case model.USER_PLACE_ROLE:
|
||||||
for k, v := range UserPlaceRoleList {
|
for k, v := range UserPlaceRoleList {
|
||||||
if k != UserPlaceCreator && k != UserPlaceVisitor {
|
if k != UserPlaceCreator && k != UserPlaceVisitor {
|
||||||
@ -47,33 +44,49 @@ func (s apply) Cancel(m *ice.Message, arg ...string) {
|
|||||||
s.SendTemplate(m, msg.Append(model.USER_UID), "场所权限申请 已取消")
|
s.SendTemplate(m, msg.Append(model.USER_UID), "场所权限申请 已取消")
|
||||||
}
|
}
|
||||||
func (s apply) Submit(m *ice.Message, arg ...string) {
|
func (s apply) Submit(m *ice.Message, arg ...string) {
|
||||||
|
msg := s.status(m, ApplyCreate, ApplySubmit)
|
||||||
|
if m.WarnNotValid(msg.IsErr()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
defer s.event.Record(m, m.Option(model.UID))
|
defer s.event.Record(m, m.Option(model.UID))
|
||||||
defer m.ToastProcess()()
|
defer m.ToastProcess()()
|
||||||
role := UserPlaceCreator
|
role := UserPlaceCreator
|
||||||
switch UserPlaceRole(kit.Int(s.status(m, ApplyCreate, ApplySubmit).Append(model.ROLE))) {
|
switch UserPlaceRole(kit.Int(msg.Append(model.ROLE))) {
|
||||||
case UserPlaceLandlord:
|
case UserPlaceLandlord:
|
||||||
role = UserPlaceCreator
|
role = UserPlaceCreator
|
||||||
case UserPlaceTenant, UserPlaceAdmin:
|
case UserPlaceTenant, UserPlaceAdmin:
|
||||||
role = UserPlaceLandlord
|
role = UserPlaceLandlord
|
||||||
}
|
}
|
||||||
msg := m.Cmd(s.userPlace, s.userPlace.Select, m.OptionSimple(model.PLACE_UID), model.ROLE, role.String())
|
msg = m.Cmd(s.userPlace, s.userPlace.Select, m.OptionSimple(model.PLACE_UID), model.ROLE, role.String())
|
||||||
|
if m.WarnNotFound(msg.Length() == 0, role.String()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
m.Cmd(order{}, order{}.Create, msg.AppendSimple(model.USER_UID), model.APPLY_UID, m.Option(model.UID), model.STATUS, OrderCreate)
|
m.Cmd(order{}, order{}.Create, msg.AppendSimple(model.USER_UID), model.APPLY_UID, m.Option(model.UID), model.STATUS, OrderCreate)
|
||||||
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限申请 已提交 🕑")
|
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限申请 已提交")
|
||||||
|
}
|
||||||
|
func (s apply) Reject(m *ice.Message, arg ...string) {
|
||||||
|
msg := s.status(m, ApplySubmit, ApplyRejected)
|
||||||
|
s.SendTemplate(m, msg.Append(model.USER_UID), "场所权限申请 已驳回 ❌")
|
||||||
|
}
|
||||||
|
func (s apply) Approve(m *ice.Message, arg ...string) {
|
||||||
|
msg := s.status(m, ApplySubmit, ApplyApproved)
|
||||||
|
s.SendTemplate(m, msg.Append(model.USER_UID), "场所权限申请 已通过 ✅")
|
||||||
|
m.Cmd(s.userPlace, s.userPlace.Create, msg.AppendSimple(model.USER_UID, model.PLACE_UID, model.ROLE))
|
||||||
}
|
}
|
||||||
func (s apply) List(m *ice.Message, arg ...string) {
|
func (s apply) List(m *ice.Message, arg ...string) {
|
||||||
s.Tables(m, s.place, s.street).Fields(m, "applies.created_at",
|
s.Tables(m, s.user, s.place, s.street, s.city).Fields(m, s.Key(s, model.CREATED_AT), s.Key(s, model.ID),
|
||||||
model.PLACE_NAME, model.PLACE_TYPE, "applies.role AS user_place_role", model.APPLY_STATUS,
|
model.USER_NAME, model.USER_AVATAR,
|
||||||
model.STREET_NAME, model.PLACE_ADDRESS, "applies.uid", model.PLACE_UID, model.STREET_UID,
|
model.PLACE_NAME, model.PLACE_TYPE, s.AS(s.Key(s, model.ROLE), model.USER_PLACE_ROLE), model.APPLY_STATUS,
|
||||||
|
model.CITY_NAME, model.STREET_NAME, model.PLACE_ADDRESS,
|
||||||
model.BEGIN_TIME, model.END_TIME,
|
model.BEGIN_TIME, model.END_TIME,
|
||||||
).Orders(m, "created_at DESC")
|
s.Key(s, model.UID), model.PLACE_UID,
|
||||||
|
).Orders(m, s.Desc(model.CREATED_AT))
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
if m.IsTech() {
|
if m.IsTech() {
|
||||||
s.Table.Select(m)
|
s.Table.Select(m)
|
||||||
} else {
|
|
||||||
s.Table.Select(m, m.OptionSimple(model.USER_UID)...)
|
|
||||||
}
|
}
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
if s.Table.Select(m, model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, arg[0]).Action(s.Create); m.Length() == 0 {
|
if s.Table.Select(m, model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, arg[0]); m.Length() == 0 {
|
||||||
m.EchoInfoButton(m.Trans("please create apply", "请创建权限申请"), s.Create)
|
m.EchoInfoButton(m.Trans("please create apply", "请创建权限申请"), s.Create)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -85,7 +98,7 @@ func (s apply) List(m *ice.Message, arg ...string) {
|
|||||||
ApplyCancel.String(),
|
ApplyCancel.String(),
|
||||||
}, ice.STR_R)
|
}, ice.STR_R)
|
||||||
} else {
|
} else {
|
||||||
s.Table.Select(m.FieldsSetDetail(), "applies.uid", arg[1])
|
s.Table.Select(m.FieldsSetDetail(), s.Key(s, model.UID), arg[1])
|
||||||
if ApplyStatus(kit.Int(m.Append(model.APPLY_STATUS))) == ApplySubmit {
|
if ApplyStatus(kit.Int(m.Append(model.APPLY_STATUS))) == ApplySubmit {
|
||||||
m.EchoQRCode(cmdurl(m, arg[0], m.Prefix("order"), arg[1]))
|
m.EchoQRCode(cmdurl(m, arg[0], m.Prefix("order"), arg[1]))
|
||||||
}
|
}
|
||||||
@ -101,17 +114,8 @@ func (s apply) List(m *ice.Message, arg ...string) {
|
|||||||
s.RewriteAppend(m).Display("").DisplayCSS("")
|
s.RewriteAppend(m).Display("").DisplayCSS("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), apply{}) }
|
func init() { ice.TeamCtxCmd(apply{}) }
|
||||||
|
|
||||||
func (s apply) Reject(m *ice.Message, arg ...string) {
|
|
||||||
msg := s.status(m, ApplySubmit, ApplyRejected)
|
|
||||||
s.SendTemplate(m, msg.Append(model.USER_UID), "场所权限申请 已驳回 ❌")
|
|
||||||
}
|
|
||||||
func (s apply) Approve(m *ice.Message, arg ...string) {
|
|
||||||
msg := s.status(m, ApplySubmit, ApplyApproved)
|
|
||||||
s.SendTemplate(m, msg.Append(model.USER_UID), "场所权限申请 已通过 ✅")
|
|
||||||
m.Cmd(s.userPlace, s.userPlace.Create, msg.AppendSimple(model.USER_UID, model.PLACE_UID, model.ROLE))
|
|
||||||
}
|
|
||||||
func (s apply) status(m *ice.Message, from, todo ApplyStatus, arg ...string) *ice.Message {
|
func (s apply) status(m *ice.Message, from, todo ApplyStatus, arg ...string) *ice.Message {
|
||||||
msg := s.Table.Select(m.Spawn(), m.OptionSimple(model.UID)...)
|
msg := s.Table.Select(m.Spawn(), m.OptionSimple(model.UID)...)
|
||||||
if !m.WarnNotFound(msg.Length() == 0, m.Option(model.UID)) {
|
if !m.WarnNotFound(msg.Length() == 0, m.Option(model.UID)) {
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
Volcanos(chat.ONIMPORT, {
|
Volcanos(chat.ONIMPORT, {
|
||||||
_init: function(can, msg) { if (msg.IsDetail()) { return msg.Dump(can) }
|
_init: function(can, msg) { if (msg.IsDetail()) { return msg.Dump(can) }
|
||||||
can.page.Append(can, can._output, msg.Table(function(value) {
|
can.page.Append(can, can._output, msg.Table(function(value) { value._style = [value.place_type, value.user_place_role, value.apply_status]
|
||||||
value._style = [value.place_type, value.user_place_role, value.apply_status]
|
|
||||||
return can.onimport.itemcard(can, value, [
|
return can.onimport.itemcard(can, value, [
|
||||||
{view: html.TITLE, list: [{text: value.place_name},
|
{view: html.TITLE, list: [{text: value.place_name},
|
||||||
{text: [can.user.transValue(can, value, "place_type"), "", mdb.TYPE]},
|
{text: [can.user.transValue(can, value, "place_type"), "", mdb.TYPE]},
|
||||||
{text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
{text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
||||||
{text: [can.user.transValue(can, value, "apply_status"), "", mdb.STATUS]},
|
{text: [can.user.transValue(can, value, "apply_status"), "", mdb.STATUS]},
|
||||||
]},
|
]},
|
||||||
{view: html.STATUS, list: [{text: value.street_name}, {text: value.place_address}]},
|
|
||||||
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
||||||
{view: html.STATUS, list: [{text: value.begin_time.split(" ")[0]}, {text: value.end_time.split(" ")[0]}]},
|
{view: html.STATUS, list: [{text: value.begin_time.split(" ")[0]}, {text: value.end_time.split(" ")[0]}]},
|
||||||
], function() { can.Option("uid", value.uid), can.Update() })
|
{view: html.STATUS, list: [{text: value.city_name}, {text: value.street_name}, {text: value.place_address}]},
|
||||||
|
])
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
})
|
})
|
24
src/gonganxitong/city.go
Normal file
24
src/gonganxitong/city.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package gonganxitong
|
||||||
|
|
||||||
|
import (
|
||||||
|
"shylinux.com/x/ice"
|
||||||
|
|
||||||
|
"shylinux.com/x/community/src/gonganxitong/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type city struct{ Table }
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(city{}) }
|
||||||
|
|
||||||
|
func (s city) FindOrCreateByName(m *ice.Message, arg ...string) {
|
||||||
|
if msg := m.Cmd(s, s.Select, model.NAME, arg[1]); msg.Length() == 0 {
|
||||||
|
msg := m.Cmd(s, s.Create, model.NAME, arg[1])
|
||||||
|
arg[0], arg[1] = model.CITY_UID, msg.Result()
|
||||||
|
} else {
|
||||||
|
arg[0], arg[1] = model.CITY_UID, msg.Append(model.UID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type City struct{ city }
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(City{}) }
|
@ -11,15 +11,16 @@ import (
|
|||||||
|
|
||||||
type Table struct {
|
type Table struct {
|
||||||
db.Table
|
db.Table
|
||||||
list string `name:"list place_uid uid auto"`
|
inputs string `name:"inputs" role:"void"`
|
||||||
|
list string `name:"list place_uid uid auto" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
|
||||||
s.Table.Inputs(m, arg...)
|
|
||||||
}
|
|
||||||
func (s Table) Init(m *ice.Message, arg ...string) {
|
func (s Table) Init(m *ice.Message, arg ...string) {
|
||||||
kit.If(m.Config(web.PORTAL) == ice.TRUE, func() { portal{}.Show(m) })
|
kit.If(m.Config(web.PORTAL) == ice.TRUE, func() { portal{}.Show(m) })
|
||||||
}
|
}
|
||||||
|
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
||||||
|
s.Table.Inputs(m, arg...)
|
||||||
|
}
|
||||||
func (s Table) List(m *ice.Message, arg ...string) *ice.Message {
|
func (s Table) List(m *ice.Message, arg ...string) *ice.Message {
|
||||||
if len(arg) == 0 || len(arg) == 1 {
|
if len(arg) == 0 || len(arg) == 1 {
|
||||||
if m.IsTech() {
|
if m.IsTech() {
|
||||||
@ -47,8 +48,6 @@ func (s Table) SendTemplate(m *ice.Message, user_uid, title string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func cmdurl(m *ice.Message, arg ...string) string {
|
func cmdurl(m *ice.Message, arg ...string) string {
|
||||||
return m.MergePodCmd("", m.Prefix(web.PORTAL), ice.MSG_DEBUG, m.Option(ice.MSG_DEBUG)) +
|
return m.MergePodCmd("", m.Prefix(web.PORTAL)) + "?debug=true" +
|
||||||
"#" + kit.Join([]string{arg[0], kit.Select(m.PrefixKey(), arg, 1), kit.Select("", arg, 2)}, ":")
|
"#" + kit.Join([]string{arg[0], kit.Select(m.PrefixKey(), arg, 1), kit.Select("", arg, 2)}, ":")
|
||||||
}
|
}
|
||||||
|
|
||||||
func prefixKey() string { return kit.Keys("web.team", kit.PathName(-1), kit.FileName(-1)) }
|
|
||||||
|
@ -14,37 +14,40 @@ import (
|
|||||||
type email struct {
|
type email struct {
|
||||||
user user
|
user user
|
||||||
portal portal
|
portal portal
|
||||||
Creds emails.Creds
|
creds emails.Creds
|
||||||
apply string `name:"apply username* password*"`
|
apply string `name:"apply username* password*" role:"void"`
|
||||||
reset string `name:"reset password*" help:"重置密码"`
|
reset string `name:"reset password*" help:"重置密码" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s email) Init(m *ice.Message, arg ...string) {
|
func (s email) Init(m *ice.Message, arg ...string) {
|
||||||
s.portal.Show(m)
|
s.portal.Show(m)
|
||||||
}
|
}
|
||||||
func (s email) List(m *ice.Message, arg ...string) {
|
|
||||||
if msg := m.Cmd(s.user, s.user.Select, model.UID, m.Option(model.USER_UID)); len(msg.Append(model.EMAIL)) < 10 {
|
|
||||||
m.EchoInfoButton(m.Trans("please apply email", "请申请邮箱"), s.Apply)
|
|
||||||
} else {
|
|
||||||
m.EchoInfoButton(msg.Append(model.EMAIL), s.Reset)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (s email) Apply(m *ice.Message, arg ...string) {
|
func (s email) Apply(m *ice.Message, arg ...string) {
|
||||||
|
defer m.ToastProcess()()
|
||||||
msg := m.Cmd(s.user, s.user.Select, model.UID, m.Option(model.USER_UID))
|
msg := m.Cmd(s.user, s.user.Select, model.UID, m.Option(model.USER_UID))
|
||||||
if m.Warn(msg.Append(model.EMAIL) != "", m.Trans("email already exists", "邮箱已存在")) {
|
if m.Warn(msg.Append(model.EMAIL) != "", m.Trans("email already exists", "邮箱已存在")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !strings.Contains(m.Option(aaa.USERNAME), "@") {
|
if !strings.Contains(m.Option(aaa.USERNAME), "@") {
|
||||||
m.Option(aaa.USERNAME, m.Option(aaa.USERNAME)+"@"+m.UserWeb().Hostname())
|
m.Option(aaa.USERNAME, m.Option(aaa.USERNAME)+"@"+strings.Split(m.UserHost(), "://")[1])
|
||||||
}
|
}
|
||||||
m.Cmdy(s.Creds, s.Creds.Create, m.Option(aaa.USERNAME), m.Option(aaa.PASSWORD))
|
m.Cmdy(s.creds, s.creds.Create, m.Option(aaa.USERNAME), m.Option(aaa.PASSWORD))
|
||||||
kit.If(!m.IsErr(), func() { m.Cmdy(s.user, s.user.Email, m.Option(aaa.USERNAME)) })
|
kit.If(!m.IsErr(), func() { m.Cmdy(s.user, s.user.Email, m.Option(aaa.USERNAME)) })
|
||||||
kit.If(!m.IsErr(), func() { m.ToastSuccess() })
|
|
||||||
}
|
}
|
||||||
func (s email) Reset(m *ice.Message, arg ...string) {
|
func (s email) Reset(m *ice.Message, arg ...string) {
|
||||||
|
defer m.ToastProcess()()
|
||||||
msg := m.Cmd(s.user, s.user.Select, model.UID, m.Option(model.USER_UID))
|
msg := m.Cmd(s.user, s.user.Select, model.UID, m.Option(model.USER_UID))
|
||||||
m.Cmdy(s.Creds, s.Creds.Password, msg.Append(model.EMAIL), m.Option(aaa.PASSWORD))
|
if m.WarnNotFound(msg.Append(model.EMAIL) == "", model.EMAIL) {
|
||||||
kit.If(!m.IsErr(), func() { m.ToastSuccess() })
|
return
|
||||||
|
}
|
||||||
|
m.Cmdy(s.creds, s.creds.Password, msg.Append(model.EMAIL), m.Option(aaa.PASSWORD))
|
||||||
|
}
|
||||||
|
func (s email) List(m *ice.Message, arg ...string) {
|
||||||
|
if msg := m.Cmd(s.user, s.user.Select, model.UID, m.Option(model.USER_UID)); msg.Append(model.EMAIL) == "" {
|
||||||
|
m.EchoInfoButton(m.Trans("please apply email", "请申请邮箱"), s.Apply)
|
||||||
|
} else {
|
||||||
|
m.EchoInfoButton(msg.Append(model.EMAIL), s.Reset)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), email{}) }
|
func init() { ice.TeamCtxCmd(email{}) }
|
||||||
|
@ -16,13 +16,24 @@ type event struct {
|
|||||||
|
|
||||||
func (s event) List(m *ice.Message, arg ...string) {
|
func (s event) List(m *ice.Message, arg ...string) {
|
||||||
s.Tables(m, s.user).Fields(m,
|
s.Tables(m, s.user).Fields(m,
|
||||||
"events.created_at", "events.uid",
|
s.Key(s, model.CREATED_AT), s.Key(s, model.ID),
|
||||||
"index", "operate", "args",
|
model.USER_AVATAR, model.USER_NAME,
|
||||||
"users.avatar AS icons", "user_name", "user_uid",
|
ctx.INDEX, model.OPERATE, ctx.ARGS, model.INFO,
|
||||||
).Orders(m, "created_at DESC").Select(m).Display("")
|
s.Key(s, model.UID), model.USER_UID,
|
||||||
|
).Orders(m, s.Desc(model.CREATED_AT))
|
||||||
|
if len(arg) == 0 {
|
||||||
|
if m.IsTech() {
|
||||||
|
s.Select(m)
|
||||||
|
}
|
||||||
|
} else if len(arg) == 1 {
|
||||||
|
s.Select(m, model.PLACE_UID, arg[0])
|
||||||
|
} else {
|
||||||
|
s.Select(m.FieldsSetDetail(), s.Key(s, model.UID), arg[1])
|
||||||
|
}
|
||||||
|
m.Display("")
|
||||||
}
|
}
|
||||||
func init() { ice.Cmd(prefixKey(), event{}) }
|
func init() { ice.TeamCtxCmd(event{}) }
|
||||||
|
|
||||||
func (s event) Record(m *ice.Message, arg ...string) {
|
func (s event) Record(m *ice.Message, info string, arg ...string) {
|
||||||
m.Cmd(s, s.Create, m.OptionSimple(model.USER_UID, model.PLACE_UID), ctx.INDEX, m.PrefixKey(), "operate", m.ActionKey(), ctx.ARGS, kit.Join(arg, ","))
|
m.Cmd(s, s.Create, m.OptionSimple(model.USER_UID, model.PLACE_UID), model.INFO, info, ctx.INDEX, m.PrefixKey(), model.OPERATE, m.ActionKey(), ctx.ARGS, kit.Join(arg, ","))
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
||||||
{view: html.STATUS, list: [{text: value.index}, {text: value.operate}]},
|
{view: html.STATUS, list: [{text: value.index}, {text: value.operate}]},
|
||||||
{view: html.STATUS, list: [{text: value.args}]},
|
{view: html.STATUS, list: [{text: value.args}]},
|
||||||
], function() { can.Option("uid", value.uid), can.Update() })
|
{view: html.OUTPUT, list: [{text: value.info}]},
|
||||||
|
])
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
})
|
})
|
8
src/gonganxitong/express/common.go
Normal file
8
src/gonganxitong/express/common.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package express
|
||||||
|
|
||||||
|
import (
|
||||||
|
"shylinux.com/x/community/src/gonganxitong"
|
||||||
|
_ "shylinux.com/x/community/src/gonganxitong/express/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Table struct{ gonganxitong.Table }
|
7
src/gonganxitong/express/common.json
Normal file
7
src/gonganxitong/express/common.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"express": "寄快递",
|
||||||
|
"icons": {
|
||||||
|
"express": "https://img.icons8.com/officel/80/shipped.png"
|
||||||
|
},
|
||||||
|
"value": {}
|
||||||
|
}
|
18
src/gonganxitong/express/express.go
Normal file
18
src/gonganxitong/express/express.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package express
|
||||||
|
|
||||||
|
import (
|
||||||
|
"shylinux.com/x/ice"
|
||||||
|
|
||||||
|
"shylinux.com/x/community/src/gonganxitong"
|
||||||
|
)
|
||||||
|
|
||||||
|
type express struct {
|
||||||
|
Table
|
||||||
|
portal gonganxitong.Portal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s express) Init(m *ice.Message, arg ...string) {
|
||||||
|
s.portal.Show(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(express{}) }
|
12
src/gonganxitong/express/model/model.go
Normal file
12
src/gonganxitong/express/model/model.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "shylinux.com/x/mysql-story/src/db"
|
||||||
|
|
||||||
|
type Express struct {
|
||||||
|
db.ModelWithUID
|
||||||
|
FromPlaceUID string `gorm:"type:char(32);index"`
|
||||||
|
ToPlaceUID string `gorm:"type:char(32);index"`
|
||||||
|
Status uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { db.CmdModels("", &Express{}) }
|
BIN
src/gonganxitong/icons/apply.png
Normal file
BIN
src/gonganxitong/icons/apply.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
src/gonganxitong/icons/event.png
Normal file
BIN
src/gonganxitong/icons/event.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
src/gonganxitong/icons/house.png
Normal file
BIN
src/gonganxitong/icons/house.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
BIN
src/gonganxitong/icons/office.png
Normal file
BIN
src/gonganxitong/icons/office.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
src/gonganxitong/icons/order.png
Normal file
BIN
src/gonganxitong/icons/order.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
@ -1,15 +1,12 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import "shylinux.com/x/mysql-story/src/db"
|
||||||
"time"
|
|
||||||
|
|
||||||
"shylinux.com/x/ice"
|
|
||||||
"shylinux.com/x/mysql-story/src/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
ID = "id"
|
||||||
UID = "uid"
|
UID = "uid"
|
||||||
NAME = "name"
|
NAME = "name"
|
||||||
|
INFO = "info"
|
||||||
TYPE = "type"
|
TYPE = "type"
|
||||||
ROLE = "role"
|
ROLE = "role"
|
||||||
STATUS = "status"
|
STATUS = "status"
|
||||||
@ -19,17 +16,22 @@ const (
|
|||||||
OPEN_ID = "open_id"
|
OPEN_ID = "open_id"
|
||||||
USER_UID = "user_uid"
|
USER_UID = "user_uid"
|
||||||
USER_NAME = "user_name"
|
USER_NAME = "user_name"
|
||||||
|
USER_AVATAR = "user_avatar"
|
||||||
USER_PLACE_ROLE = "user_place_role"
|
USER_PLACE_ROLE = "user_place_role"
|
||||||
PLACE_UID = "place_uid"
|
PLACE_UID = "place_uid"
|
||||||
PLACE_NAME = "place_name"
|
PLACE_NAME = "place_name"
|
||||||
PLACE_TYPE = "place_type"
|
PLACE_TYPE = "place_type"
|
||||||
PLACE_ADDRESS = "place_address"
|
PLACE_ADDRESS = "place_address"
|
||||||
STREET_UID = "street_uid"
|
|
||||||
STREET_NAME = "street_name"
|
STREET_NAME = "street_name"
|
||||||
|
STREET_UID = "street_uid"
|
||||||
|
CITY_NAME = "city_name"
|
||||||
|
CITY_UID = "city_uid"
|
||||||
APPLY_UID = "apply_uid"
|
APPLY_UID = "apply_uid"
|
||||||
APPLY_STATUS = "apply_status"
|
APPLY_STATUS = "apply_status"
|
||||||
ORDER_STATUS = "order_status"
|
ORDER_STATUS = "order_status"
|
||||||
ORDER_UID = "order_uid"
|
ORDER_UID = "order_uid"
|
||||||
|
CREATED_AT = "created_at"
|
||||||
|
OPERATE = "operate"
|
||||||
BEGIN_TIME = "begin_time"
|
BEGIN_TIME = "begin_time"
|
||||||
END_TIME = "end_time"
|
END_TIME = "end_time"
|
||||||
)
|
)
|
||||||
@ -48,32 +50,38 @@ type User struct {
|
|||||||
Avatar string `gorm:"size:256"`
|
Avatar string `gorm:"size:256"`
|
||||||
}
|
}
|
||||||
type UserPlace struct {
|
type UserPlace struct {
|
||||||
db.Model
|
db.ModelWithUID
|
||||||
UserUID string `gorm:"type:char(32);index"`
|
UserUID string `gorm:"type:char(32);index"`
|
||||||
PlaceUID string `gorm:"type:char(32)"`
|
PlaceUID string `gorm:"type:char(32)"`
|
||||||
Role uint8
|
Role uint8
|
||||||
BeginTime time.Time
|
BeginTime db.Time
|
||||||
EndTime time.Time
|
EndTime db.Time
|
||||||
}
|
}
|
||||||
type Place struct {
|
type Place struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
StreetUID string `gorm:"type:char(32)"`
|
StreetUID string `gorm:"type:char(32)"`
|
||||||
Name string `gorm:"type:char(32)"`
|
Name string `gorm:"type:char(32)"`
|
||||||
Type uint8
|
|
||||||
Address string `gorm:"size:256"`
|
Address string `gorm:"size:256"`
|
||||||
|
Type uint8
|
||||||
}
|
}
|
||||||
type Street struct {
|
type Street struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
Name string `gorm:"type:char(32)"`
|
CityUID string `gorm:"type:char(32)"`
|
||||||
|
Name string `gorm:"type:char(32);index"`
|
||||||
|
}
|
||||||
|
type City struct {
|
||||||
|
db.ModelWithUID
|
||||||
|
Name string `gorm:"type:char(32);index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
PlaceUID string `gorm:"type:char(32);index"`
|
PlaceUID string `gorm:"type:char(32);index"`
|
||||||
UserUID string `gorm:"type:char(32)"`
|
UserUID string `gorm:"type:char(32)";index`
|
||||||
Index string `gorm:"type:char(32)"`
|
Index string `gorm:"type:char(32)"`
|
||||||
Operate string `gorm:"type:char(32)"`
|
Operate string `gorm:"type:char(32)"`
|
||||||
Args string `gorm:"type:char(32)"`
|
Args string `gorm:"type:char(32)"`
|
||||||
|
Info string `gorm:"size:1024"`
|
||||||
}
|
}
|
||||||
type Apply struct {
|
type Apply struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
@ -81,8 +89,8 @@ type Apply struct {
|
|||||||
PlaceUID string `gorm:"type:char(32)"`
|
PlaceUID string `gorm:"type:char(32)"`
|
||||||
Status uint8
|
Status uint8
|
||||||
Role uint8
|
Role uint8
|
||||||
BeginTime time.Time
|
BeginTime db.Time
|
||||||
EndTime time.Time
|
EndTime db.Time
|
||||||
}
|
}
|
||||||
type Order struct {
|
type Order struct {
|
||||||
db.ModelWithUID
|
db.ModelWithUID
|
||||||
@ -91,10 +99,6 @@ type Order struct {
|
|||||||
Status uint8
|
Status uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
type models struct{ db.Models }
|
func init() {
|
||||||
|
db.CmdModels("", &Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, &City{}, Event{}, Apply{}, Order{})
|
||||||
func (s models) Init(m *ice.Message, arg ...string) {
|
|
||||||
s.Models.Register(m, "gonganxitong", &Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, Event{}, Apply{}, Order{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd("web.team.community.gonganxitong.models", models{}) }
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS gonganxitong CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
|
@ -9,53 +9,57 @@ import (
|
|||||||
|
|
||||||
type order struct {
|
type order struct {
|
||||||
Table
|
Table
|
||||||
user user
|
user user
|
||||||
apply apply
|
apply apply
|
||||||
place place
|
userPlace userPlace
|
||||||
street street
|
place place
|
||||||
event event
|
street street
|
||||||
portal string `data:"true"`
|
city city
|
||||||
create string `name:"create user_uid* apply_uid* status*"`
|
event event
|
||||||
reject string `name:"reject" role:"void"`
|
portal string `data:"true"`
|
||||||
approve string `name:"approve" role:"void"`
|
create string `name:"create user_uid* apply_uid* status*"`
|
||||||
list string `name:"list place_uid uid auto" role:"void"`
|
reject string `name:"reject" role:"void"`
|
||||||
|
approve string `name:"approve" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s order) Create(m *ice.Message, arg ...string) {
|
func (s order) Create(m *ice.Message, arg ...string) {
|
||||||
s.Table.Create(m, arg...)
|
s.Table.Create(m, arg...)
|
||||||
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限申请 请审批 🕑")
|
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限审批 请处理")
|
||||||
}
|
}
|
||||||
func (s order) Reject(m *ice.Message, arg ...string) {
|
func (s order) Reject(m *ice.Message, arg ...string) {
|
||||||
defer m.ToastProcess()()
|
defer m.ToastProcess()()
|
||||||
defer s.event.Record(m, m.Option(model.UID))
|
defer s.event.Record(m, kit.Format("审批驳回%s成为%s", m.Option(model.USER_NAME), m.Option(model.USER_PLACE_ROLE)), m.Option(model.UID))
|
||||||
m.Cmd(s.apply, s.apply.Reject, m.Option(model.UID))
|
m.Cmd(s.apply, s.apply.Reject, m.Option(model.UID))
|
||||||
s.Table.Update(m, kit.Dict(model.STATUS, OrderRejected), model.UID, m.Option(model.ORDER_UID))
|
s.Table.Update(m, kit.Dict(model.STATUS, OrderRejected), model.UID, m.Option(model.ORDER_UID))
|
||||||
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限申请 已驳回 ❌")
|
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限审批 已驳回 ❌")
|
||||||
}
|
}
|
||||||
func (s order) Approve(m *ice.Message, arg ...string) {
|
func (s order) Approve(m *ice.Message, arg ...string) {
|
||||||
defer m.ToastProcess()()
|
defer m.ToastProcess()()
|
||||||
defer s.event.Record(m, m.Option(model.UID))
|
defer s.event.Record(m, kit.Format("审批通过%s成为%s", m.Option(model.USER_NAME), m.Option(model.USER_PLACE_ROLE)), m.Option(model.UID))
|
||||||
m.Cmd(s.apply, s.apply.Approve, m.Option(model.UID))
|
m.Cmd(s.apply, s.apply.Approve, m.Option(model.UID))
|
||||||
s.Table.Update(m, kit.Dict(model.STATUS, OrderApproved), model.UID, m.Option(model.ORDER_UID))
|
s.Table.Update(m, kit.Dict(model.STATUS, OrderApproved), model.UID, m.Option(model.ORDER_UID))
|
||||||
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限申请 已通过 ✅")
|
s.SendTemplate(m, m.Option(model.USER_UID), "场所权限审批 已通过 ✅")
|
||||||
}
|
}
|
||||||
func (s order) List(m *ice.Message, arg ...string) {
|
func (s order) List(m *ice.Message, arg ...string) {
|
||||||
s.Tables(m, s.apply, s.place, s.street).Fields(m, "orders.created_at",
|
s.Tables(m, s.apply, "left join users on applies.user_uid = users.uid", s.place, s.street, s.city).Fields(m,
|
||||||
model.PLACE_NAME, model.PLACE_TYPE, "applies.role AS user_place_role", model.ORDER_STATUS,
|
s.Key(s, model.CREATED_AT), s.Key(s, model.ID),
|
||||||
model.STREET_NAME, model.PLACE_ADDRESS, model.PLACE_UID, "orders.uid AS order_uid",
|
model.USER_AVATAR, model.USER_NAME,
|
||||||
"applies.uid", model.BEGIN_TIME, model.END_TIME,
|
model.PLACE_NAME, model.PLACE_TYPE, s.AS(s.Key(s.apply, model.ROLE), model.USER_PLACE_ROLE), model.ORDER_STATUS,
|
||||||
).Orders(m, "created_at DESC")
|
model.CITY_NAME, model.STREET_NAME, model.PLACE_ADDRESS,
|
||||||
|
model.BEGIN_TIME, model.END_TIME,
|
||||||
|
s.Key(s.apply, model.UID), s.AS(s.Key(s, model.UID), model.ORDER_UID), model.PLACE_UID,
|
||||||
|
).Orders(m, s.Desc(model.CREATED_AT))
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
if m.IsTech() {
|
if m.IsTech() {
|
||||||
s.Table.Select(m)
|
s.Table.Select(m)
|
||||||
} else {
|
} else {
|
||||||
s.Table.Select(m, "orders.user_uid", m.Option(model.USER_UID))
|
s.Table.Select(m, s.Key(s, model.USER_UID), m.Option(model.USER_UID))
|
||||||
}
|
}
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
s.Table.Select(m, "orders.user_uid", m.Option(model.USER_UID), model.PLACE_UID, arg[0]).Action(s.Create)
|
s.Table.Select(m, s.Key(s, model.USER_UID), m.Option(model.USER_UID), model.PLACE_UID, arg[0])
|
||||||
defer m.Sort("order_status,created_at", []string{OrderCreate.String(), OrderApproved.String(), OrderRejected.String()}, ice.STR_R)
|
defer m.Sort(kit.Fields(model.ORDER_STATUS, model.CREATED_AT), []string{OrderCreate.String(), OrderApproved.String(), OrderRejected.String()}, ice.STR_R)
|
||||||
} else {
|
} else {
|
||||||
s.Table.Select(m.FieldsSetDetail(), "orders.user_uid", m.Option(model.USER_UID), "applies.uid", arg[1])
|
s.Table.Select(m.FieldsSetDetail(), s.Key(s, model.USER_UID), m.Option(model.USER_UID), s.Key(s.apply, model.UID), arg[1])
|
||||||
}
|
}
|
||||||
m.Table(func(value ice.Maps) {
|
m.Table(func(value ice.Maps) {
|
||||||
switch OrderStatus(kit.Int(value[model.ORDER_STATUS])) {
|
switch OrderStatus(kit.Int(value[model.ORDER_STATUS])) {
|
||||||
@ -65,10 +69,11 @@ func (s order) List(m *ice.Message, arg ...string) {
|
|||||||
m.PushButton()
|
m.PushButton()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
m.Info("what %v", m.FormatsMeta(nil))
|
||||||
s.RewriteAppend(m).Display("").DisplayCSS("")
|
s.RewriteAppend(m).Display("").DisplayCSS("")
|
||||||
|
|
||||||
}
|
}
|
||||||
func init() { ice.Cmd(prefixKey(), order{}) }
|
func init() { ice.TeamCtxCmd(order{}) }
|
||||||
|
|
||||||
type OrderStatus int
|
type OrderStatus int
|
||||||
|
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
Volcanos(chat.ONIMPORT, {
|
Volcanos(chat.ONIMPORT, {
|
||||||
_init: function(can, msg) { if (msg.IsDetail()) { return msg.Dump(can) }
|
_init: function(can, msg) {
|
||||||
can.page.Append(can, can._output, msg.Table(function(value) {
|
if (msg.IsDetail()) { msg.Option("_share_icons", msg.Append("user_avatar"))
|
||||||
value._style = [value.place_type, value.user_place_role, value.order_status]
|
msg.Option("_share_content", can.user.transValue(can, msg, "user_place_role")+" "+msg.Append("user_name"))
|
||||||
|
return msg.Dump(can)
|
||||||
|
}
|
||||||
|
can.page.Append(can, can._output, msg.Table(function(value) { value._style = [value.place_type, value.user_place_role, value.order_status]
|
||||||
return can.onimport.itemcard(can, value, [
|
return can.onimport.itemcard(can, value, [
|
||||||
{view: html.TITLE, list: [{text: value.place_name},
|
{view: html.TITLE, list: [{text: value.user_name},
|
||||||
{text: [can.user.transValue(can, value, "place_type"), "", mdb.TYPE]},
|
{text: [can.user.transValue(can, value, "place_type"), "", mdb.TYPE]},
|
||||||
{text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
{text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
||||||
{text: [can.user.transValue(can, value, "order_status"), "", mdb.STATUS]},
|
{text: [can.user.transValue(can, value, "order_status"), "", mdb.STATUS]},
|
||||||
]},
|
]},
|
||||||
{view: html.STATUS, list: [{text: value.street_name}, {text: value.place_address}]},
|
|
||||||
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
||||||
{view: html.STATUS, list: [{text: value.begin_time.split(" ")[0]}, {text: value.end_time.split(" ")[0]}]},
|
{view: html.STATUS, list: [{text: value.begin_time.split(" ")[0]}, {text: value.end_time.split(" ")[0]}]},
|
||||||
], function() { can.Option("uid", value.uid), can.Update() })
|
{view: html.STATUS, list: [{text: value.city_name}, {text: value.street_name}, {text: value.place_address}]},
|
||||||
|
])
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
})
|
})
|
@ -2,14 +2,30 @@ package gonganxitong
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
|
||||||
"shylinux.com/x/community/src/gonganxitong/model"
|
"shylinux.com/x/community/src/gonganxitong/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type place struct{ Table }
|
type place struct {
|
||||||
|
Table
|
||||||
|
user user
|
||||||
|
city city
|
||||||
|
street street
|
||||||
|
}
|
||||||
|
|
||||||
func (s place) Inputs(m *ice.Message, arg ...string) {
|
func (s place) Inputs(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case model.CITY_NAME:
|
||||||
|
if m.Option(ctx.ACTION) == "placeCreate" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
m.Cmdy(s.city, s.city.Select).CutTo(model.NAME, arg[0])
|
||||||
|
case model.STREET_NAME:
|
||||||
|
if m.Option(ctx.ACTION) == "placeCreate" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
m.Cmdy(s.street, s.street.Select).CutTo(model.NAME, arg[0])
|
||||||
case model.PLACE_TYPE:
|
case model.PLACE_TYPE:
|
||||||
for k, v := range PlaceTypeList {
|
for k, v := range PlaceTypeList {
|
||||||
m.Push(arg[0], k).Push(model.NAME, v)
|
m.Push(arg[0], k).Push(model.NAME, v)
|
||||||
@ -19,8 +35,28 @@ func (s place) Inputs(m *ice.Message, arg ...string) {
|
|||||||
s.Table.Inputs(m, arg...)
|
s.Table.Inputs(m, arg...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (s place) User(m *ice.Message, arg ...string) {
|
||||||
|
userPlace := userPlace{}
|
||||||
|
s.Tables(m, "left join user_places on places.uid = user_places.place_uid", s.user).Fields(m,
|
||||||
|
s.Key(userPlace, model.CREATED_AT), s.Key(userPlace, model.UID),
|
||||||
|
model.USER_AVATAR, model.USER_NAME, model.USER_PLACE_ROLE, model.BEGIN_TIME, model.END_TIME,
|
||||||
|
).Orders(m, s.Desc(model.CREATED_AT))
|
||||||
|
if len(arg) == 0 {
|
||||||
|
if m.IsTech() {
|
||||||
|
s.Select(m)
|
||||||
|
}
|
||||||
|
} else if len(arg) == 1 {
|
||||||
|
s.Select(m, model.PLACE_UID, arg[0])
|
||||||
|
} else {
|
||||||
|
s.Select(m.FieldsSetDetail(), s.Key(userPlace, model.UID), arg[1])
|
||||||
|
}
|
||||||
|
s.RewriteAppend(m)
|
||||||
|
}
|
||||||
|
func init() { ice.TeamCtxCmd(place{}) }
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), place{}) }
|
type Place struct{ place }
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(Place{}) }
|
||||||
|
|
||||||
type PlaceType int
|
type PlaceType int
|
||||||
|
|
||||||
|
22
src/gonganxitong/placeUser.go
Normal file
22
src/gonganxitong/placeUser.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package gonganxitong
|
||||||
|
|
||||||
|
import (
|
||||||
|
"shylinux.com/x/ice"
|
||||||
|
|
||||||
|
"shylinux.com/x/community/src/gonganxitong/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type placeUser struct {
|
||||||
|
place place
|
||||||
|
portal portal
|
||||||
|
list string `name:"list place_uid uid auto" role:"void"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s placeUser) Init(m *ice.Message, arg ...string) {
|
||||||
|
s.portal.Show(m, model.ROLE, "creator,landlord")
|
||||||
|
}
|
||||||
|
func (s placeUser) List(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(s.place, s.place.User, arg).PushAction().Action().Display("")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(placeUser{}) }
|
13
src/gonganxitong/placeUser.js
Normal file
13
src/gonganxitong/placeUser.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Volcanos(chat.ONIMPORT, {
|
||||||
|
_init: function(can, msg) { if (msg.IsDetail()) { return msg.Dump(can) }
|
||||||
|
can.page.Append(can, can._output, msg.Table(function(value) { value._style = [value.user_place_role]
|
||||||
|
return can.onimport.itemcard(can, value, [
|
||||||
|
{view: html.TITLE, list: [{text: value.user_name},
|
||||||
|
{text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
||||||
|
]},
|
||||||
|
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
|
||||||
|
{view: html.STATUS, list: [{text: value.begin_time.split(" ")[0]}, {text: value.end_time.split(" ")[0]}]},
|
||||||
|
])
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
})
|
@ -14,4 +14,11 @@ $output>div.list>div.action div.item i { display:none; }
|
|||||||
$output>div.action div.item.button { margin-right:5px; }
|
$output>div.action div.item.button { margin-right:5px; }
|
||||||
$output>div.action div.item.button input { border:none; color:var(--notice-bg-color); min-width:80px; float:left; }
|
$output>div.action div.item.button input { border:none; color:var(--notice-bg-color); min-width:80px; float:left; }
|
||||||
$output>div.action div.item.button span { display:none; }
|
$output>div.action div.item.button span { display:none; }
|
||||||
$output>fieldset.qrcode table.content td { text-align:center; }
|
$output>fieldset table.content td { box-shadow:none; }
|
||||||
|
$output>fieldset table.content tr.uid { display:none; }
|
||||||
|
$output>fieldset table.content tr.order_uid { display:none; }
|
||||||
|
$output>fieldset table.content tr.place_uid { display:none; }
|
||||||
|
$output>fieldset table.content td img { max-width:100%; }
|
||||||
|
$output>fieldset.qrcode table.content td { text-align:center; }
|
||||||
|
$output>fieldset.qrcode div.code { text-align:center; }
|
||||||
|
$output>fieldset.story { box-shadow:none; }
|
@ -16,12 +16,14 @@ type portal struct {
|
|||||||
userPlace userPlace
|
userPlace userPlace
|
||||||
place place
|
place place
|
||||||
street street
|
street street
|
||||||
|
city city
|
||||||
export string `data:"true"`
|
export string `data:"true"`
|
||||||
short string `data:"index"`
|
short string `data:"index"`
|
||||||
field string `data:"time,name,icons,index,order,enable,type,role"`
|
field string `data:"time,name,icons,index,order,enable,type,role"`
|
||||||
|
inputs string `name:"inputs" role:"void"`
|
||||||
list string `name:"list place_uid index uid auto" role:"void"`
|
list string `name:"list place_uid index uid auto" role:"void"`
|
||||||
placeCreate string `name:"placeCreate street_uid*:select place_type*:select name* address*" role:"void"`
|
placeCreate string `name:"placeCreate city_name* street_name* place_type*:select name* address*" role:"void"`
|
||||||
placeRemove string `name:"placeRemove place_uid*" role:"void"`
|
placeRemove string `name:"placeRemove user_uid* place_uid* user_place_role*" role:"void"`
|
||||||
scanQRCode string `name:"scanQRCode type text" role:"void"`
|
scanQRCode string `name:"scanQRCode type text" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +43,8 @@ func (s portal) List(m *ice.Message, arg ...string) {
|
|||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
s.Hash.List(m, arg[1:]...).SortInt(mdb.ORDER)
|
s.Hash.List(m, arg[1:]...).SortInt(mdb.ORDER)
|
||||||
} else if len(arg) == 2 {
|
} else if len(arg) == 2 {
|
||||||
|
msg := m.Cmd(s.place, s.place.Select, model.UID, arg[0])
|
||||||
|
m.Option(model.PLACE_NAME, msg.Append(model.NAME))
|
||||||
m.Cmdy(ctx.COMMAND, arg[1]).Push(ctx.ARGS, arg[0])
|
m.Cmdy(ctx.COMMAND, arg[1]).Push(ctx.ARGS, arg[0])
|
||||||
} else {
|
} else {
|
||||||
m.FieldsSetDetail().Cmdy(arg[1], mdb.SELECT, model.UID, arg[2]).PushAction().Action()
|
m.FieldsSetDetail().Cmdy(arg[1], mdb.SELECT, model.UID, arg[2]).PushAction().Action()
|
||||||
@ -49,11 +53,10 @@ func (s portal) List(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
|
func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
|
||||||
defer m.ToastProcess()()
|
defer m.ToastProcess()()
|
||||||
if m.WarnNotFound(m.Cmd(s.street, s.street.Select, model.UID, m.Option(model.STREET_UID)).Length() == 0, "street") {
|
s.city.FindOrCreateByName(m, arg...)
|
||||||
return
|
s.street.FindOrCreateByName(m, arg...)
|
||||||
}
|
|
||||||
arg = kit.TransArgKeys(arg, model.PLACE_TYPE, model.TYPE)
|
arg = kit.TransArgKeys(arg, model.PLACE_TYPE, model.TYPE)
|
||||||
if m.Cmdy(s.place, s.place.Create, arg).IsErr() {
|
if m.Cmdy(s.place, s.place.Create, arg[2:]).IsErr() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
args := kit.Simple(model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, m.Result(), model.ROLE, UserPlaceCreator)
|
args := kit.Simple(model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, m.Result(), model.ROLE, UserPlaceCreator)
|
||||||
@ -62,12 +65,12 @@ func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
func (s portal) PlaceRemove(m *ice.Message, arg ...string) {
|
func (s portal) PlaceRemove(m *ice.Message, arg ...string) {
|
||||||
defer m.ToastProcess()()
|
defer m.ToastProcess()()
|
||||||
args := kit.Simple(model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, m.Option(model.PLACE_UID))
|
args := kit.Simple(model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, m.Option(model.PLACE_UID), model.ROLE, m.Option(model.USER_PLACE_ROLE))
|
||||||
msg := m.Cmd(s.userPlace, s.userPlace.Select, args)
|
msg := m.Cmd(s.userPlace, s.userPlace.Select, args)
|
||||||
if m.WarnNotFound(msg.Length() == 0, "place") {
|
if m.WarnNotFound(msg.Length() == 0, "place") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Cmdy(s.userPlace, s.userPlace.Delete, args)
|
m.Cmdy(s.userPlace, s.userPlace.Delete, msg.AppendSimple(model.UID))
|
||||||
if kit.Int(msg.Append(model.ROLE)) == kit.Int(UserPlaceCreator) {
|
if kit.Int(msg.Append(model.ROLE)) == kit.Int(UserPlaceCreator) {
|
||||||
m.Cmdy(s.place, s.place.Delete, model.UID, m.Option(model.PLACE_UID))
|
m.Cmdy(s.place, s.place.Delete, model.UID, m.Option(model.PLACE_UID))
|
||||||
}
|
}
|
||||||
@ -88,7 +91,7 @@ func (s portal) ScanQRCode(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), portal{}) }
|
func init() { ice.TeamCtxCmd(portal{}) }
|
||||||
|
|
||||||
type Portal struct {
|
type Portal struct {
|
||||||
portal
|
portal
|
||||||
@ -97,12 +100,12 @@ type Portal struct {
|
|||||||
field string `data:"time,name,icons,index,order,enable,type,role"`
|
field string `data:"time,name,icons,index,order,enable,type,role"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), Portal{}) }
|
func init() { ice.TeamCtxCmd(Portal{}) }
|
||||||
|
|
||||||
func (s portal) Show(m *ice.Message, arg ...string) {
|
func (s portal) Show(m *ice.Message, arg ...string) {
|
||||||
m.GoSleep("30ms", func() {
|
m.GoSleep("30ms", func() {
|
||||||
cmd := m.GetCommand()
|
cmd := m.GetCommand()
|
||||||
icon := kit.Select(cmd.Icon, kit.Value(cmd.Meta, kit.Keys(ice.CTX_ICONS, m.CommandKey())))
|
icon := kit.Select(cmd.Icon, kit.Value(cmd.Meta, kit.Keys(ice.CTX_ICONS, m.CommandKey())))
|
||||||
m.Cmd(s, s.Create, mdb.NAME, cmd.Help, mdb.ICONS, icon, ctx.INDEX, m.PrefixKey())
|
m.Cmd(s, s.Create, mdb.NAME, cmd.Help, mdb.ICONS, icon, ctx.INDEX, m.PrefixKey(), arg)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,17 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
{text: [can.user.transValue(can, value, PLACE_TYPE), "", mdb.TYPE]},
|
{text: [can.user.transValue(can, value, PLACE_TYPE), "", mdb.TYPE]},
|
||||||
value.user_place_role != "creator" && {text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
value.user_place_role != "creator" && {text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
||||||
]},
|
]},
|
||||||
{view: html.STATUS, list: [{text: value[PLACE_UID].slice(0, 8)}, {text: value.street_name}, {text: can.base.TimeTrim(value.created_at)}]},
|
{view: html.STATUS, list: [
|
||||||
|
{text: value[PLACE_UID].slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)},
|
||||||
|
{text: value.city_name}, {text: value.street_name},
|
||||||
|
]},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
myPortal: function(can, msg, PLACE_UID, PLACE_NAME, title) { can.user.isMobile && can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
|
myPortal: function(can, msg, PLACE_UID, PLACE_NAME, title) { can.user.isMobile && can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
|
||||||
can.db.hash = can.misc.SearchHash(can), can.sup.current = can.sup.current||{}
|
can.isCmdMode() && (can.db.hash = can.misc.SearchHash(can))
|
||||||
|
can.sup.current = can.sup.current||{}
|
||||||
if (can.Option(PLACE_UID) == "") {
|
if (can.Option(PLACE_UID) == "") {
|
||||||
if (can.db.hash.length > 1 && can.db.hash[0]) {
|
if (can.db.hash.length > 1 && can.db.hash[0]) { return can.Option(PLACE_UID, can.db.hash[0]), can.Option(ctx.INDEX, can.db.hash[1]), can.Update() }
|
||||||
return can.Option(PLACE_UID, can.db.hash[0]), can.Option(ctx.INDEX, can.db.hash[1]), can.Update()
|
|
||||||
}
|
|
||||||
can.db.hash[0] && can.onexport.session(can, PLACE_UID, can.db.hash[0])
|
can.db.hash[0] && can.onexport.session(can, PLACE_UID, can.db.hash[0])
|
||||||
can.ui = can.page.Append(can, can._output, ["myplace.list", "myindex.list"])
|
can.ui = can.page.Append(can, can._output, ["myplace.list", "myindex.list"])
|
||||||
can.page.Append(can, can.ui.myplace, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Place", title)}], _init: function(target) {
|
can.page.Append(can, can.ui.myplace, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Place", title)}], _init: function(target) {
|
||||||
@ -25,14 +27,18 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
|
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
|
||||||
}}])
|
}}])
|
||||||
}}])
|
}}])
|
||||||
|
msg.Table(function(value) { var key = "_trans.value."+PLACE_NAME.replace("_name", "_type")+".icons."
|
||||||
|
msg.Push(mdb.ICONS, can.Conf(key+value.place_type)||can.Conf(key+"office"))
|
||||||
|
})
|
||||||
var uid = can.onimport.myPlace(can, msg, can.ui.myplace, PLACE_UID, PLACE_NAME)
|
var uid = can.onimport.myPlace(can, msg, can.ui.myplace, PLACE_UID, PLACE_NAME)
|
||||||
msg.Length() > 0 && can.run({}, [uid], function(msg) {
|
msg.Length() > 0 && can.run({}, [uid], function(msg) {
|
||||||
can.page.Append(can, can.ui.myindex, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Index", "我的应用")}]}])
|
can.page.Append(can, can.ui.myindex, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Index", "我的应用")}]}])
|
||||||
for (var i = 0; i < 1; i++) { can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID) }
|
for (var i = 0; i < 1; i++) { can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID) }
|
||||||
can.onimport.selectIndex(can, can.sup.current)
|
can.onimport.selectIndex(can, can.sup.current)
|
||||||
})
|
})
|
||||||
|
can.user.agent.init(can)
|
||||||
} else {
|
} else {
|
||||||
can.onimport.myData(can, msg, can._output, PLACE_UID)
|
can.onimport.myData(can, msg, can._output, PLACE_UID, PLACE_NAME)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
myPlace: function(can, msg, target, PLACE_UID, PLACE_NAME) { var place_uid
|
myPlace: function(can, msg, target, PLACE_UID, PLACE_NAME) { var place_uid
|
||||||
@ -78,17 +84,20 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
}}
|
}}
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
myData: function(can, msg, target, PLACE_UID) {
|
myData: function(can, msg, target, PLACE_UID, PLACE_NAME) {
|
||||||
msg.Table(function(value) { function back() {} function refresh() {}
|
msg.Table(function(value) { function back() {} function refresh() {}
|
||||||
var list = [can.page.button(can, can.user.trans(can, "goback", "返回"), function(event) { back() }), can.page.button(can, can.user.trans(can, "reload", "刷新"), function(event) { refresh() })]
|
var list = [can.page.button(can, can.user.trans(can, "goback", "返回"), function(event) { back() }), can.page.button(can, can.user.trans(can, "reload", "刷新"), function(event) { refresh() })]
|
||||||
var ui = can.page.Append(can, can._output, [{view: html.ACTION}])
|
var ui = can.page.Append(can, can._output, [{view: html.ACTION}])
|
||||||
if (can.db.hash.length > 2 && can.db.hash[0] && can.db.hash[2]) { value.args = [can.db.hash[0], can.db.hash[2]] }
|
if (can.db.hash.length > 2 && can.db.hash[0] && can.db.hash[2]) { value.args = [can.db.hash[0], can.db.hash[2]] }
|
||||||
value.style = html.OUTPUT, value.height = can.ConfHeight()-html.ACTION_HEIGHT
|
value.style = html.OUTPUT, value.height = can.ConfHeight()-html.ACTION_HEIGHT
|
||||||
can.onexport.title(can, can.ConfHelp(), can.sup.current.place_name, value.help)
|
// can.onexport.title(can, value.help, can.user.trans(can, msg.Option("place_type"), null, "value.place_type"), msg.Option("place_name"))
|
||||||
|
can.onexport.title(can, value.help, msg.Option(PLACE_NAME))
|
||||||
can.onappend.plugin(can, value, function(sub) { refresh = function() { sub.Update() }
|
can.onappend.plugin(can, value, function(sub) { refresh = function() { sub.Update() }
|
||||||
sub.onexport.output = function(_sub, msg) { can.user.toastSuccess(can, "load", "", 1000), can.onappend.style(sub, html.OUTPUT)
|
sub.Conf(PLACE_NAME, msg.Option(PLACE_NAME))
|
||||||
|
sub.onexport.output = function(_sub, msg) { can.onappend.style(sub, html.OUTPUT)
|
||||||
can.page.Appends(can, ui.action, list), msg.Option(ice.MSG_ACTION) && can.onappend._action(sub, msg.Option(ice.MSG_ACTION), ui.action, null, true)
|
can.page.Appends(can, ui.action, list), msg.Option(ice.MSG_ACTION) && can.onappend._action(sub, msg.Option(ice.MSG_ACTION), ui.action, null, true)
|
||||||
can.onexport.hash(can, can.Option(PLACE_UID), value.index, sub.Option(UID))
|
can.onexport.hash(can, can.Option(PLACE_UID), value.index, sub.Option(UID))
|
||||||
|
can.user.agent.init(can, msg.Option("_share_content")||value.help, msg.Option("_share_icons")||value.icons)
|
||||||
back = function() {
|
back = function() {
|
||||||
if (sub.Option(UID)) {
|
if (sub.Option(UID)) {
|
||||||
can.onexport.hash(can, can.Option(PLACE_UID), can.Option(ctx.INDEX)), sub.Option(UID, ""), sub.Update()
|
can.onexport.hash(can, can.Option(PLACE_UID), can.Option(ctx.INDEX)), sub.Option(UID, ""), sub.Update()
|
||||||
|
@ -1,43 +1,50 @@
|
|||||||
{
|
{
|
||||||
"user": "用户",
|
|
||||||
"place": "场所",
|
|
||||||
"street": "街道",
|
|
||||||
"portal": "用户场所",
|
"portal": "用户场所",
|
||||||
"scanQRCode": "扫码添加",
|
"scanQRCode": "扫码添加",
|
||||||
"placeCreate": "添加场所",
|
"placeCreate": "添加场所",
|
||||||
"placeRemove": "删除场所",
|
"placeRemove": "删除场所",
|
||||||
"email": "邮箱配置",
|
|
||||||
"qrcode": "场所码",
|
"qrcode": "场所码",
|
||||||
"event": "事件流",
|
|
||||||
"apply": "申请单",
|
"apply": "申请单",
|
||||||
"order": "审批单",
|
"order": "审批单",
|
||||||
|
"event": "事件流",
|
||||||
|
"email": "邮箱配置",
|
||||||
|
"placeUser": "场所用户",
|
||||||
|
"cancel": "取消",
|
||||||
|
"submit": "提交",
|
||||||
"reject": "驳回",
|
"reject": "驳回",
|
||||||
"approve": "通过",
|
"approve": "通过",
|
||||||
"icons": {
|
"icons": {
|
||||||
"email": "usr/icons/Mail.png",
|
|
||||||
"qrcode": "usr/icons/Chess.png",
|
|
||||||
"scanQRCode": "bi bi-qr-code-scan",
|
"scanQRCode": "bi bi-qr-code-scan",
|
||||||
"placeCreate": "bi bi-plus-square-dotted"
|
"placeCreate": "bi bi-plus-square-dotted",
|
||||||
|
"qrcode": "https://img.icons8.com/officel/80/qr-code.png",
|
||||||
|
"apply": "https://img.icons8.com/officel/80/edit-property.png",
|
||||||
|
"order": "https://img.icons8.com/officel/80/receipt-approved.png",
|
||||||
|
"event": "https://img.icons8.com/officel/80/property-with-timer.png",
|
||||||
|
"email": "https://img.icons8.com/officel/80/reading-confirmation.png",
|
||||||
|
"placeUser": "https://img.icons8.com/officel/80/person-at-home.png"
|
||||||
},
|
},
|
||||||
"style": {
|
"style": {
|
||||||
"placeRemove": "danger"
|
"placeRemove": "danger"
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
"address": "地址",
|
"city_uid": "城市",
|
||||||
"open_id": "外键",
|
"city_name": "城市名称",
|
||||||
"user_uid": "用户",
|
"street_uid": "街道",
|
||||||
"user_name": "用户名",
|
"street_name": "街道名称",
|
||||||
"user_place_role": "用户角色",
|
|
||||||
"place_uid": "场所",
|
"place_uid": "场所",
|
||||||
"place_name": "场所名称",
|
"place_name": "场所名称",
|
||||||
"place_type": "场所类型",
|
"place_type": "场所类型",
|
||||||
"place_address": "场所地址",
|
"place_address": "场所地址",
|
||||||
"street_uid": "街道",
|
"user_place_role": "用户角色",
|
||||||
"street_name": "街道名称",
|
"user_uid": "用户",
|
||||||
|
"user_name": "用户昵称",
|
||||||
|
"user_avatar": "用户头像",
|
||||||
"apply_status": "申请状态",
|
"apply_status": "申请状态",
|
||||||
"order_status": "审批状态",
|
"order_status": "审批状态",
|
||||||
|
"order_uid": "审批",
|
||||||
"begin_time": "起始时间",
|
"begin_time": "起始时间",
|
||||||
"end_time": "结束时间"
|
"end_time": "结束时间",
|
||||||
|
"operate": "操作"
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"place_type": {
|
"place_type": {
|
||||||
@ -48,7 +55,17 @@
|
|||||||
"school": "学校",
|
"school": "学校",
|
||||||
"office": "办公",
|
"office": "办公",
|
||||||
"factory": "工厂",
|
"factory": "工厂",
|
||||||
"hospital": "医院"
|
"hospital": "医院",
|
||||||
|
"icons": {
|
||||||
|
"house": "https://img.icons8.com/officel/80/cottage.png",
|
||||||
|
"hotel": "https://img.icons8.com/officel/80/5-star-hotel.png",
|
||||||
|
"store": "https://img.icons8.com/officel/80/online-store.png",
|
||||||
|
"public": "https://img.icons8.com/officel/80/university.png",
|
||||||
|
"school": "https://img.icons8.com/officel/80/classroom.png",
|
||||||
|
"office": "https://img.icons8.com/officel/80/building.png",
|
||||||
|
"factory": "https://img.icons8.com/officel/80/manufacturing.png",
|
||||||
|
"hospital": "https://img.icons8.com/officel/80/clinic.png"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"user_place_role": {
|
"user_place_role": {
|
||||||
"creator": "创建人",
|
"creator": "创建人",
|
||||||
|
11
src/gonganxitong/portal.shy
Normal file
11
src/gonganxitong/portal.shy
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
chapter "用户场所"
|
||||||
|
refer `
|
||||||
|
ICON https://igoutu.cn/icons/officel
|
||||||
|
GORM https://gorm.io/docs/indexes.html
|
||||||
|
`
|
||||||
|
|
||||||
|
field web.code.mysql.client
|
||||||
|
field web.code.mysql.query args `mysql gonganxitong`
|
||||||
|
field web.code.db.database
|
||||||
|
field web.code.db.driver
|
||||||
|
field web.code.db.models
|
@ -2,14 +2,15 @@ package gonganxitong
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
|
||||||
"shylinux.com/x/community/src/gonganxitong/model"
|
"shylinux.com/x/community/src/gonganxitong/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type qrcode struct {
|
type qrcode struct {
|
||||||
portal portal
|
portal portal
|
||||||
user user
|
|
||||||
userPlace userPlace
|
userPlace userPlace
|
||||||
|
list string `name:"list place_uid uid auto" role:"void"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s qrcode) Init(m *ice.Message, arg ...string) {
|
func (s qrcode) Init(m *ice.Message, arg ...string) {
|
||||||
@ -18,9 +19,12 @@ func (s qrcode) Init(m *ice.Message, arg ...string) {
|
|||||||
func (s qrcode) List(m *ice.Message, arg ...string) {
|
func (s qrcode) List(m *ice.Message, arg ...string) {
|
||||||
msg := m.Cmd(s.userPlace, m.Option(model.USER_UID), arg[0])
|
msg := m.Cmd(s.userPlace, m.Option(model.USER_UID), arg[0])
|
||||||
m.FieldsSetDetail()
|
m.FieldsSetDetail()
|
||||||
m.Push(model.PLACE_NAME, msg.Append(model.PLACE_NAME))
|
kit.For([]string{
|
||||||
m.Push(model.PLACE_UID, arg[0])
|
model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME, model.PLACE_ADDRESS,
|
||||||
|
}, func(key string) {
|
||||||
|
m.Push(key, msg.Append(key))
|
||||||
|
})
|
||||||
m.EchoQRCode(cmdurl(m, arg[0], m.Prefix("apply")))
|
m.EchoQRCode(cmdurl(m, arg[0], m.Prefix("apply")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), qrcode{}) }
|
func init() { ice.TeamCtxCmd(qrcode{}) }
|
||||||
|
@ -22,10 +22,11 @@ func (s sess) Create(m *ice.Message, arg ...string) {
|
|||||||
func (s sess) Check(m *ice.Message, arg ...string) {
|
func (s sess) Check(m *ice.Message, arg ...string) {
|
||||||
msg := s.Table.Select(m.Spawn(), model.UID, arg[0])
|
msg := s.Table.Select(m.Spawn(), model.UID, arg[0])
|
||||||
msg = m.Cmd(s.user, s.user.Select, model.UID, msg.Append(model.USER_UID))
|
msg = m.Cmd(s.user, s.user.Select, model.UID, msg.Append(model.USER_UID))
|
||||||
|
m.Option(ice.MSG_USERROLE, aaa.VOID)
|
||||||
m.Option(ice.MSG_USERNAME, msg.Append(model.UID))
|
m.Option(ice.MSG_USERNAME, msg.Append(model.UID))
|
||||||
m.Option(ice.MSG_USERNICK, msg.Append(model.NAME))
|
m.Option(ice.MSG_USERNICK, msg.Append(model.NAME))
|
||||||
m.Option(ice.MSG_AVATAR, msg.Append(model.AVATAR))
|
m.Option(ice.MSG_AVATAR, msg.Append(model.AVATAR))
|
||||||
m.Option(model.USER_UID, msg.Append(model.UID))
|
m.Option(model.USER_UID, msg.Append(model.UID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), sess{}) }
|
func init() { ice.TeamCtxCmd(sess{}) }
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
package gonganxitong
|
package gonganxitong
|
||||||
|
|
||||||
import "shylinux.com/x/ice"
|
import (
|
||||||
|
"shylinux.com/x/ice"
|
||||||
|
|
||||||
|
"shylinux.com/x/community/src/gonganxitong/model"
|
||||||
|
)
|
||||||
|
|
||||||
type street struct{ Table }
|
type street struct{ Table }
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), street{}) }
|
func (s street) FindOrCreateByName(m *ice.Message, arg ...string) {
|
||||||
|
if msg := m.Cmd(s, s.Select, model.CITY_UID, arg[1], model.NAME, arg[3]); msg.Length() == 0 {
|
||||||
|
msg := m.Cmd(s, s.Create, model.CITY_UID, arg[1], model.NAME, arg[3])
|
||||||
|
arg[2], arg[3] = model.STREET_UID, msg.Result()
|
||||||
|
} else {
|
||||||
|
arg[2], arg[3] = model.STREET_UID, msg.Append(model.UID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(street{}) }
|
||||||
|
@ -22,15 +22,13 @@ func (s user) Create(m *ice.Message, arg ...string) {
|
|||||||
s.Table.Create(m, kit.Simple(m.OptionSimple(model.OPEN_ID, model.AVATAR), model.NAME, m.Option(aaa.USERNICK))...)
|
s.Table.Create(m, kit.Simple(m.OptionSimple(model.OPEN_ID, model.AVATAR), model.NAME, m.Option(aaa.USERNICK))...)
|
||||||
m.Option(model.USER_UID, m.Result())
|
m.Option(model.USER_UID, m.Result())
|
||||||
} else {
|
} else {
|
||||||
|
s.Table.Update(m, kit.Dict(m.OptionSimple(model.AVATAR), model.NAME, m.Option(aaa.USERNICK)), m.AppendSimple(model.UID)...)
|
||||||
m.Option(model.USER_UID, m.Append(model.UID))
|
m.Option(model.USER_UID, m.Append(model.UID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s user) Email(m *ice.Message, arg ...string) {
|
func (s user) Email(m *ice.Message, arg ...string) {
|
||||||
s.Table.Update(m, m.OptionSimple(model.EMAIL), model.UID, m.Option(model.USER_UID))
|
s.Table.Update(m, kit.Dict(m.OptionSimple(model.EMAIL)), model.UID, m.Option(model.USER_UID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), user{}) }
|
|
||||||
|
|
||||||
func (s user) SendTemplate(m *ice.Message, arg ...string) { // uid url type name hash
|
func (s user) SendTemplate(m *ice.Message, arg ...string) { // uid url type name hash
|
||||||
msg := s.Select(m, model.UID, arg[0])
|
msg := s.Select(m, model.UID, arg[0])
|
||||||
m.Cmdy("web.chat.wx.template", "", m.Config("template"), msg.Append(model.OPEN_ID), kit.Select("", arg, 1),
|
m.Cmdy("web.chat.wx.template", "", m.Config("template"), msg.Append(model.OPEN_ID), kit.Select("", arg, 1),
|
||||||
@ -39,6 +37,8 @@ func (s user) SendTemplate(m *ice.Message, arg ...string) { // uid url type name
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(user{}) }
|
||||||
|
|
||||||
type User struct{ user }
|
type User struct{ user }
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), User{}) }
|
func init() { ice.TeamCtxCmd(User{}) }
|
||||||
|
@ -10,27 +10,34 @@ type userPlace struct {
|
|||||||
Table
|
Table
|
||||||
place place
|
place place
|
||||||
street street
|
street street
|
||||||
create string `name:"create user_uid* place_uid* role*"`
|
city city
|
||||||
|
create string `name:"create user_uid* place_uid* role* begin_time end_time"`
|
||||||
list string `name:"list user_uid place_uid auto"`
|
list string `name:"list user_uid place_uid auto"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s userPlace) List(m *ice.Message, arg ...string) {
|
func (s userPlace) List(m *ice.Message, arg ...string) {
|
||||||
s.Tables(m, s.place, s.street).Fields(m, "user_places.created_at",
|
s.Tables(m, s.place, s.street, s.city).Fields(m, "user_places.created_at", "user_places.id",
|
||||||
model.USER_UID, model.PLACE_UID,
|
|
||||||
model.PLACE_NAME, model.PLACE_TYPE, model.USER_PLACE_ROLE,
|
model.PLACE_NAME, model.PLACE_TYPE, model.USER_PLACE_ROLE,
|
||||||
model.STREET_NAME, model.PLACE_ADDRESS,
|
model.CITY_NAME, model.STREET_NAME, model.PLACE_ADDRESS,
|
||||||
).Orders(m, "user_places.id DESC")
|
model.USER_UID, model.PLACE_UID,
|
||||||
|
).Orders(m, "created_at DESC")
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
s.Select(m)
|
if m.IsTech() {
|
||||||
|
s.Select(m)
|
||||||
|
}
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
s.Select(m, model.USER_UID, arg[0])
|
s.Select(m, model.USER_UID, arg[0])
|
||||||
} else {
|
} else {
|
||||||
s.Select(m.FieldsSetDetail(), model.USER_UID, arg[0], model.PLACE_UID, arg[1])
|
s.Select(m.FieldsSetDetail(), model.PLACE_UID, arg[1])
|
||||||
}
|
}
|
||||||
s.RewriteAppend(m)
|
s.RewriteAppend(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), userPlace{}) }
|
func init() { ice.TeamCtxCmd(userPlace{}) }
|
||||||
|
|
||||||
|
type UserPlace struct{ userPlace }
|
||||||
|
|
||||||
|
func init() { ice.TeamCtxCmd(UserPlace{}) }
|
||||||
|
|
||||||
type UserPlaceRole int
|
type UserPlaceRole int
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
|
|
||||||
_ "shylinux.com/x/community/src/gonganxitong"
|
_ "shylinux.com/x/community/src/gonganxitong"
|
||||||
|
_ "shylinux.com/x/community/src/gonganxitong/express"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() { print(ice.Run()) }
|
func main() { print(ice.Run()) }
|
||||||
|
@ -10,4 +10,4 @@ func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) {
|
|||||||
s.Table.List(m, arg...)
|
s.Table.List(m, arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.Cmd(prefixKey(), {{.Option "name"}}{}) }
|
func init() { ice.TeamCtxCmd({{.Option "name"}}{}) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user