This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-09-27 23:58:12 +08:00
parent 146e346579
commit fb083a6303
46 changed files with 463 additions and 644 deletions

View File

@ -9,12 +9,9 @@ import (
type allow struct { type allow struct {
Table Table
user user
apply apply apply apply
event event
portal Portal
order string `data:"503"` order string `data:"503"`
role string `data:"creator"` role string `data:"leader"`
create string `name:"create apply_uid* place_uid* user_uid* status*"` create string `name:"create apply_uid* place_uid* user_uid* status*"`
reject string `name:"reject" role:"void"` reject string `name:"reject" role:"void"`
approve string `name:"approve" role:"void"` approve string `name:"approve" role:"void"`
@ -23,48 +20,53 @@ type allow struct {
func (s allow) Create(m *ice.Message, arg ...string) { func (s allow) Create(m *ice.Message, arg ...string) {
s.Insert(m.Spawn(), arg...) s.Insert(m.Spawn(), arg...)
s.GetCommandUID(m) m.Option(model.COMMAND_UID, CommandUID(m, m.PrefixKey()))
s.SendMessage(m, m.Option(model.FROM_USER_UID), "") s.SendMessage(m, m.Option(model.FROM_USER_UID), "")
s.sendTemplate(m, m.Trans("role allow process", "权限审批 请处理")) s.SendTemplate(m, "", "", m.Trans("please allow", "权限审批 请处理"))
} }
func (s allow) ApplyQRCode(m *ice.Message, arg ...string) { func (s allow) ApplyQRCode(m *ice.Message, arg ...string) {
m.Cmdy(s.Prefix(m, qrcode{}), m.ActionKey(), arg) m.Cmdy(s.Prefix(m, qrcode{}), m.ActionKey(), arg)
} }
func (s allow) List(m *ice.Message, arg ...string) { func (s allow) List(m *ice.Message, arg ...string) {
s.Tables(m, s.apply, "left join users on applies.user_uid = users.uid").FieldsWithCreatedAT(m, s.apply, s.Tables(m, s.apply).FieldsWithCreatedAT(m, s.apply,
s.AS(s.Key(s, model.UID), model.ALLOW_UID), model.ALLOW_STATUS, s.AS(s.Key(s.apply, model.ROLE), s.Keys(s.UserPlace, model.ROLE)), s.Key(s.apply, model.USER_UID),
model.BEGIN_TIME, model.END_TIME, s.Key(s, model.PLACE_UID), s.Key(s.apply, model.USER_UID), s.AS(s.Key(s.apply, model.ROLE), s.Keys(s.UserPlace, model.ROLE)), model.BEGIN_TIME, model.END_TIME,
s.AS(s.Key(s, model.UID), model.ALLOW_UID), model.ALLOW_STATUS,
) )
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, s.Key(s, model.USER_UID), m.Option(model.USER_UID), s.Key(s, model.PLACE_UID), arg[0]) s.Select(m, s.Key(s, model.PLACE_UID), arg[0], s.Key(s, model.USER_UID), m.Option(model.USER_UID)).Action(s.ApplyQRCode)
if m.Length() == 0 {
m.Cmdy(s.Prefix(m, qrcode{}), s.ApplyQRCode, arg)
return
}
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s, model.USER_UID), m.Option(model.USER_UID), s.Key(s, model.PLACE_UID), arg[0], s.Key(s.apply, model.UID), arg[1]) s.SelectDetail(m, s.Key(s, model.PLACE_UID), arg[0], 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) {
if AllowStatus(kit.Int(value[model.ALLOW_STATUS])) != AllowCreate {
s.DoneMessage(m)
}
})
} else { } else {
return return
} }
if m.Length() == 0 {
m.Cmdy(s.Prefix(m, qrcode{}), s.ApplyQRCode, arg)
return
}
m.Table(func(value ice.Maps) { m.Table(func(value ice.Maps) {
if AllowStatus(kit.Int(value[model.ALLOW_STATUS])) == AllowCreate { if AllowStatus(kit.Int(value[model.ALLOW_STATUS])) == AllowCreate {
m.PushButton(s.Reject, s.Approve) m.PushButton(s.Reject, s.Approve)
} else { } else {
m.PushButton() m.PushButton()
s.DoneMessage(m)
} }
}).Action(s.ApplyQRCode) })
s.RenameAppend(m, model.PLACE_UID, s.Keys(s.Place, model.UID))
s.SelectJoin(m, s.Place, model.NAME, model.TYPE)
s.SelectJoinUser(m) s.SelectJoinUser(m)
s.DisplayBase(m, "") s.DisplayBase(m, "")
} }
func (s allow) Reject(m *ice.Message, arg ...string) { func (s allow) Reject(m *ice.Message, arg ...string) {
s.process(m, AllowCreate, AllowRejected, "❌", m.Trans("role allow rejected", "权限审批 已驳回")) s.process(m, AllowCreate, AllowRejected, "❌", m.Trans("allow rejected", "权限审批 已驳回"))
} }
func (s allow) Approve(m *ice.Message, arg ...string) { func (s allow) Approve(m *ice.Message, arg ...string) {
s.process(m, AllowCreate, AllowApproved, "✅", m.Trans("role allow approved", "权限审批 已通过")) s.process(m, AllowCreate, AllowApproved, "✅", m.Trans("allow approved", "权限审批 已通过"))
} }
func init() { ice.TeamCtxCmd(allow{Table: newTable()}) }
func (s allow) process(m *ice.Message, from, to AllowStatus, icon string, title string) { func (s allow) process(m *ice.Message, from, to AllowStatus, icon string, title string) {
if s.changeStatus(m, from, to); m.IsErr() { if s.changeStatus(m, from, to); m.IsErr() {
return return
@ -73,22 +75,15 @@ func (s allow) process(m *ice.Message, from, to AllowStatus, icon string, title
s.RecordEvent(m, kit.JoinWord(icon, title, kit.Cut(m.Option(model.UID), 6), s.TransRole(m), m.Option(model.USER_NAME)), m.Option(model.UID)) s.RecordEvent(m, kit.JoinWord(icon, title, kit.Cut(m.Option(model.UID), 6), s.TransRole(m), m.Option(model.USER_NAME)), m.Option(model.UID))
s.DoneMessage(m) s.DoneMessage(m)
} }
func (s allow) changeStatus(m *ice.Message, from, to AllowStatus, arg ...string) *ice.Message {
func init() { ice.TeamCtxCmd(allow{Table: newTable()}) }
func (s allow) changeStatus(m *ice.Message, from, todo AllowStatus, arg ...string) *ice.Message {
msg := s.Select(m.Spawn(), model.UID, m.Option(model.ALLOW_UID), model.USER_UID, m.Option(model.USER_UID)) msg := s.Select(m.Spawn(), model.UID, m.Option(model.ALLOW_UID), model.USER_UID, m.Option(model.USER_UID))
if !m.WarnNotFound(msg.Length() == 0, m.Option(model.UID)) { if !m.WarnNotFound(msg.Length() == 0, m.Option(model.ALLOW_UID)) {
if status := AllowStatus(kit.Int(msg.Append(model.STATUS))); !m.WarnNotValid(status != from, status.String()) { if status := AllowStatus(kit.Int(msg.Append(model.STATUS))); !m.WarnNotValid(status != from, status.String()) {
s.Update(m, kit.Dict(model.STATUS, todo), model.UID, m.Option(model.ALLOW_UID)) s.Update(m, kit.Dict(model.STATUS, to), model.UID, m.Option(model.ALLOW_UID), model.USER_UID, m.Option(model.USER_UID))
} }
} }
return msg return msg
} }
func (s allow) sendTemplate(m *ice.Message, info string) *ice.Message {
s.SendTemplate(m, m.Option(model.USER_NAME), m.Append(model.USER_UID), info)
return m
}
type AllowStatus int type AllowStatus int

View File

@ -1,11 +1,9 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) { var USER_PLACE_ROLE = msg.Option("_user_place_role")
var USER_PLACE_ROLE = msg.Option("_user_place_role"), STREET_NAME = msg.Option("_street_name"), ALLOW_STATUS = "allow_status" can.onimport.myView(can, msg, function(value) { return [
can.onimport.myView(can, msg, function(value) { var status = value[ALLOW_STATUS]; return [
{view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, USER_PLACE_ROLE), can.onimport.titleAction(can, value)]}, {view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, USER_PLACE_ROLE), can.onimport.titleAction(can, value)]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value, ALLOW_STATUS)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: [value.begin_time.split(" ")[0], value.end_time.split(" ")[0]]}, {view: html.STATUS, list: [value.begin_time.split(" ")[0], value.end_time.split(" ")[0]]},
{view: html.STATUS, list: [value.city_name, value[STREET_NAME]]},
] }) ] })
}, },
}) })

View File

@ -9,21 +9,17 @@ import (
type apply struct { type apply struct {
Table Table
user user
event event
portal Portal
order string `data:"502"` order string `data:"502"`
role string `data:"creator"` role string `data:"leader"`
create string `name:"create user_place_role*:select begin_time:select@date end_time:select@date" role:"void"` create string `name:"create 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"`
} }
func (s apply) Init(m *ice.Message, arg ...string) { func (s apply) Init(m *ice.Message, arg ...string) {
USER_PLACE_ROLE := s.Keys(s.UserPlace, model.ROLE)
m.Design(s.Create, "", kit.JoinWord(USER_PLACE_ROLE+"*:select", "begin_time:select@date", "end_time:select@date"))
s.Table.Init(m, arg...) s.Table.Init(m, arg...)
place_uid, user_place_role := s.Keys(s.Place, model.UID), s.Keys(s.UserPlace, model.ROLE)
m.Design(s.Create, "", user_place_role+"*:select")
m.Design(s.List, "", kit.JoinWord(place_uid, model.UID, ice.AUTO))
} }
func (s apply) Inputs(m *ice.Message, arg ...string) { func (s apply) Inputs(m *ice.Message, arg ...string) {
s.UserPlace.Inputs(m, arg...) s.UserPlace.Inputs(m, arg...)
@ -31,37 +27,31 @@ func (s apply) Inputs(m *ice.Message, arg ...string) {
func (s apply) Create(m *ice.Message, arg ...string) { func (s apply) Create(m *ice.Message, arg ...string) {
PLACE_UID, USER_PLACE_ROLE := s.Keys(s.Place, model.UID), s.Keys(s.UserPlace, model.ROLE) PLACE_UID, USER_PLACE_ROLE := s.Keys(s.Place, model.UID), s.Keys(s.UserPlace, model.ROLE)
arg = kit.TransArgKeys(arg, PLACE_UID, model.PLACE_UID, USER_PLACE_ROLE, model.ROLE) arg = kit.TransArgKeys(arg, PLACE_UID, model.PLACE_UID, USER_PLACE_ROLE, model.ROLE)
s.Insert(m, kit.Simple(model.PLACE_UID, m.Option(PLACE_UID), arg, m.OptionSimple(model.USER_UID), model.STATUS, ApplyCreate)...) s.Insert(m, kit.Simple(arg, model.PLACE_UID, m.Option(PLACE_UID), m.OptionSimple(model.USER_UID))...)
m.ProcessRewrite(model.UID, m.Result()) m.ProcessRewrite(model.UID, m.Result())
} }
func (s apply) List(m *ice.Message, arg ...string) { func (s apply) List(m *ice.Message, arg ...string) {
s.Tables(m).FieldsWithCreatedAT(m, s, model.APPLY_STATUS, s.FieldsWithCreatedAT(m, s,
s.AS(s.Key(s, model.ROLE), s.Keys(s.UserPlace, model.ROLE)), model.USER_UID, model.APPLY_STATUS,
model.BEGIN_TIME, model.END_TIME, model.PLACE_UID, model.USER_UID, s.AS(s.Key(s, model.ROLE), s.Keys(s.UserPlace, model.ROLE)), model.BEGIN_TIME, model.END_TIME,
) )
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, arg[0]) s.Select(m, model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, model.USER_UID, m.Option(model.USER_UID), model.PLACE_UID, arg[0], s.Key(s, model.UID), arg[1]) s.SelectDetail(m, model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID), model.UID, arg[1])
switch ApplyStatus(kit.Int(m.Append(model.APPLY_STATUS))) { m.Table(func(value ice.Maps) {
case ApplySubmit: switch ApplyStatus(kit.Int(m.Append(model.APPLY_STATUS))) {
m.Echo("请让管理员扫码或等待审批") case ApplyCreate:
m.EchoQRCode(s.portal.Link(m, arg[0], s.Prefix(m, allow{}), arg[1])) m.PushButton(s.Cancel, s.Submit)
case ApplyRejected, ApplyApproved: case ApplySubmit:
s.DoneMessage(m) m.EchoQRCode(s.Link(m, arg[0], s.Prefix(m, allow{}), arg[1])).Echo("请让管理员扫码或等待审批")
} case ApplyRejected, ApplyApproved:
s.DoneMessage(m)
}
})
} else { } else {
return return
} }
m.Table(func(value ice.Maps) {
if ApplyStatus(kit.Int(value[model.APPLY_STATUS])) == ApplyCreate {
m.PushButton(s.Cancel, s.Submit)
} else {
m.PushButton()
}
})
s.RenameAppend(m, model.PLACE_UID, s.Keys(s.Place, model.UID))
s.SelectJoin(m, s.Place, model.NAME, model.TYPE)
s.SelectJoinUser(m) s.SelectJoinUser(m)
s.DisplayBase(m, "") s.DisplayBase(m, "")
} }
@ -77,44 +67,42 @@ func (s apply) Submit(m *ice.Message, arg ...string) {
switch UserPlaceRole(kit.Int(msg.Append(model.ROLE))) { switch UserPlaceRole(kit.Int(msg.Append(model.ROLE))) {
case UserPlaceLandlord: case UserPlaceLandlord:
role = UserPlaceCreator role = UserPlaceCreator
case UserPlaceTenant, UserPlaceAdmin: default:
role = UserPlaceLandlord role = UserPlaceLandlord
} }
msg = m.Cmd(s.UserPlace, s.Select, m.OptionSimple(s.Keys(s.Place, model.UID)), model.ROLE, role) msg = m.Cmd(s.UserPlace, s.Select, m.OptionSimple(s.Keys(s.Place, model.UID)), model.ROLE, role)
if m.WarnNotFound(msg.Length() == 0, role.String()) { if m.WarnNotFound(msg.Length() == 0, role.String()) {
return return
} }
s.PlaceInfo(m)
m.Option(model.FROM_USER_UID, m.Option(model.USER_UID)) m.Option(model.FROM_USER_UID, m.Option(model.USER_UID))
m.Cmd(s.Prefix(m, allow{}), s.Create, model.APPLY_UID, m.Option(model.UID), model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)), msg.AppendSimple(model.USER_UID), model.STATUS, AllowCreate) m.Cmd(s.Prefix(m, allow{}), s.Create, model.APPLY_UID, m.Option(model.UID), model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)), msg.AppendSimple(model.USER_UID), model.STATUS, AllowCreate)
s.RecordEvent(m, kit.JoinWord("🕑", m.Trans("role apply submit", "权限申请 已提交"), kit.Cut(m.Option(model.UID), 6), s.TransRole(m), m.Option(model.USER_NAME)), m.Option(model.UID)) s.RecordEvent(m, kit.JoinWord("🕑", m.Trans("apply submit", "权限申请 已提交"), kit.Cut(m.Option(model.UID), 6), s.TransRole(m), m.Option(model.USER_NAME)), m.Option(model.UID))
s.SendMessage(m, msg.Append(model.USER_UID), m.Option(model.USER_UID)) s.SendMessage(m, msg.Append(model.USER_UID), m.Option(model.USER_UID))
} }
func (s apply) Reject(m *ice.Message, arg ...string) { func (s apply) Reject(m *ice.Message, arg ...string) {
msg := s.changeStatus(m, ApplySubmit, ApplyRejected) msg := s.changeStatus(m, ApplySubmit, ApplyRejected)
s.sendTemplate(msg, m.Trans("role apply rejected", "权限申请 已驳回")) s.SendTemplate(msg, "", "", m.Trans("apply rejected", "权限申请 已驳回"))
} }
func (s apply) Approve(m *ice.Message, arg ...string) { func (s apply) Approve(m *ice.Message, arg ...string) {
msg := s.changeStatus(m, ApplySubmit, ApplyApproved) msg := s.changeStatus(m, ApplySubmit, ApplyApproved)
m.Cmd(s.UserPlace, s.Insert, msg.AppendSimple(model.USER_UID, model.ROLE), s.Keys(s.Place, model.UID), msg.Append(model.PLACE_UID)) if msg.IsErr() {
s.sendTemplate(msg, m.Trans("role apply approved", "权限申请 已通过")) return
}
m.Cmd(s.UserPlace, s.Insert, s.Keys(s.Place, model.UID), msg.Append(model.PLACE_UID), msg.AppendSimple(model.USER_UID, model.ROLE))
s.SendTemplate(msg, "", "", m.Trans("apply approved", "权限申请 已通过"))
} }
func init() { ice.TeamCtxCmd(apply{Table: newTable()}) } func init() { ice.TeamCtxCmd(apply{Table: newTable()}) }
func (s apply) changeStatus(m *ice.Message, from, todo ApplyStatus, arg ...string) *ice.Message { func (s apply) changeStatus(m *ice.Message, from, to ApplyStatus, arg ...string) *ice.Message {
msg := s.Select(m.Spawn(), m.OptionSimple(model.UID)...) msg := s.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)) {
if status := ApplyStatus(kit.Int(msg.Append(model.STATUS))); !m.WarnNotValid(status != from, status.String()) { if status := ApplyStatus(kit.Int(msg.Append(model.STATUS))); !m.WarnNotValid(status != from, status.String()) {
s.Update(m, kit.Dict(model.STATUS, todo), m.OptionSimple(model.UID)...) s.Update(m, kit.Dict(model.STATUS, to), m.OptionSimple(model.UID)...)
} }
} }
return msg return msg
} }
func (s apply) sendTemplate(m *ice.Message, info string) *ice.Message {
s.SendTemplate(m, "", m.Append(model.USER_UID), info)
return m
}
type ApplyStatus int type ApplyStatus int

View File

@ -1,19 +1,16 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) { var USER_PLACE_ROLE = msg.Option("_user_place_role")
var USER_PLACE_ROLE = msg.Option("_user_place_role"), STREET_NAME = msg.Option("_street_name"), APPLY_STATUS = "apply_status" can.onimport.myView(can, msg, function(value) { return [
can.onimport.myView(can, msg, function(value) { var status = value[APPLY_STATUS]; return [
{view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, USER_PLACE_ROLE)]}, {view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, USER_PLACE_ROLE)]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can,value, APPLY_STATUS)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: [value.begin_time.split(" ")[0], value.end_time.split(" ")[0]]}, {view: html.STATUS, list: [value.begin_time.split(" ")[0], value.end_time.split(" ")[0]]},
{view: html.STATUS, list: [value.city_name, value[STREET_NAME]]},
] }) ] })
if (msg.Length() == 0) { can.onappend.style(can, html.FORM) if (msg.Length() == 0) { var target = can.page.Append(can, can._output, [{view: html.CODE, list: [{view: [mdb.INFO, "", "请创建权限申请"]}]}])._target
var target = can.page.Append(can, can._output, [{view: html.CODE, list: [{view: [mdb.INFO, "", "请创建权限申请"]}]}])._target can.runAction({}, mdb.INPUTS, [USER_PLACE_ROLE], function(msg) { msg.Table(function(value) {
can.run({}, [ctx.ACTION, mdb.INPUTS, USER_PLACE_ROLE], function(msg) { msg.Table(function(value) { can.onappend.input(can, {type: html.BUTTON, name: value.name, value: "我是"+can.user.trans(can, value.name, null, "value."+USER_PLACE_ROLE), style: value[USER_PLACE_ROLE] == "2"? html.DANGER: html.NOTICE, onclick: function(event) {
can.onappend.input(can, {type: html.BUTTON, name: value.name, style: value[USER_PLACE_ROLE] == "2"? html.DANGER: html.NOTICE, value: "我是"+can.user.trans(can, value.name, null, "value."+USER_PLACE_ROLE), onclick: function(event) { can.runAction(event, mdb.CREATE, [USER_PLACE_ROLE, value[USER_PLACE_ROLE]])
can.run(can.request(event, {_handle: ice.TRUE}), [ctx.ACTION, mdb.CREATE, USER_PLACE_ROLE, value[USER_PLACE_ROLE]])
}}, "", target) }}, "", target)
}) }) }) }), can.onappend.style(can, html.FORM)
} }
}, },
}) })

View File

@ -10,18 +10,18 @@ import (
type city struct { type city struct {
Table Table
list string `name:"list city_name auto" role:"void"` list string `name:"list city_name auto" role:"void"`
authCreate string `name:"authCreate city_name* city_info company_name*" role:"tech"` authCreate string `name:"authCreate" role:"tech"`
} }
func (s city) Init(m *ice.Message, arg ...string) {
cmdPortal[m.PrefixKey()] = api.GONGANXITONG_PORTAL
}
func (s user) Init(m *ice.Message, arg ...string) { func (s user) Init(m *ice.Message, arg ...string) {
cmdPortal[m.PrefixKey()] = api.GONGANXITONG_PORTAL cmdPortal[m.PrefixKey()] = api.GONGANXITONG_PORTAL
} }
func (s street) Init(m *ice.Message, arg ...string) { func (s street) Init(m *ice.Message, arg ...string) {
cmdPortal[m.PrefixKey()] = api.GONGANXITONG_PORTAL cmdPortal[m.PrefixKey()] = api.GONGANXITONG_PORTAL
} }
func (s city) Init(m *ice.Message, arg ...string) {
cmdPortal[m.PrefixKey()] = api.GONGANXITONG_PORTAL
}
func (s city) FindOrCreateByName(m *ice.Message, arg ...string) { func (s city) FindOrCreateByName(m *ice.Message, arg ...string) {
if msg := m.Cmd(s, s.Select, model.NAME, arg[1]); msg.Length() == 0 { if msg := m.Cmd(s, s.Select, model.NAME, arg[1]); msg.Length() == 0 {
msg := m.Cmd(s, s.Insert, model.NAME, arg[1]) msg := m.Cmd(s, s.Insert, model.NAME, arg[1])
@ -34,13 +34,13 @@ func (s city) List(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
s.Select(m).Action() s.Select(m).Action()
} else if len(arg) == 1 { } else if len(arg) == 1 {
s.Select(m, model.NAME, arg[0]).Action() s.SelectDetail(m, model.NAME, arg[0])
if m.Append(model.AUTH_UID) == "" && m.IsTech() { if m.Append(model.AUTH_UID) == "" && m.IsTech() {
m.EchoInfoButton("请申请城市认证", s.AuthCreate) m.EchoInfoButton(m.Trans("please auth city", "请申请城市认证"), s.AuthCreate)
} }
} }
} }
func (s city) AuthCreate(m *ice.Message, arg ...string) { func (s city) AuthCreate(m *ice.Message, arg ...string) {
s.Table.AuthCreate(m, m.Option(model.CITY_NAME), m.Option(model.COMPANY_NAME), 1, m.Option(model.CITY_NAME), m.Option(model.CITY_INFO), model.NAME, m.Option(model.CITY_NAME)) s.Table.AuthCreate(m, 1, "")
} }
func init() { ice.TeamCtxCmd(city{}) } func init() { ice.TeamCtxCmd(city{}) }

View File

@ -15,26 +15,29 @@ import (
type command struct { type command struct {
Table Table
service service service service
modify string `name:"modify service_uid icon name index"` modify string `name:"modify service_uid index name icon"`
} }
func CommandUID(m *ice.Message, cmd string) string {
return kit.Hashs(m.Option(model.SERVICE_UID), cmd)
}
func (s command) Modify(m *ice.Message, arg ...string) { func (s command) Modify(m *ice.Message, arg ...string) {
uid := kit.Hashs(m.Option(model.SERVICE_UID), m.Option(model.INDEX)) uid := CommandUID(m, m.Option(model.INDEX))
if s.Select(m.Spawn(), model.UID, uid).Length() == 0 { if s.Select(m.Spawn(), model.UID, uid).Length() == 0 {
s.Insert(m, kit.Simple(model.UID, uid, m.OptionSimple(model.SERVICE_UID, model.INDEX))...) s.Insert(m, kit.Simple(arg, model.UID, uid)...)
} else {
s.Update(m, kit.Dict(arg), model.UID, uid)
} }
s.Update(m, kit.Dict(arg), model.UID, uid)
m.SetResult().Echo(uid) m.SetResult().Echo(uid)
} }
func (s command) Autogen(m *ice.Message, arg ...string) { func (s command) Autogen(m *ice.Message, arg ...string) {
space := map[string][]string{} space, portal := map[string][]string{}, map[string][]string{}
portal := map[string][]string{}
s.List(m).Table(func(value ice.Maps) { s.List(m).Table(func(value ice.Maps) {
if strings.HasSuffix(value[model.INDEX], ".allow") { if strings.HasSuffix(value[model.INDEX], ".allow") {
space[value[model.SPACE]] = append(space[value[model.SPACE]], strings.ReplaceAll(value[model.INDEX], ".allow", ".portal")) space[value[model.SPACE]] = append(space[value[model.SPACE]], strings.ReplaceAll(value[model.INDEX], ".allow", ".portal"))
} }
space[value[model.SPACE]] = append(space[value[model.SPACE]], value[model.INDEX]) space[value[model.SPACE]] = append(space[value[model.SPACE]], value[model.INDEX])
portal[value["portal"]] = append(portal[value["portal"]], value[model.INDEX]) portal[value[model.PORTAL]] = append(portal[value[model.PORTAL]], value[model.INDEX])
}) })
for p, v := range space { for p, v := range space {
nfs.Create(m.Message, "src/api/"+p+".go", func(w io.Writer) { nfs.Create(m.Message, "src/api/"+p+".go", func(w io.Writer) {
@ -44,48 +47,35 @@ func (s command) Autogen(m *ice.Message, arg ...string) {
} }
}) })
} }
return
nfs.Create(m.Message, "src/api/space.go", func(w io.Writer) { nfs.Create(m.Message, "src/api/space.go", func(w io.Writer) {
fmt.Fprintf(w, "package api\n\n") fmt.Fprintf(w, "package api\n\n")
fmt.Fprintf(w, "var Space = map[string]string{\n") fmt.Fprintf(w, "var Space = map[string]string{\n")
for p, v := range space { defer fmt.Fprintf(w, "}\n")
for _, v := range v { for space, cmd := range space {
fmt.Fprintf(w, "\"%s\": \"%s\",\n", v, p) kit.For(cmd, func(cmd string) { fmt.Fprintf(w, "\"%s\": \"%s\",\n", cmd, space) })
}
} }
fmt.Fprintf(w, "}\n")
}) })
nfs.Create(m.Message, "src/api/portal.go", func(w io.Writer) { nfs.Create(m.Message, "src/api/portal.go", func(w io.Writer) {
fmt.Fprintf(w, "package api\n\n") fmt.Fprintf(w, "package api\n\n")
fmt.Fprintf(w, "var Portal = map[string]string{\n") fmt.Fprintf(w, "var Portal = map[string]string{\n")
for p, v := range portal { defer fmt.Fprintf(w, "}\n")
for _, v := range v { for portal, cmd := range portal {
fmt.Fprintf(w, "\"%s\": \"%s\",\n", v, p) kit.For(cmd, func(cmd string) { fmt.Fprintf(w, "\"%s\": \"%s\",\n", cmd, portal) })
}
} }
fmt.Fprintf(w, "}\n")
}) })
} }
func (s command) Cache(m *ice.Message, arg ...string) *ice.Message { func (s command) Cache(m *ice.Message, arg ...string) {
kit.For(cmdPortal, func(k, v string) { kit.For(cmdPortal, func(k, v string) { m.Push(model.SPACE, cmdSpace[k]).Push(model.PORTAL, v).Push(model.INDEX, k) })
m.Push(model.SPACE, cmdSpace[k])
m.Push(model.PORTAL, v)
m.Push(model.INDEX, k)
})
m.Sort("space,portal,index") m.Sort("space,portal,index")
return m
} }
func (s command) List(m *ice.Message, arg ...string) *ice.Message { func (s command) List(m *ice.Message, arg ...string) *ice.Message {
s.Tables(m, s.service).Fields(m, s.Tables(m, s.service).Fields(m, s.Key(s, model.UPDATED_AT),
s.Key(s, model.UPDATED_AT), s.Key(s, model.INDEX), s.Key(s, model.INDEX), s.AS(s.Key(s.service, model.INDEX), model.PORTAL), s.AS(model.NODENAME, model.SPACE),
s.AS(s.Key(s.service, model.INDEX), "portal"), ).Orders(m, "`space`,`index`").Limit(m, 300).Select(m).Action(s.Cache, s.Autogen)
s.AS(model.NODENAME, model.SPACE),
).Orders(m, "`space`,`index`").Limit(m, 300)
s.Select(m).Action(s.Autogen, s.Cache)
return m return m
} }
func init() { ice.TeamCtxCmd(command{}) }
var cmdPortal = map[string]string{} var cmdPortal = map[string]string{}
var cmdSpace = map[string]string{} var cmdSpace = map[string]string{}
func init() { ice.TeamCtxCmd(command{}) }

View File

@ -12,6 +12,14 @@ func (s comment) Create(m *ice.Message, arg ...string) {
s.Insert(m, append(arg, m.OptionSimple(model.MARKET_UID, model.USER_UID)...)...) s.Insert(m, append(arg, m.OptionSimple(model.MARKET_UID, model.USER_UID)...)...)
} }
func (s comment) List(m *ice.Message, arg ...string) { func (s comment) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
s.Select(m, model.MARKET_UID, arg[0])
} else if len(arg) == 2 {
s.SelectDetail(m, model.MARKET_UID, arg[0], model.UID, arg[1])
} else {
return
}
s.SelectJoinUser(m)
} }
func init() { ice.TeamCtxCmd(comment{}) } func init() { ice.TeamCtxCmd(comment{}) }

View File

@ -45,13 +45,13 @@ type Table struct {
} }
func (s Table) LoadTrans(m *ice.Message, arg ...string) { func (s Table) LoadTrans(m *ice.Message, arg ...string) {
base := kit.FileLine(1, 100) p := kit.FileLine(1, 100)
if m.PrefixKey() != api.GONGANXITONG_PORTAL { if m.PrefixKey() != api.GONGANXITONG_PORTAL {
ice.LoadTrans(m.Spawn(kit.Dict("_template", path.Join(path.Dir(base), "portal.json"))).Message, m.CommandKey(), m.GetCommand().Command) ice.LoadTrans(m.Spawn(kit.Dict("_template", path.Join(path.Dir(p), "portal.json"))).Message, m.CommandKey(), m.GetCommand().Command)
} }
h := ctx.GetCmdFile(m.Message, m.PrefixKey()) h := ctx.GetCmdFile(m.Message, m.PrefixKey())
kit.If(strings.HasPrefix(h, "/p/src/"), func() { h = strings.TrimPrefix(h, "/p/") }) kit.If(strings.HasPrefix(h, "/p/src/"), func() { h = strings.TrimPrefix(h, "/p/") })
if path.Dir(h) != path.Dir(base) && m.CommandKey() != web.PORTAL { if path.Dir(h) != path.Dir(p) && m.CommandKey() != web.PORTAL {
ice.LoadTrans(m.Spawn(kit.Dict("_template", path.Join(path.Dir(h), "portal.json"))).Message, m.CommandKey(), m.GetCommand().Command) ice.LoadTrans(m.Spawn(kit.Dict("_template", path.Join(path.Dir(h), "portal.json"))).Message, m.CommandKey(), m.GetCommand().Command)
} }
} }
@ -59,12 +59,8 @@ func (s Table) Init(m *ice.Message, arg ...string) {
s.LoadTrans(m, arg...) s.LoadTrans(m, arg...)
s.Table.Init(m, arg...) s.Table.Init(m, arg...)
} }
func (s Table) BeforeMigrate(m *ice.Message, arg ...string) {
s.Table.BeforeMigrate(m, arg...)
}
func (s Table) AfterMigrate(m *ice.Message, arg ...string) { func (s Table) AfterMigrate(m *ice.Message, arg ...string) {
kit.If(m.GetCommand().Icon, func() { Portal{}.Show(m) }) kit.If(m.GetCommand().Icon, func() { Portal{}.Show(m) })
s.Table.AfterMigrate(m, arg...)
} }
func (s Table) Inputs(m *ice.Message, arg ...string) { func (s Table) Inputs(m *ice.Message, arg ...string) {
switch arg[0] { switch arg[0] {
@ -115,7 +111,7 @@ func (s Table) ValueModel(m *ice.Message, action ice.Any, arg ...string) *ice.Me
defer m.Options(db.MODEL, m.Configv(db.MODEL)).Set(ice.MSG_OPTION, db.MODEL) defer m.Options(db.MODEL, m.Configv(db.MODEL)).Set(ice.MSG_OPTION, db.MODEL)
defer m.Options(db.TARGET, kit.Select(m.CommandKey(), m.Config(db.MODELS))).Set(ice.MSG_OPTION, db.TARGET) defer m.Options(db.TARGET, kit.Select(m.CommandKey(), m.Config(db.MODELS))).Set(ice.MSG_OPTION, db.TARGET)
kit.For(db.CommonField, func(k string) { arg = kit.TransArgKeys(arg, s.Keys(m.Option(db.TARGET), k), k) }) kit.For(db.CommonField, func(k string) { arg = kit.TransArgKeys(arg, s.Keys(m.Option(db.TARGET), k), k) })
return m.Options(arg).Cmdy(m.Prefix(web.PORTAL), action, arg) return m.Options(arg).Cmdy(s.PrefixPortal(m), action, arg)
} }
func (s Table) ValueCreate(m *ice.Message, arg ...string) { func (s Table) ValueCreate(m *ice.Message, arg ...string) {
s.ValueModel(m, s.ValueCreate, arg...) s.ValueModel(m, s.ValueCreate, arg...)
@ -131,15 +127,14 @@ func (s Table) ValueModify(m *ice.Message, arg ...string) {
s.RecordEventWithName(m, "") s.RecordEventWithName(m, "")
} }
func (s Table) ValueList(m *ice.Message, arg []string, fields ...ice.Any) *ice.Message { func (s Table) ValueList(m *ice.Message, arg []string, fields ...ice.Any) *ice.Message {
defer s.SelectJoinUser(m)
if len(arg) > 0 { if len(arg) > 0 {
kit.If(len(fields) == 0, func() { fields = kit.TransArgs(kit.Split(m.Config(mdb.FIELDS), ",", ",")) }) kit.If(len(fields) == 0, func() { fields = kit.TransArgs(kit.Split(m.Config(mdb.FIELDS), ",", ",")) })
defer m.Options(db.FIELDS, fields).Set(ice.MSG_OPTION, db.FIELDS) defer m.Options(db.FIELDS, fields).Set(ice.MSG_OPTION, db.FIELDS)
} }
if s.ValueModel(m, s.ValueList, arg...); len(arg) > 0 { if s.ValueModel(m, s.ValueList, arg...); len(arg) == 1 {
s.Button(m, "") s.Button(m, "")
} }
return m return s.SelectJoinUser(m)
} }
func (s Table) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) } func (s Table) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) }
func (s Table) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) } func (s Table) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) }
@ -147,24 +142,28 @@ func (s Table) Modify(m *ice.Message, arg ...string) { s.ValueModify(m, arg...)
func (s Table) List(m *ice.Message, arg ...string) *ice.Message { func (s Table) List(m *ice.Message, arg ...string) *ice.Message {
return s.ValueList(m, arg) return s.ValueList(m, arg)
} }
func (s Table) FieldsDefault(m *ice.Message, arg ...string) *ice.Message { func (s Table) FieldsDefault(m *ice.Message, arg ...string) Table {
if m.Option(mdb.SELECT) == "" { if m.Option(mdb.SELECT) == "" {
if fields := m.Config(mdb.FIELDS); fields != "" { if fields := m.Config(mdb.FIELDS); fields != "" {
s.Table.FieldsWithCreatedAT(m, kit.Select(m.CommandKey(), m.Config(db.MODELS)), kit.TransArgs(kit.Split(fields, ",", ","))...) s.Table.FieldsWithCreatedAT(m, kit.Select(m.CommandKey(), m.Config(db.MODELS)), kit.TransArgs(kit.Split(fields, ",", ","))...)
} }
} }
return m return s
}
func (s Table) LeftJoinValue(m *ice.Message, value, place ice.Any, arg ...string) string {
model := s.ToLower(kit.TypeName(value))
models := s.TableName(model)
_model := s.ToLower(kit.TypeName(place))
_models := s.TableName(_model)
return kit.Format("LEFT JOIN %s ON %s.%s_uid = %s.uid AND %s.user_uid = '%s'", models, models, _model, _models, models, m.Option("user_uid"))
} }
func (s Table) Select(m *ice.Message, arg ...string) *ice.Message { func (s Table) Select(m *ice.Message, arg ...string) *ice.Message {
s.FieldsDefault(m) s.FieldsDefault(m).Table.Select(m, arg...)
s.Table.Select(m, arg...)
kit.If(m.Length() > 0, func() { s.UserPlaceInit(m) }) kit.If(m.Length() > 0, func() { s.UserPlaceInit(m) })
return m return m
} }
func (s Table) SelectDetail(m *ice.Message, arg ...string) *ice.Message { func (s Table) SelectDetail(m *ice.Message, arg ...string) *ice.Message {
s.FieldsDefault(m) return s.FieldsDefault(m).Table.SelectDetail(m, arg...)
s.Table.SelectDetail(m, arg...)
return m
} }
func (s Table) SelectJoinUser(m *ice.Message, arg ...string) *ice.Message { func (s Table) SelectJoinUser(m *ice.Message, arg ...string) *ice.Message {
kit.If(len(arg) == 0, func() { arg = append(arg, model.NAME, model.AVATAR) }) kit.If(len(arg) == 0, func() { arg = append(arg, model.NAME, model.AVATAR) })
@ -174,18 +173,30 @@ func (s Table) SelectJoinCity(m *ice.Message, arg ...string) *ice.Message {
kit.If(len(arg) == 0, func() { arg = append(arg, model.NAME) }) kit.If(len(arg) == 0, func() { arg = append(arg, model.NAME) })
return s.SelectJoin(m, city{}, arg...) return s.SelectJoin(m, city{}, arg...)
} }
func (s Table) SelectJoinService(m *ice.Message, arg ...string) *ice.Message {
kit.If(len(arg) == 0, func() { arg = append(arg, model.NODENAME, model.INDEX) })
return s.SelectJoin(m, service{}, arg...)
}
func (s Table) SelectJoinAuth(m *ice.Message, arg ...string) *ice.Message { func (s Table) SelectJoinAuth(m *ice.Message, arg ...string) *ice.Message {
kit.If(len(arg) == 0, func() { arg = append(arg, model.NAME, model.AUTH_TYPE, model.AUTH_STATUS, model.DASHBOARD_UID) }) kit.If(len(arg) == 0, func() { arg = append(arg, model.NAME, model.AUTH_TYPE, model.AUTH_STATUS, model.DASHBOARD_UID) })
defer s.SaveBack(m, ice.MSG_USERPOD, ice.MSG_USERROLE)() defer s.SaveBack(m, ice.MSG_USERPOD, ice.MSG_USERROLE)()
return s.SelectJoin(m, s.findSpaceCmd(m, api.RENZHENGSHOUQUAN_AUTH), arg...) return s.SelectJoin(m, s.findSpaceCmd(m, api.RENZHENGSHOUQUAN_AUTH), arg...)
} }
func (s Table) RenameAppend(m *ice.Message, arg ...string) Table { func (s Table) SelectJoinRecent(m *ice.Message, PLACE_UID string, arg ...string) *ice.Message {
m.RenameAppend(arg...) if m.Length() == 0 {
return s return m
}
kit.If(len(arg) == 0, func() { arg = append(arg, model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME) })
list := []string{}
m.Table(func(value ice.Maps) { kit.If(value[PLACE_UID], func(v string) { list = kit.AddUniq(list, v) }) })
msg := m.Spawn()
recents := msg.CmdMap(recent{}, s.SelectList, model.PLACE_UID, list, model.PLACE_UID)
m.Info("what %v", recents)
m.Table(func(value ice.Maps) {
recent := recents[value[PLACE_UID]]
kit.For(arg, func(k string) { m.Push(k, recent[k]) })
})
return m
}
func (s Table) SelectJoinService(m *ice.Message, arg ...string) *ice.Message {
kit.If(len(arg) == 0, func() { arg = append(arg, model.NODENAME, model.INDEX) })
return s.SelectJoin(m, service{}, arg...)
} }
func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
m.RewriteAppend(func(value, key string, index int) string { m.RewriteAppend(func(value, key string, index int) string {
@ -215,6 +226,18 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
}) })
return m return m
} }
func (s Table) Update(m *ice.Message, data ice.Map, arg ...string) {
if len(arg) == 0 {
arg = append(arg, model.UID, kit.Select(m.Option(model.UID), m.Option(s.Keys(m.CommandKey(), model.UID))))
}
s.Table.Update(m, data, arg...)
}
func (s Table) UpdateAuth(m *ice.Message, arg ...string) {
s.Update(m, kit.Dict(model.AUTH_UID, arg[0]), arg[1:]...)
}
func (s Table) UpdateField(m *ice.Message, arg ...string) {
s.Update(m, kit.Dict(arg[0], arg[1]), arg[2:]...)
}
func (s Table) UploadUpdate(m *ice.Message, field, uid string, arg ...string) { func (s Table) UploadUpdate(m *ice.Message, field, uid string, arg ...string) {
if m.IsErr() { if m.IsErr() {
return return
@ -229,16 +252,6 @@ func (s Table) UploadCreate(m *ice.Message, field, uid string, arg ...string) {
p := m.UploadSave(path.Join(nfs.USR, kit.Select(field, m.Option("field")), uid) + nfs.PS) p := m.UploadSave(path.Join(nfs.USR, kit.Select(field, m.Option("field")), uid) + nfs.PS)
s.Create(m, kit.Select(m.Option("field"), field), p, model.UID, uid) s.Create(m, kit.Select(m.Option("field"), field), p, model.UID, uid)
} }
func (s Table) Update(m *ice.Message, data ice.Map, arg ...string) {
data[model.OPERATOR] = m.Option(model.USER_UID)
s.Table.Update(m, data, arg...)
}
func (s Table) UpdateAuth(m *ice.Message, arg ...string) {
s.Update(m, kit.Dict(model.AUTH_UID, arg[0]), arg[1:]...)
}
func (s Table) UpdateField(m *ice.Message, arg ...string) {
s.Update(m, kit.Dict(arg[0], arg[1]), arg[2:]...)
}
func (s Table) ChangeStatus(m *ice.Message, place_uid, uid string, from, to int, arg ...string) *ice.Message { func (s Table) ChangeStatus(m *ice.Message, place_uid, uid string, from, to int, arg ...string) *ice.Message {
msg := s.ValueList(m.Spawn(), []string{place_uid, uid}, model.STATUS) msg := s.ValueList(m.Spawn(), []string{place_uid, uid}, model.STATUS)
if !m.WarnNotValid(msg.Length() == 0 || kit.Int(msg.Append(mdb.STATUS)) != int(from)) { if !m.WarnNotValid(msg.Length() == 0 || kit.Int(msg.Append(mdb.STATUS)) != int(from)) {
@ -249,7 +262,6 @@ func (s Table) ChangeStatus(m *ice.Message, place_uid, uid string, from, to int,
func (s Table) CheckRole(m *ice.Message, arg ...string) { func (s Table) CheckRole(m *ice.Message, arg ...string) {
role := UserPlaceRole(s.UserPlaceRole(m)) role := UserPlaceRole(s.UserPlaceRole(m))
m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserPlaceCreator.String())...), role.String()) m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserPlaceCreator.String())...), role.String())
m.Option(model.USER_ROLE, kit.Format(role))
} }
func (s Table) IsVisitor(m *ice.Message) bool { func (s Table) IsVisitor(m *ice.Message) bool {
if role := kit.Int(m.Option(model.USER_ROLE)); role == 0 { if role := kit.Int(m.Option(model.USER_ROLE)); role == 0 {
@ -270,19 +282,16 @@ func (s Table) IsWorker(m *ice.Message) bool {
return false return false
} }
func (s Table) UserPlaceRole(m *ice.Message) int { func (s Table) UserPlaceRole(m *ice.Message) int {
return kit.Int(m.Cmdy(s.Prefix(m, Portal{}), s.UserPlaceRole).Option(model.USER_ROLE)) return kit.Int(m.Cmdy(s.PrefixPortal(m), s.UserPlaceRole).Option(model.USER_ROLE))
} }
func (s Table) UserPlaceInit(m *ice.Message, arg ...string) { func (s Table) UserPlaceInit(m *ice.Message, arg ...string) {
if m.Option(model.PLACE_INIT) == "" || m.PrefixKey() != m.Option(ice.MSG_INDEX) { if m.Option(model.PLACE_INIT) == "" || m.PrefixKey() != m.Option(ice.MSG_INDEX) {
return return
} }
m.Cmd(s.Prefix(m, Portal{}), "placeCmd", "addCount", model.INIT, 1, m.Option(model.PLACE_UID), m.Option(model.PLACE_INIT)) m.Cmd(s.PrefixPortal(m), Portal{}.PlaceCmd, "addCount", model.INIT, 1, m.Option(model.PLACE_UID), m.Option(model.PLACE_INIT))
}
func (s Table) PlaceInfo(m *ice.Message) {
m.Cmdy(s.Prefix(m, Portal{}), s.PlaceInfo)
} }
func (s Table) RecordEvent(m *ice.Message, info string, arg ...string) { func (s Table) RecordEvent(m *ice.Message, info string, arg ...string) {
m.Cmd(s.Prefix(m, Portal{}), s.RecordEvent, info, arg) m.Cmd(s.PrefixPortal(m), s.RecordEvent, info, arg)
} }
func (s Table) RecordEventWithName(m *ice.Message, info string, arg ...string) { func (s Table) RecordEventWithName(m *ice.Message, info string, arg ...string) {
uid := kit.Select(m.Result(), m.Option(model.UID)) uid := kit.Select(m.Result(), m.Option(model.UID))
@ -296,11 +305,21 @@ func (s Table) RecordEventWithName(m *ice.Message, info string, arg ...string) {
info = "🕑 " + info info = "🕑 " + info
} }
}) })
s.RecordEvent(m, kit.JoinWord(info, kit.Cut(uid, 6), kit.Select(m.Option(model.TITLE), m.Option(model.NAME))), uid) s.RecordEvent(m, kit.JoinWord(info, kit.Cut(uid, 6), kit.Select(m.Option(model.NAME), m.Option(model.TITLE))), uid)
} }
func (s Table) MemberList(m *ice.Message, arg ...string) { func (s Table) MemberList(m *ice.Message, arg ...string) {
m.Cmdy(s.Prefix(m, member{}), arg) m.Cmdy(s.Prefix(m, member{}), arg)
} }
func (s Table) CityList(m *ice.Message, arg ...string) *ice.Message {
m.Cmdy(s.Prefix(m, city{}), arg).RenameAppend(model.NAME, model.CITY_NAME)
return m
}
func (s Table) AuthCreate(m *ice.Message, authType int, fromUID string, arg ...string) {
s.AutoCmdy(m, api.RENZHENGSHOUQUAN_PORTAL, Portal{}.PlaceCreate,
model.AUTH_NAME, kit.Select(m.Option(model.NAME), arg, 0), model.AUTH_INFO, kit.Select(m.Option(model.INFO), arg, 1),
model.AUTH_TYPE, authType, model.FROM_UID, kit.Select(ice.AUTO, fromUID))
s.Update(m, kit.Dict(m.OptionSimple(model.AUTH_UID)), arg...)
}
func (s Table) DashboardUpdate(m *ice.Message, arg ...string) { func (s Table) DashboardUpdate(m *ice.Message, arg ...string) {
if m.IsErr() { if m.IsErr() {
return return
@ -313,29 +332,16 @@ func (s Table) MarketInsert(m *ice.Message, arg ...string) {
func (s Table) ServiceList(m *ice.Message, arg ...string) *ice.Message { func (s Table) ServiceList(m *ice.Message, arg ...string) *ice.Message {
return m.Cmd(s.Prefix(m, service{}), arg) return m.Cmd(s.Prefix(m, service{}), arg)
} }
func (s Table) CityList(m *ice.Message, arg ...string) *ice.Message {
m.Cmdy(web.TEAM_GONGANXITONG_CITY, arg).RenameAppend(model.NAME, model.CITY_NAME)
return m
}
func (s Table) AuthCreate(m *ice.Message, cityName, companyName string, authType int, authName, authInfo string, arg ...string) {
m.Cmdy(api.RENZHENGSHOUQUAN_PORTAL, Portal{}.PlaceCreate, model.CITY_NAME, cityName, model.COMPANY_NAME, companyName,
model.AUTH_TYPE, authType, model.AUTH_NAME, authName, model.AUTH_INFO, authInfo)
s.Update(m, kit.Dict(m.OptionSimple(model.AUTH_UID)), arg...)
}
func (s Table) GetCommandUID(m *ice.Message) { func (s Table) GetCommandUID(m *ice.Message) {
m.Options(m.Cmd(s.Prefix(m, Portal{}), Portal{}.CommandSelect, m.PrefixKey()).AppendSimple(model.COMMAND_UID)) m.Option(model.COMMAND_UID, CommandUID(m, m.PrefixKey()))
} }
func (s Table) GetCommands(m *ice.Message, key string, arg ...string) []string { func (s Table) SendMessage(m *ice.Message, from, to string, arg ...string) {
m.Option(model.UID, kit.Select(m.Option(model.UID), m.Result()))
return kit.Simple(m.OptionSimple(key), ctx.ARGS, kit.Join(arg), m.OptionSimple(model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME))
}
func (s Table) SendMessage(m *ice.Message, from_user_uid, to_user_uid string, arg ...string) {
if m.IsErr() { if m.IsErr() {
return return
} }
m.Spawn(ice.Maps{db.DB: ""}).Cmd(s.Prefix(m, message{}), s.Create, m.Spawn(ice.Maps{db.DB: ""}).Cmd(s.Prefix(m, message{}), s.Create,
model.FROM_USER_UID, kit.Select(m.Option(model.USER_UID), from_user_uid), model.TO_USER_UID, kit.Select(m.Option(model.USER_UID), to_user_uid), model.FROM_USER_UID, kit.Select(m.Option(model.USER_UID), from), model.TO_USER_UID, kit.Select(m.Option(model.USER_UID), to),
model.DETAIL_NAME, kit.Select(m.Option(model.NAME), m.Option(model.TITLE)), s.GetCommands(m, model.COMMAND_UID, arg...), m.OptionSimple(model.COMMAND_UID), model.ARGS, kit.Join(arg),
) )
} }
func (s Table) DoneMessage(m *ice.Message, arg ...string) { func (s Table) DoneMessage(m *ice.Message, arg ...string) {
@ -347,7 +353,7 @@ func (s Table) SendTemplate(m *ice.Message, from, to, title string, arg ...strin
if m.IsErr() { if m.IsErr() {
return return
} }
m.Cmd(s.Prefix(m, Portal{}), s.SendTemplate, m.PrefixKey(), from, to, title, arg) m.Cmd(s.PrefixPortal(m), s.SendTemplate, m.PrefixKey(), from, to, title, arg)
} }
func (s Portal) SendTemplate(m *ice.Message, arg ...string) { func (s Portal) SendTemplate(m *ice.Message, arg ...string) {
name := kit.Select("", arg, 4) name := kit.Select("", arg, 4)
@ -356,7 +362,7 @@ func (s Portal) SendTemplate(m *ice.Message, arg ...string) {
} }
uid, place_uid := kit.Select(m.Option(model.UID), arg, 5), kit.Select("", arg, 6) uid, place_uid := kit.Select(m.Option(model.UID), arg, 5), kit.Select("", arg, 6)
kit.If(place_uid == "", func() { place_uid = m.Option(s.Keys(s.Place, model.UID)) }) kit.If(place_uid == "", func() { place_uid = m.Option(s.Keys(s.Place, model.UID)) })
link := s.Link(m, place_uid, arg[0], uid) link := m.Cmdx("", s.Link, place_uid, arg[0], uid)
s.AutoCmd(m, user{}, s.SendTemplate, arg[1], arg[2], link, kit.JoinWord(m.Option(model.PORTAL_NAME), arg[3]), name, kit.Cut(uid, 6)) s.AutoCmd(m, user{}, s.SendTemplate, arg[1], arg[2], link, kit.JoinWord(m.Option(model.PORTAL_NAME), arg[3]), name, kit.Cut(uid, 6))
} }
func (s Table) Button(m *ice.Message, info string, arg ...ice.Any) *ice.Message { func (s Table) Button(m *ice.Message, info string, arg ...ice.Any) *ice.Message {
@ -412,26 +418,6 @@ func (s Table) Prefix(m *ice.Message, target ice.Any) string {
func (s Table) PrefixPortal(m *ice.Message) string { func (s Table) PrefixPortal(m *ice.Message) string {
return m.Prefix(kit.TypeName(Portal{})) return m.Prefix(kit.TypeName(Portal{}))
} }
func (s Table) ProcessPodCmd(m, msg *ice.Message, arg ...string) *ice.Message {
m.ProcessPodCmd(msg.Append(web.SPACE), msg.Append(ctx.INDEX), kit.Split(msg.Append(ctx.ARGS)))
m.Push("field.option", kit.Format(kit.Dict(arg)))
m.RewriteAppend(func(value, key string, index int) string {
kit.If(key == ctx.STYLE, func() { value = html.OUTPUT })
// kit.If(key == web.SPACE, func() { value = m.Appendv("_space")[index] })
return value
})
if msg.Append(web.SPACE) != "" {
m.Optionv(ice.FIELD_PREFIX, ctx.ACTION, ctx.RUN, kit.Join(kit.Slice(kit.Split(msg.Append(ctx.INDEX), "."), 0, -1), ".")+".portal", ctx.ACTION, ctx.RUN, msg.Append(ctx.INDEX))
}
return m
}
func (s Table) spaceCmd(m *ice.Message, space string, arg ...ice.Any) *ice.Message {
if space == ice.Info.NodeName {
return m.Cmd(arg...)
} else {
return m.Cmd(append([]ice.Any{web.SPACE, kit.Keys(ice.OPS, space)}, arg...)...)
}
}
func (s Table) findSpaceCmd(m *ice.Message, cmd ice.Any) ice.Any { func (s Table) findSpaceCmd(m *ice.Message, cmd ice.Any) ice.Any {
cmds := ice.GetTypeKey(cmd) cmds := ice.GetTypeKey(cmd)
if space, ok := cmdSpace[cmds]; ok && space != ice.Info.NodeName { if space, ok := cmdSpace[cmds]; ok && space != ice.Info.NodeName {
@ -454,8 +440,19 @@ func (s Table) AutoCmdy(m *ice.Message, arg ...ice.Any) *ice.Message {
func (s Table) AutoCmd(m *ice.Message, arg ...ice.Any) *ice.Message { func (s Table) AutoCmd(m *ice.Message, arg ...ice.Any) *ice.Message {
return m.Cmd(append([]ice.Any{s.findSpaceCmd(m, arg[0])}, arg[1:]...)...) return m.Cmd(append([]ice.Any{s.findSpaceCmd(m, arg[0])}, arg[1:]...)...)
} }
func (s Table) ProcessPodCmd(m, msg *ice.Message, arg ...string) *ice.Message {
m.ProcessPodCmd(msg.Append(web.SPACE), msg.Append(ctx.INDEX), kit.Split(msg.Append(ctx.ARGS)))
m.RewriteAppend(func(value, key string, index int) string {
if key == "style" {
value = "output"
}
return value
})
m.Push("field.option", kit.Format(kit.Dict(arg)))
return m
}
func (s Table) Link(m *ice.Message, arg ...string) string { func (s Table) Link(m *ice.Message, arg ...string) string {
return Portal{}.Link(m, arg...) return m.Cmdx(s.PrefixPortal(m), s.Link, arg)
} }
type Tables struct{ Table } type Tables struct{ Table }
@ -483,8 +480,8 @@ func PortalCmd(portal ice.Any) {
_, cmd := ice.Cmd(kit.Keys(p, name), data) _, cmd := ice.Cmd(kit.Keys(p, name), data)
cmd.RawHand = path.Join(path.Dir(h), name+".go") cmd.RawHand = path.Join(path.Dir(h), name+".go")
cmd.Actions[ice.CTX_INIT].Hand = icebergs.MergeHand(func(m *icebergs.Message, arg ...string) { cmd.Actions[ice.CTX_INIT].Hand = icebergs.MergeHand(func(m *icebergs.Message, arg ...string) {
mdb.Config(m, db.DOMAIN, kit.PathName(1))
m.Design(mdb.LIST, "", kit.JoinWord(table.Keys(table.Place, model.UID), model.UID, ice.AUTO)) m.Design(mdb.LIST, "", kit.JoinWord(table.Keys(table.Place, model.UID), model.UID, ice.AUTO))
mdb.Config(m, db.DOMAIN, kit.PathName(1))
}, cmd.Actions[ice.CTX_INIT].Hand) }, cmd.Actions[ice.CTX_INIT].Hand)
} }
cmd("portal", portal) cmd("portal", portal)

View File

@ -4,7 +4,7 @@ Volcanos(chat.ONIMPORT, {
PLACE_TYPE || can.core.List(msg.append, function(key) { can.base.endWith(key, "_type") && (PLACE_TYPE = key), can.base.endWith(key, "_role") && (USER_PLACE_ROLE = key) }) PLACE_TYPE || can.core.List(msg.append, function(key) { can.base.endWith(key, "_type") && (PLACE_TYPE = key), can.base.endWith(key, "_role") && (USER_PLACE_ROLE = key) })
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list:[value.title||value.name||value.user_name, can.onimport.textView(can, value, PLACE_TYPE), can.onimport.textView(can, value, USER_PLACE_ROLE)]}, {view: html.TITLE, list:[value.title||value.name||value.user_name, can.onimport.textView(can, value, PLACE_TYPE), can.onimport.textView(can, value, USER_PLACE_ROLE)]},
{view: html.STATUS, list: [value.city_name, value.street_name, value.company_name||value.place_name]}, {view: html.STATUS, list: [value.city_name, value.company_name||value.street_name, value.place_name]},
{view: html.STATUS, list: [value.uid && value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, {view: html.STATUS, list: [value.uid && value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]},
value.address && {view: html.STATUS, list: [value.address]}, value.address && {view: html.STATUS, list: [value.address]},
value.content && {view: html.OUTPUT, list: [value.content]}, value.content && {view: html.OUTPUT, list: [value.content]},

View File

@ -8,8 +8,9 @@ import (
type domain struct { type domain struct {
Table Table
create string `name:"create name* info" role:"void"` create string `name:"create name* info" role:"tech"`
remove string `name:"remove" role:"void"` remove string `name:"remove" role:"tech"`
list string `name:"list domain_uid auto" role:"void"`
} }
func (s domain) Create(m *ice.Message, arg ...string) { s.Insert(m, arg...) } func (s domain) Create(m *ice.Message, arg ...string) { s.Insert(m, arg...) }
@ -17,13 +18,13 @@ func (s domain) Remove(m *ice.Message, arg ...string) { s.Delete(m, arg...) }
func (s domain) List(m *ice.Message, arg ...string) { func (s domain) List(m *ice.Message, arg ...string) {
s.Fields(m, model.UID, model.NAME) s.Fields(m, model.UID, model.NAME)
if len(arg) == 0 { if len(arg) == 0 {
s.Select(m).RenameAppend(model.UID, model.DOMAIN_UID) s.Select(m).RenameAppend(model.UID, model.DOMAIN_UID).Action()
} else if len(arg) == 1 { } else if len(arg) == 1 {
s.Select(m) s.SelectDetail(m, model.UID, arg[0])
} else if len(arg) == 2 { }
s.Select(m, model.UID, arg[1]) if m.IsTech() {
m.PushAction(s.Remove).Action(s.Create)
} }
m.PushAction(s.Remove)
} }
func init() { ice.TeamCtxCmd(domain{}) } func init() { ice.TeamCtxCmd(domain{}) }

View File

@ -2,38 +2,31 @@ package gonganxitong
import ( import (
"shylinux.com/x/ice" "shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/ctx"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model" "shylinux.com/x/community/src/gonganxitong/model"
) )
type event struct { type event struct {
Table Table
user user
order string `data:"504"` order string `data:"504"`
role string `data:"creator"` role string `data:"leader"`
} }
func (s event) List(m *ice.Message, arg ...string) { func (s event) List(m *ice.Message, arg ...string) {
s.Tables(m, s.user).FieldsWithCreatedAT(m, s, s.FieldsWithCreatedAT(m, s, model.USER_UID, model.INFO)
s.Key(s, model.INFO),
s.Key(s, model.CITY_NAME), s.Key(s, model.STREET_NAME), s.Key(s, model.PLACE_NAME),
model.USER_NAME, model.USER_AVATAR,
)
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.PLACE_UID, arg[0]).Action() s.Select(m, model.PLACE_UID, arg[0]).Action()
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, model.PLACE_UID, arg[0], s.Key(s, model.UID), arg[1]) s.SelectDetail(m, model.PLACE_UID, arg[0], model.UID, arg[1])
} else { } else {
return return
} }
s.SelectJoinUser(m)
s.DisplayBase(m, "") s.DisplayBase(m, "")
} }
func init() { ice.TeamCtxCmd(event{Table: newTable()}) } func init() { ice.TeamCtxCmd(event{Table: newTable()}) }
func (s event) Record(m *ice.Message, info string, arg ...string) { func (s event) Record(m *ice.Message, info string, arg ...string) {
m.Cmd(s.Prefix(m, s), s.Insert, m.OptionSimple(model.COMMAND_UID, model.PLACE_UID, model.USER_UID), model.INFO, info, m.Cmd(s.Prefix(m, s), s.Insert, m.OptionSimple(model.PLACE_UID, model.USER_UID), model.INFO, info)
m.OptionSimple(model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME), model.OPERATE, m.ActionKey(), ctx.ARGS, kit.Join(arg, ","))
} }

View File

@ -25,18 +25,12 @@ type market struct {
} }
func (s market) Create(m *ice.Message, arg ...string) { func (s market) Create(m *ice.Message, arg ...string) {
s.Insert(m, append(arg, m.OptionSimple( s.Insert(m, append(arg, m.OptionSimple(model.PLACE_UID, model.USER_UID, model.COMMAND_UID, model.ARGS)...)...)
model.CITY_NAME, model.STREET_NAME, model.PLACE_NAME,
model.ARGS, model.COMMAND_UID, model.PLACE_UID, model.USER_UID,
)...)...)
} }
func (s market) List(m *ice.Message, arg ...string) { func (s market) List(m *ice.Message, arg ...string) {
s.Tables(m, s.domain, s.command, s.service, s.Tables(m, s.command, s.service, s.LeftJoinValue(m, s.thumb, s), s.LeftJoinValue(m, s.favor, s)).FieldsWithCreatedAT(m, s,
kit.Format("LEFT JOIN thumbs ON thumbs.market_uid = markets.uid AND thumbs.user_uid = '%s'", m.Option(model.USER_UID)), s.Key(s, model.USER_UID), model.PLACE_UID, model.SERVICE_NAME, model.TITLE, model.CONTENT,
kit.Format("LEFT JOIN favors ON favors.market_uid = favors.uid AND favors.user_uid = '%s'", m.Option(model.USER_UID)), model.THUMB_COUNT, model.COMMENT_COUNT, model.FAVOR_COUNT, model.SHARE_COUNT, model.THUMB_STATUS, model.FAVOR_STATUS,
).FieldsWithCreatedAT(m, s, s.Key(s, model.USER_UID), model.TITLE, model.CONTENT,
s.Key(s, model.CITY_NAME), s.Key(s, model.STREET_NAME), s.Key(s, model.PLACE_NAME), model.SERVICE_NAME,
model.THUMB_STATUS, model.FAVOR_STATUS, model.THUMB_COUNT, model.COMMENT_COUNT, model.FAVOR_COUNT, model.SHARE_COUNT,
s.AS(model.NODENAME, model.SPACE), s.Key(s.command, model.INDEX), model.ARGS, s.AS(model.NODENAME, model.SPACE), s.Key(s.command, model.INDEX), model.ARGS,
) )
if len(arg) < 2 { if len(arg) < 2 {
@ -52,9 +46,10 @@ func (s market) List(m *ice.Message, arg ...string) {
} else { } else {
return return
} }
s.SelectJoinRecent(m, model.PLACE_UID)
s.SelectJoinUser(m, model.NAME, model.AVATAR, model.AUTH_UID) s.SelectJoinUser(m, model.NAME, model.AVATAR, model.AUTH_UID)
s.SelectJoinAuth(m) s.SelectJoinAuth(m)
s.Display(m, "") s.DisplayBase(m, "")
} }
func (s market) ThumbToggle(m *ice.Message, arg ...string) { func (s market) ThumbToggle(m *ice.Message, arg ...string) {
m.OptionDefault(model.MARKET_UID, m.Option(model.UID)) m.OptionDefault(model.MARKET_UID, m.Option(model.UID))

View File

@ -14,15 +14,10 @@ Volcanos(chat.ONIMPORT, {
_data: function(can, msg) { can.onmotion.clear(can, can.ui.list) _data: function(can, msg) { can.onmotion.clear(can, can.ui.list)
can.onimport.itemcards(can, msg, function(value) { return [ can.onimport.itemcards(can, msg, function(value) { return [
{view: html.STATUS, list: [ {view: html.STATUS, list: [
{text: [value.user_name, "", aaa.USERNAME], onclick: function(event) { can.onkeymap.prevent(event) {text: [value.user_name, "", aaa.USERNAME]}, can.onimport.authView(can, value), can.onimport.timeView(can, value),
can.onimport.myStory(can, {index: "web.team.gonganxitong.profile", args: [value.user_uid]})
}},
can.onimport.authView(can, value), can.onimport.timeView(can, value),
]}, ]},
{view: html.STATUS, list: [ {view: html.STATUS, list: [
{text: [value.service_name.split(" ")[0], "", "service"]}, {text: [value.street_name, "", "street"]}, {text: [value.place_name, "", "place"]}, {text: [value.service_name.split(" ")[0], "", "service"]},
{text: [value.place_name, "", "place"]},
{text: ["@"+value.street_name, "", "street"]},
]}, ]},
{view: html.OUTPUT, list: [value.title]}, {view: html.OUTPUT, list: [value.title]},
{view: html.OUTPUT, list: [value.content]}, {view: html.OUTPUT, list: [value.content]},

View File

@ -1,6 +1 @@
$output>div.item.myself div.title span { $output>div.item.myself div.title span { font-weight:bold; }
font-weight:bold;
}
$output>div.item.disabled div.title span {
// color:var(--disable-fg-color);
}

View File

@ -15,22 +15,19 @@ type member struct {
func (s member) Remove(m *ice.Message, arg ...string) { func (s member) Remove(m *ice.Message, arg ...string) {
if s.IsLeader(m) { if s.IsLeader(m) {
m.Cmdy(s.UserPlace, s.Delete, s.Option(m)) m.Cmdy(s.UserPlace, s.Delete, s.option(m))
} }
} }
func (s member) Enable(m *ice.Message, arg ...string) { func (s member) Enable(m *ice.Message, arg ...string) {
if s.IsLeader(m) { if s.IsLeader(m) {
m.Cmdy(s.UserPlace, s.UpdateField, model.STATUS, MemberNormal, s.Option(m)) m.Cmdy(s.UserPlace, s.UpdateField, model.STATUS, MemberNormal, s.option(m))
} }
} }
func (s member) Disable(m *ice.Message, arg ...string) { func (s member) Disable(m *ice.Message, arg ...string) {
if s.IsLeader(m) { if s.IsLeader(m) {
m.Cmdy(s.UserPlace, s.UpdateField, model.STATUS, MemberDisabled, s.Option(m)) m.Cmdy(s.UserPlace, s.UpdateField, model.STATUS, MemberDisabled, s.option(m))
} }
} }
func (s member) Option(m *ice.Message, arg ...string) []string {
return m.OptionSimple(s.Keys(s.Place, model.UID), model.UID)
}
func (s member) List(m *ice.Message, arg ...string) { func (s member) List(m *ice.Message, arg ...string) {
user_uid, isLeader := m.Option(model.USER_UID), s.IsLeader(m) user_uid, isLeader := m.Option(model.USER_UID), s.IsLeader(m)
s.FieldsWithCreatedAT(m, s.UserPlace, model.USER_UID, s.Keys(s.UserPlace, model.ROLE), s.AS(s.Key(s.UserPlace, model.STATUS), model.MEMBER_STATUS)) s.FieldsWithCreatedAT(m, s.UserPlace, model.USER_UID, s.Keys(s.UserPlace, model.ROLE), s.AS(s.Key(s.UserPlace, model.STATUS), model.MEMBER_STATUS))
@ -41,8 +38,6 @@ func (s member) List(m *ice.Message, arg ...string) {
} else { } else {
return return
} }
s.SelectJoinUser(m, model.NAME, model.INFO, model.AVATAR, model.AUTH_UID)
s.SelectJoinAuth(m)
m.Table(func(value ice.Maps) { m.Table(func(value ice.Maps) {
if user_uid == value[model.USER_UID] { if user_uid == value[model.USER_UID] {
m.Push("who", "myself") m.Push("who", "myself")
@ -63,11 +58,17 @@ func (s member) List(m *ice.Message, arg ...string) {
m.PushButton() m.PushButton()
} }
}) })
s.Display(m, "").DisplayCSS("") s.SelectJoinUser(m, model.NAME, model.INFO, model.AVATAR, model.AUTH_UID)
s.SelectJoinAuth(m)
s.DisplayBase(m, "").DisplayCSS("")
} }
func init() { ice.TeamCtxCmd(member{Tables: newTables()}) } func init() { ice.TeamCtxCmd(member{Tables: newTables()}) }
func (s member) option(m *ice.Message, arg ...string) []string {
return m.OptionSimple(s.Keys(s.Place, model.UID), model.UID)
}
type MemberStatus int type MemberStatus int
const ( const (

View File

@ -1,19 +1,19 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { var USER_PLACE_ROLE = msg.Option("_user_place_role") _init: function(can, msg) {
if (msg.IsDetail()) {
msg.Option("_share_title", msg.Append("user_name"))
}
var USER_PLACE_ROLE = msg.Option("_user_place_role")
can.onimport.myView(can, msg, function(value) { value._style = [value.who, value.member_status] can.onimport.myView(can, msg, function(value) { value._style = [value.who, value.member_status]
return [ return [
{view: html.TITLE, list: [ {view: html.TITLE, list: [value.user_name,
value.user_name,
can.onimport.authView(can, value), can.onimport.textView(can, value, USER_PLACE_ROLE), can.onimport.authView(can, value), can.onimport.textView(can, value, USER_PLACE_ROLE),
can.onimport.titleAction(can, value), can.onimport.titleAction(can, value),
]}, ]},
{view: html.STATUS, list: [ {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value),
value.uid.slice(0, 6), can.onimport.timeView(can, value),
value.member_status != "normal" && can.onimport.textView(can, value, "member_status"), value.member_status != "normal" && can.onimport.textView(can, value, "member_status"),
]}, ]},
{view: html.STATUS, list: [ {view: html.STATUS, list: [value.user_info]},
value.user_info,
]},
] ]
}) })
}, },

View File

@ -2,7 +2,6 @@ package gonganxitong
import ( import (
"shylinux.com/x/ice" "shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/ctx"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model" "shylinux.com/x/community/src/gonganxitong/model"
@ -14,6 +13,7 @@ type message struct {
service service service service
order string `data:"902"` order string `data:"902"`
create string `name:"create from_user_uid to_user_uid"` create string `name:"create from_user_uid to_user_uid"`
remove string `name:"remove" role:"void"`
read string `name:"read" role:"void"` read string `name:"read" role:"void"`
done string `name:"done" role:"void"` done string `name:"done" role:"void"`
sticky string `name:"sticky" role:"void"` sticky string `name:"sticky" role:"void"`
@ -21,8 +21,9 @@ type message struct {
} }
func (s message) Create(m *ice.Message, arg ...string) { func (s message) Create(m *ice.Message, arg ...string) {
kit.If(m.Option(ctx.ARGS) == "", func() { arg = append(arg, model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))
arg = append(arg, ctx.ARGS, kit.JoinFields(m.Option(s.Keys(s.Place, model.UID)), m.Option(model.UID))) kit.If(m.Option(model.ARGS) == "", func() {
arg = append(arg, model.ARGS, kit.JoinFields(m.Option(s.Keys(s.Place, model.UID)), m.Option(model.UID)))
}) })
s.Insert(m, arg...) s.Insert(m, arg...)
} }
@ -31,20 +32,18 @@ func (s message) Remove(m *ice.Message, arg ...string) {
} }
func (s message) List(m *ice.Message, arg ...string) { func (s message) List(m *ice.Message, arg ...string) {
s.Tables(m, s.command, s.service).FieldsWithCreatedAT(m, s, s.Tables(m, s.command, s.service).FieldsWithCreatedAT(m, s,
model.FROM_USER_UID, s.Key(s, model.PLACE_NAME), s.Key(s.command, model.NAME), model.SCORE, model.MESSAGE_STATUS, model.FROM_USER_UID, model.COMMAND_NAME, model.MESSAGE_STATUS, model.SCORE,
s.AS(model.NODENAME, model.SPACE), s.Key(s.command, model.INDEX), model.OPERATE, model.ARGS, model.PLACE_UID, model.SERVICE_NAME,
s.Key(s, model.CITY_NAME), s.Key(s, model.STREET_NAME), model.SERVICE_NAME, s.Key(s, model.DETAIL_NAME), s.AS(model.NODENAME, model.SPACE), s.Key(s.command, model.INDEX), model.ARGS,
) )
if len(arg) < 2 { if len(arg) < 2 {
s.Orders(m, s.Desc(model.SCORE), s.Desc(model.CREATED_AT))
args := []string{model.TO_USER_UID, m.Option(model.USER_UID)} args := []string{model.TO_USER_UID, m.Option(model.USER_UID)}
kit.If(m.Option(model.MESSAGE_STATUS), func(p string) { kit.If(m.Option(model.MESSAGE_STATUS), func(p string) {
for i, v := range MessageStatusList { for i, v := range MessageStatusList {
if v == p { kit.If(v == p, func() { args = append(args, model.STATUS, kit.Format(i)) })
args = append(args, model.STATUS, kit.Format(i))
}
} }
}) })
s.Orders(m, s.Desc(model.SCORE), s.Desc(model.CREATED_AT))
s.Select(m, args...).Table(func(value ice.Maps) { s.Select(m, args...).Table(func(value ice.Maps) {
button := []ice.Any{} button := []ice.Any{}
if value[model.SCORE] == "0" { if value[model.SCORE] == "0" {
@ -63,6 +62,7 @@ func (s message) List(m *ice.Message, arg ...string) {
m.PushButton(button...) m.PushButton(button...)
}).Action() }).Action()
m.RenameAppend(model.FROM_USER_UID, model.USER_UID) m.RenameAppend(model.FROM_USER_UID, model.USER_UID)
s.SelectJoinRecent(m, model.PLACE_UID)
s.SelectJoinUser(m) s.SelectJoinUser(m)
s.DisplayBase(m, "") s.DisplayBase(m, "")
} else if len(arg) == 2 { } else if len(arg) == 2 {
@ -85,12 +85,13 @@ func (s message) Sticky(m *ice.Message, arg ...string) {
func (s message) UnSticky(m *ice.Message, arg ...string) { func (s message) UnSticky(m *ice.Message, arg ...string) {
s.update(m, ice.Map{model.SCORE: 0}) s.update(m, ice.Map{model.SCORE: 0})
} }
func init() { ice.TeamCtxCmd(message{Table: newTable()}) }
func (s message) update(m *ice.Message, data ice.Map, arg ...ice.Any) { func (s message) update(m *ice.Message, data ice.Map, arg ...ice.Any) {
s.Table.Update(m, data, kit.Simple(model.TO_USER_UID, m.Option(model.USER_UID), m.OptionSimple(model.UID), arg)...) s.Table.Update(m, data, kit.Simple(model.TO_USER_UID, m.Option(model.USER_UID), m.OptionSimple(model.UID), arg)...)
} }
func init() { ice.TeamCtxCmd(message{Table: newTable()}) }
type MessageStatus int type MessageStatus int
const ( const (

View File

@ -5,9 +5,7 @@ Volcanos(chat.ONIMPORT, {
can.onimport.myView(can, msg, function(value) { var args = can.core.Split(value.args) can.onimport.myView(can, msg, function(value) { var args = can.core.Split(value.args)
value.icons = value.user_avatar||value.icons; if (value.score > 0) { value._style = ["sticky"] } value.icons = value.user_avatar||value.icons; if (value.score > 0) { value._style = ["sticky"] }
return [ return [
{view: html.TITLE, list: [value.place_name, value.name, value.detail_name||(args[1]||"").slice(0, 6), {view: html.TITLE, list: [value.place_name, value.command_name, value.detail||(args[1]||"").slice(0, 6), can.onimport.textView(can, value)]},
value.message_status != "done" && can.onimport.textView(can, value, MESSAGE_STATUS)
]},
{view: html.STATUS, list: [value.city_name, value.street_name, value.service_name]}, {view: html.STATUS, list: [value.city_name, value.street_name, value.service_name]},
{view: html.STATUS, list: [can.onimport.timeView(can, value), value.user_name]}, {view: html.STATUS, list: [can.onimport.timeView(can, value), value.user_name]},
value.info && {view: html.OUTPUT, list: [value.info]}, value.info && {view: html.OUTPUT, list: [value.info]},

View File

@ -3,26 +3,22 @@ package model
import "shylinux.com/x/mysql-story/src/db" import "shylinux.com/x/mysql-story/src/db"
const ( const (
ID = "id"
UID = "uid" UID = "uid"
NAME = "name" NAME = "name"
INFO = "info" INFO = "info"
TYPE = "type" TYPE = "type"
ROLE = "role" ROLE = "role"
STATUS = "status" STATUS = "status"
LEVEL = "level"
SCORE = "score"
TITLE = "title" TITLE = "title"
CONTENT = "content" CONTENT = "content"
CREATOR = "creator" AVATAR = "avatar"
OPERATOR = "operator" BACKGROUND = "background"
CREATED_AT = "created_at" CREATED_AT = "created_at"
UPDATED_AT = "updated_at" UPDATED_AT = "updated_at"
DELETED_AT = "deleted_at"
USER_UID = "user_uid" USER_UID = "user_uid"
USER_ROLE = "user_role"
USER_NAME = "user_name" USER_NAME = "user_name"
USER_INFO = "user_info" USER_INFO = "user_info"
USER_ROLE = "user_role"
USER_AVATAR = "user_avatar" USER_AVATAR = "user_avatar"
USER_BACKGROUND = "user_background" USER_BACKGROUND = "user_background"
USER_PLACE_ROLE = "user_place_role" USER_PLACE_ROLE = "user_place_role"
@ -62,11 +58,9 @@ const (
ALLOW_UID = "allow_uid" ALLOW_UID = "allow_uid"
ALLOW_STATUS = "allow_status" ALLOW_STATUS = "allow_status"
EVENT_UID = "event_uid" EVENT_UID = "event_uid"
MARKET_UID = "market_uid"
DOMAIN_UID = "domain_uid" DOMAIN_UID = "domain_uid"
DOMAIN_NAME = "domain_name" DOMAIN_NAME = "domain_name"
PORTAL_NAME = "portal_name" MARKET_UID = "market_uid"
DETAIL_NAME = "detail_name"
COMMAND_UID = "command_uid" COMMAND_UID = "command_uid"
COMMAND_ICON = "command_icon" COMMAND_ICON = "command_icon"
COMMAND_NAME = "command_name" COMMAND_NAME = "command_name"
@ -83,9 +77,6 @@ const (
SHARE_COUNT = "share_count" SHARE_COUNT = "share_count"
THUMB_STATUS = "thumb_status" THUMB_STATUS = "thumb_status"
FAVOR_STATUS = "favor_status" FAVOR_STATUS = "favor_status"
CLIENT_UID = "client_uid"
CLIENT_NAME = "client_name"
CLIENT_TYPE = "client_type"
FROM_UID = "from_uid" FROM_UID = "from_uid"
FROM_USER_UID = "from_user_uid" FROM_USER_UID = "from_user_uid"
TO_USER_UID = "to_user_uid" TO_USER_UID = "to_user_uid"
@ -93,20 +84,21 @@ const (
END_TIME = "end_time" END_TIME = "end_time"
OPEN_ID = "open_id" OPEN_ID = "open_id"
EMAIL = "email" EMAIL = "email"
AVATAR = "avatar"
BACKGROUND = "background"
ADDRESS = "address" ADDRESS = "address"
PORTAL = "portal"
PORTAL_NAME = "portal_name"
NODE_NAME = "node_name" NODE_NAME = "node_name"
NODENAME = "nodename" NODENAME = "nodename"
NODETYPE = "nodetype"
SPACE = "space" SPACE = "space"
OPERATE = "operate"
INDEX = "index" INDEX = "index"
QUERY = "query"
VALUE = "value"
ARGS = "args" ARGS = "args"
INIT = "init" INIT = "init"
QUERY = "query"
VALUE = "value"
SCORE = "score"
LEVEL = "level"
UNIT = "unit" UNIT = "unit"
PORTAL = "portal"
) )
type Sess struct { type Sess struct {
@ -117,12 +109,8 @@ type Sess struct {
} }
type User struct { type User struct {
db.ModelWithAuth db.ModelWithAuth
OpenID string `gorm:"type:char(32);index"` OpenID string `gorm:"type:char(32);index"`
Email string `gorm:"type:varchar(64)"` Email string `gorm:"type:varchar(64)"`
Name string `gorm:"type:varchar(32)"`
Info string `gorm:"type:varchar(255)"`
Avatar string `gorm:"type:varchar(255)"`
Background string `gorm:"type:varchar(255)"`
} }
type UserPlace struct { type UserPlace struct {
db.ModelUserPlace db.ModelUserPlace
@ -140,10 +128,7 @@ type Street struct {
} }
type City struct { type City struct {
db.ModelWithAuth db.ModelWithAuth
Name string `gorm:"type:varchar(64);index"` Name string `gorm:"type:varchar(64);index"`
Info string `gorm:"type:varchar(255)"`
Avatar string `gorm:"type:varchar(255)"`
Background string `gorm:"type:varchar(255)"`
} }
type Apply struct { type Apply struct {
@ -163,11 +148,10 @@ type Allow struct {
Status uint8 `gorm:"default:0"` Status uint8 `gorm:"default:0"`
} }
type Event struct { type Event struct {
db.ModelCommand db.ModelWithUID
CommandUID string `gorm:"type:char(32)"` 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)"` Info string `gorm:"type:varchar(255)"`
Info string `gorm:"type:varchar(255)"`
} }
type Notice struct { type Notice struct {
db.ModelContent db.ModelContent
@ -181,21 +165,21 @@ type Setting struct {
Name string `gorm:"type:varchar(64)"` Name string `gorm:"type:varchar(64)"`
Value string `gorm:"type:varchar(255)"` Value string `gorm:"type:varchar(255)"`
} }
type Domain struct { type Domain struct {
db.ModelNameInfo db.ModelNameInfo
} }
type Market struct { type Market struct {
db.ModelCommand db.ModelContent
CommandUID string `gorm:"type:char(32)"`
DomainUID string `gorm:"type:char(32);index"` DomainUID string `gorm:"type:char(32);index"`
PlaceUID string `gorm:"type:char(32)"` PlaceUID string `gorm:"type:char(32)"`
UserUID string `gorm:"type:char(32)"` UserUID string `gorm:"type:char(32)"`
Title string `gorm:"type:varchar(64)"` CommandUID string `gorm:"type:char(32)"`
Content string Args string `gorm:"type:varchar(128)"`
ThumbCount int `gorm:"default:0"` ThumbCount int `gorm:"default:0"`
CommentCount int `gorm:"default:0"` CommentCount int `gorm:"default:0"`
FavorCount int `gorm:"default:0"` FavorCount int `gorm:"default:0"`
ShareCount int `gorm:"default:0"` ShareCount int `gorm:"default:0"`
} }
type Thumb struct { type Thumb struct {
db.ModelWithUID db.ModelWithUID
@ -205,10 +189,10 @@ type Thumb struct {
} }
type Comment struct { type Comment struct {
db.ModelWithUID db.ModelWithUID
MarketUID string `gorm:"type:char(32);index"` MarketUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`
CommentUID string `gorm:"type:char(32)"` FromUID string `gorm:"type:char(32)"`
Content string Content string
} }
type Favor struct { type Favor struct {
db.ModelWithUID db.ModelWithUID
@ -216,29 +200,34 @@ type Favor struct {
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`
Status uint `gorm:"default:0"` Status uint `gorm:"default:0"`
} }
type Command struct {
db.ModelWithUID
ServiceUID string `gorm:"type:char(32)"`
Index string `gorm:"type:varchar(64)"`
Name string `gorm:"type:varchar(32)"`
Icon string `gorm:"type:varchar(128)"`
}
type Message struct { type Message struct {
db.ModelCommand db.ModelWithUID
CommandUID string `gorm:"type:char(32)"` PlaceUID string `gorm:"type:char(32)"`
FromUserUID string `gorm:"type:char(32)"` FromUserUID string `gorm:"type:char(32)"`
ToUserUID string `gorm:"type:char(32);index"` ToUserUID string `gorm:"type:char(32);index"`
CommandUID string `gorm:"type:char(32)"`
Args string `gorm:"type:varchar(128)"`
Status uint `gorm:"default:0"` Status uint `gorm:"default:0"`
Score uint `gorm:"default:0"` Score uint `gorm:"default:0"`
} }
type Recent struct { type Recent struct {
db.ModelCommand 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);index"`
ServiceUID string `gorm:"type:char(32)"` ServiceUID string `gorm:"type:char(32)"`
PlaceName string `gorm:"type:varchar(64)"`
StreetName string `gorm:"type:varchar(64)"`
CityName string `gorm:"type:varchar(64)"`
AuthStatus uint8 `gorm:"default:0"` AuthStatus uint8 `gorm:"default:0"`
Score uint8 `gorm:"default:0"` Score uint8 `gorm:"default:0"`
} }
type Command struct {
db.ModelWithUID
ServiceUID string `gorm:"type:char(32);index:idx_service"`
Index string `gorm:"type:varchar(64);index:idx_service"`
Name string `gorm:"type:varchar(32)"`
Icon string `gorm:"type:varchar(128)"`
}
type Service struct { type Service struct {
db.ModelWithUID db.ModelWithUID
Icon string `gorm:"type:varchar(128)"` Icon string `gorm:"type:varchar(128)"`
@ -248,16 +237,14 @@ type Service struct {
Version string `gorm:"type:varchar(32)"` Version string `gorm:"type:varchar(32)"`
Domain string `gorm:"type:varchar(255)"` Domain string `gorm:"type:varchar(255)"`
Portal string `gorm:"type:varchar(255)"` Portal string `gorm:"type:varchar(255)"`
Nodename string `gorm:"type:varchar(32)"`
Nodetype string `gorm:"type:varchar(32)"` Nodetype string `gorm:"type:varchar(32)"`
Nodename string `gorm:"type:varchar(32)"`
Pathname string `gorm:"type:varchar(255)"` Pathname string `gorm:"type:varchar(255)"`
Hostname string `gorm:"type:varchar(32)"` Hostname string `gorm:"type:varchar(32)"`
} }
type Support struct { type Support struct {
db.ModelContent db.ModelContent
PlaceUID string `gorm:"type:char(32);index"` PlaceUID string `gorm:"type:char(32);index"`
FromUserUID string `gorm:"type:char(32);index"`
ToUserUID string `gorm:"type:char(32);index"`
} }
func init() { func init() {
@ -265,6 +252,6 @@ func init() {
&Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, &City{}, &Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, &City{},
&Apply{}, &Allow{}, &Event{}, &Notice{}, &Setting{}, &Apply{}, &Allow{}, &Event{}, &Notice{}, &Setting{},
&Domain{}, &Market{}, &Thumb{}, &Comment{}, &Favor{}, &Domain{}, &Market{}, &Thumb{}, &Comment{}, &Favor{},
&Message{}, &Recent{}, &Command{}, &Service{}, &Support{}, &Command{}, &Message{}, &Recent{}, &Service{}, &Support{},
) )
} }

View File

@ -10,15 +10,12 @@ import (
type notice struct { type notice struct {
Table Table
order string `data:"505"` order string `data:"505"`
role string `data:"leader"`
fields string `data:"title,content,user_uid"` fields string `data:"title,content,user_uid"`
create string `name:"create title* content*" role:"landlord,teacher,leader"` create string `name:"create title* content*" role:"leader"`
remove string `name:"remove" role:"landlord,teacher,leader"` remove string `name:"remove" role:"leader"`
} }
func (s notice) Init(m *ice.Message, arg ...string) {
s.Table.Init(m, arg...)
m.Design(s.List, "", kit.JoinWord(s.Keys(s.Place, model.UID), model.UID, ice.AUTO))
}
func (s notice) Create(m *ice.Message, arg ...string) { func (s notice) Create(m *ice.Message, arg ...string) {
m.Option(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID))) m.Option(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))
s.Insert(m, kit.Simple(arg, m.OptionSimple(model.PLACE_UID, model.USER_UID))...) s.Insert(m, kit.Simple(arg, m.OptionSimple(model.PLACE_UID, model.USER_UID))...)
@ -37,13 +34,13 @@ func (s notice) List(m *ice.Message, arg ...string) {
} else { } else {
return return
} }
s.SelectJoinUser(m)
kit.If(s.IsLeader(m), func() { kit.If(s.IsLeader(m), func() {
m.PushAction(s.Remove) m.PushAction(s.Remove)
s.Button(m, "") s.Button(m, "")
}, func() { }, func() {
m.Action() m.Action()
}) })
s.SelectJoinUser(m)
} }
func init() { ice.TeamCtxCmd(notice{Table: newTable()}) } func init() { ice.TeamCtxCmd(notice{Table: newTable()}) }

View File

@ -25,14 +25,12 @@ type Portal struct {
service service service service
export string `data:"true"` export string `data:"true"`
short string `data:"index"` short string `data:"index"`
field string `data:"time,icons,name,index,order,enable,init,type,role,view,command_uid"` field string `data:"time,icons,name,index,order,enable,init,type,role,view"`
create string `name:"create index name icons"` create string `name:"create index name icons"`
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 city_name* street_name* place_name* place_type*:select address" icon:"bi bi-plus-square-dotted" role:"void"` placeCreate string `name:"placeCreate city_name* street_name* place_name* place_type*:select address" icon:"bi bi-plus-square-dotted" role:"void"`
placeRemove string `name:"placeRemove" role:"void"` placeRemove string `name:"placeRemove" role:"void"`
placeAuth string `name:"placeAuth" role:"void"` placeAuth string `name:"placeAuth" role:"void"`
command string `name:"command" role:"void"`
run string `name:"run" role:"void"`
} }
func (s Portal) Init(m *ice.Message, arg ...string) { func (s Portal) Init(m *ice.Message, arg ...string) {
@ -72,9 +70,9 @@ func (s Portal) Inputs(m *ice.Message, arg ...string) {
func (s Portal) Command(m *ice.Message, arg ...string) { func (s Portal) Command(m *ice.Message, arg ...string) {
if cmdPortal[arg[0]] != "" && cmdPortal[arg[0]] != m.PrefixKey() { if cmdPortal[arg[0]] != "" && cmdPortal[arg[0]] != m.PrefixKey() {
s.AutoCmdy(m, cmdPortal[arg[0]], m.ActionKey(), arg) s.AutoCmdy(m, cmdPortal[arg[0]], m.ActionKey(), arg)
return } else {
ctx.Command(m.Message, arg...)
} }
ctx.Command(m.Message, arg...)
} }
func (s Portal) Run(m *ice.Message, arg ...string) { func (s Portal) Run(m *ice.Message, arg ...string) {
if cmdPortal[arg[0]] != "" && cmdPortal[arg[0]] != m.PrefixKey() { if cmdPortal[arg[0]] != "" && cmdPortal[arg[0]] != m.PrefixKey() {
@ -82,30 +80,29 @@ func (s Portal) Run(m *ice.Message, arg ...string) {
return return
} }
s.DisplayBase(m, "common.js") s.DisplayBase(m, "common.js")
m.OptionDefault(model.SERVICE_UID, ServiceUID(m)) m.Option(model.SERVICE_UID, ServiceUID(m))
m.OptionDefault(model.COMMAND_UID, s.Hash.List(m.Spawn(), arg[0]).Append(model.COMMAND_UID)) m.Option(model.COMMAND_UID, CommandUID(m, arg[0]))
m.Search(arg[0], func(key string, cmd *ice.Command) { m.Search(arg[0], func(key string, cmd *ice.Command) {
sub, role := "", cmd.Role role := cmd.Role
if len(arg) > 1 && arg[1] == ctx.ACTION { if len(arg) > 1 && arg[1] == ctx.ACTION {
if action, ok := cmd.Actions[arg[2]]; ok { if action, ok := cmd.Actions[arg[2]]; ok {
sub, role = arg[2], action.Role role = action.Role
} }
} else if len(arg) > 1 { } else if len(arg) > 1 {
if action, ok := cmd.Actions[arg[1]]; ok { if action, ok := cmd.Actions[arg[1]]; ok {
sub, role = arg[1], action.Role role = action.Role
} else { } else {
m.Option(s.Keys(s.Place, model.UID), arg[1]) m.Option(s.Keys(s.Place, model.UID), arg[1])
} }
} }
s.UserPlaceRole(m) if s.UserPlaceRole(m); kit.IsIn(role, "", aaa.VOID, aaa.TECH, aaa.ROOT) {
if kit.IsIn(role, "", aaa.VOID, aaa.TECH, aaa.ROOT) {
kit.If(!ctx.PodCmd(m.Message, arg) && aaa.Right(m.Message, arg), func() { m.Cmdy(arg) }) kit.If(!ctx.PodCmd(m.Message, arg) && aaa.Right(m.Message, arg), func() { m.Cmdy(arg) })
} else { } else {
if !m.Cmdy(arg[0], s.CheckRole, kit.Split(role)).IsErr() { if !m.Cmdy(s.Place, s.CheckRole, kit.Split(role)).IsErr() {
m.Cmdy(arg) m.Cmdy(arg)
} }
} }
if sub != mdb.INPUTS && kit.IndexOf(arg, mdb.INPUTS) == -1 { if kit.IndexOf(arg, mdb.INPUTS) == -1 {
s.Place.RewriteAppend(m) s.Place.RewriteAppend(m)
} }
}) })
@ -115,7 +112,7 @@ func (s Portal) List(m *ice.Message, arg ...string) {
s.Hash.List(m, arg...).PushAction(mdb.DETAIL, s.Hash.Remove).SortInt(mdb.ORDER) s.Hash.List(m, arg...).PushAction(mdb.DETAIL, s.Hash.Remove).SortInt(mdb.ORDER)
return return
} }
m.OptionDefault(model.SERVICE_UID, ServiceUID(m)) m.Option(model.SERVICE_UID, ServiceUID(m))
if len(arg) == 0 { if len(arg) == 0 {
USER_PLACE_ROLE := s.Keys(s.UserPlace, model.ROLE) USER_PLACE_ROLE := s.Keys(s.UserPlace, model.ROLE)
m.Cmdy(m.PrefixKey(), s.PlaceList, m.Option(model.USER_UID)).Table(func(value ice.Maps) { m.Cmdy(m.PrefixKey(), s.PlaceList, m.Option(model.USER_UID)).Table(func(value ice.Maps) {
@ -139,7 +136,7 @@ func (s Portal) List(m *ice.Message, arg ...string) {
s.DisplayBase(m, "").DisplayCSS("") s.DisplayBase(m, "").DisplayCSS("")
} }
func (s Portal) PlaceListOption(m *ice.Message, arg ...string) *ice.Message { func (s Portal) PlaceListOption(m *ice.Message, arg ...string) *ice.Message {
msg := m.Cmd(m.PrefixKey(), s.PlaceList, m.Option(model.USER_UID), arg[0]) msg := m.Cmd("", s.PlaceList, m.Option(model.USER_UID), arg[0])
if msg.Length() == 0 { if msg.Length() == 0 {
msg = m.Cmd(s.Place, s.Table.Select, model.UID, arg[0]) msg = m.Cmd(s.Place, s.Table.Select, model.UID, arg[0])
if msg.Length() == 0 { if msg.Length() == 0 {
@ -159,8 +156,8 @@ func (s Portal) PlaceListOption(m *ice.Message, arg ...string) *ice.Message {
s.Keys(s.Place, model.NAME), s.Keys(s.Place, model.TYPE), s.Keys(s.UserPlace, model.ROLE), s.Keys(s.Place, model.NAME), s.Keys(s.Place, model.TYPE), s.Keys(s.UserPlace, model.ROLE),
model.CITY_NAME, s.Keys(s.Street, model.NAME), model.AUTH_STATUS, model.DASHBOARD_UID, model.CITY_NAME, s.Keys(s.Street, model.NAME), model.AUTH_STATUS, model.DASHBOARD_UID,
)) ))
m.Option(model.PLACE_NAME, msg.Append(s.Keys(s.Place, model.NAME)))
m.Option(model.STREET_NAME, msg.Append(s.Keys(s.Street, model.NAME))) m.Option(model.STREET_NAME, msg.Append(s.Keys(s.Street, model.NAME)))
m.Option(model.PLACE_NAME, msg.Append(s.Keys(s.Place, model.NAME)))
return msg return msg
} }
func (s Portal) PlaceCreate(m *ice.Message, arg ...string) { func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
@ -171,7 +168,7 @@ func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
} }
name := m.Option(s.Keys(s.Place, model.NAME)) name := m.Option(s.Keys(s.Place, model.NAME))
arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.NAME), model.NAME, s.Keys(s.Place, model.INFO), model.INFO, s.Keys(s.Place, model.TYPE), model.TYPE) arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.NAME), model.NAME, s.Keys(s.Place, model.INFO), model.INFO, s.Keys(s.Place, model.TYPE), model.TYPE)
if m.Cmdy(s.Place, s.Insert, arg[2:]).IsErr() { if m.Options(arg).Cmdy(s.Place, s.Insert, arg[2:]).IsErr() {
return return
} }
s.RecordEventWithName(m.Options(mdb.NAME, name, s.Keys(s.Place, model.UID), m.Result()), "") s.RecordEventWithName(m.Options(mdb.NAME, name, s.Keys(s.Place, model.UID), m.Result()), "")
@ -201,32 +198,27 @@ func (s Portal) PlaceList(m *ice.Message, arg ...string) *ice.Message {
s.SelectJoinAuth(m) s.SelectJoinAuth(m)
return m return m
} }
func (s Portal) PlaceInfo(m *ice.Message, arg ...string) {
msg := m.Cmd(s.Place, s.Table.Select, model.UID, m.Option(s.Keys(s.Place, model.UID)))
s.SelectJoin(msg, s.Street, model.NAME, model.CITY_UID)
s.SelectJoinCity(msg)
m.Option(model.CITY_NAME, msg.Append(model.CITY_NAME))
m.Option(model.STREET_NAME, msg.Append(s.Keys(s.Street, model.NAME)))
m.Option(model.PLACE_NAME, msg.Append(model.NAME))
}
func (s Portal) PlaceAuth(m *ice.Message, arg ...string) { func (s Portal) PlaceAuth(m *ice.Message, arg ...string) {
if m.Option(model.AUTH_UID) != "" { if m.Option(model.AUTH_UID) != "" {
return return
} }
msg := m.Cmd(s.Street, s.Table.Select, model.UID, m.Option(s.Keys(s.Street, model.UID)))
if m.WarnNotValid(msg.Append(model.AUTH_UID) == "") {
return
}
place_uid, place_name := m.Option(s.Keys(s.Place, model.UID)), m.Option(s.Keys(s.Place, model.NAME)) place_uid, place_name := m.Option(s.Keys(s.Place, model.UID)), m.Option(s.Keys(s.Place, model.NAME))
m.Option(model.COMPANY_NAME, m.Option(s.Keys(s.Street, model.NAME))) s.AutoCmdy(m, api.RENZHENGSHOUQUAN_PORTAL, s.PlaceCreate,
msg := s.AutoCmd(m, api.RENZHENGSHOUQUAN_PORTAL, s.PlaceCreate, m.OptionSimple(model.CITY_NAME, model.COMPANY_NAME), model.AUTH_NAME, place_name, model.AUTH_TYPE, ice.AUTO, model.FROM_UID, msg.Append(model.AUTH_UID),
model.AUTH_TYPE, ice.AUTO, model.AUTH_NAME, place_name, model.FROM_UID, ice.AUTO,
model.SERVICE_UID, ServiceUID(m), model.PLACE_UID, place_uid, model.SERVICE_UID, ServiceUID(m), model.PLACE_UID, place_uid,
) )
m.Cmd(s.Place, s.UpdateAuth, msg.Option(model.AUTH_UID), model.UID, place_uid) m.Cmd(s.Place, s.UpdateField, msg.OptionSimple(model.AUTH_UID), model.UID, place_uid)
s.RecordEventWithName(m.Options(model.NAME, place_name, model.UID, place_uid), "") s.RecordEventWithName(m.Options(model.NAME, place_name, model.UID, place_uid), "")
msg.Cmd(s.Prefix(m, s), s.AfterPlaceAuth) msg.Cmd(s.Prefix(msg, s), s.AfterPlaceAuth)
s.StorageCreate(m, "") s.StorageCreate(m, "")
} }
func (s Portal) ValueCreate(m *ice.Message, arg ...string) { func (s Portal) ValueCreate(m *ice.Message, arg ...string) {
s.Table.Insert(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, s.Keys(s.Place, model.UID)))...) s.Table.Insert(m, kit.Simple(arg, m.OptionSimple(s.Keys(s.Place, model.UID), model.USER_UID))...)
} }
func (s Portal) ValueRemove(m *ice.Message, arg ...string) { func (s Portal) ValueRemove(m *ice.Message, arg ...string) {
s.Table.Delete(m, m.OptionSimple(s.Keys(s.Place, model.UID), model.UID)...) s.Table.Delete(m, m.OptionSimple(s.Keys(s.Place, model.UID), model.UID)...)
@ -264,11 +256,9 @@ func (s Portal) BeforePlaceAuth(m *ice.Message, arg ...string) {}
func (s Portal) AfterPlaceAuth(m *ice.Message, arg ...string) {} func (s Portal) AfterPlaceAuth(m *ice.Message, arg ...string) {}
func (s Portal) AddRecent(m *ice.Message, arg ...string) { func (s Portal) AddRecent(m *ice.Message, arg ...string) {
if kit.IsIn(m.Append(model.AUTH_STATUS), "2", "issued") { args := kit.Simple(model.PLACE_UID, arg[0], m.OptionSimple(model.SERVICE_UID, model.PLACE_NAME, model.STREET_NAME, model.CITY_NAME))
m.Cmd(s.Prefix(m, s.recent), s.Create, s.GetCommands(m, model.SERVICE_UID, arg...), model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)), model.AUTH_STATUS, "2") kit.If(kit.IsIn(m.Append(model.AUTH_STATUS), "2", "issued"), func() { args = append(args, model.AUTH_STATUS, "2") })
} else { m.Cmd(s.Prefix(m, s.recent), s.Create, args)
m.Cmd(s.Prefix(m, s.recent), s.Create, s.GetCommands(m, model.SERVICE_UID, arg...), model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))
}
} }
func (s Portal) RecordEvent(m *ice.Message, arg ...string) { func (s Portal) RecordEvent(m *ice.Message, arg ...string) {
s.event.Record(m.Spawn(kit.Dict(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))), arg[0], arg[1:]...) s.event.Record(m.Spawn(kit.Dict(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))), arg[0], arg[1:]...)
@ -282,11 +272,11 @@ func (s Portal) DashboardCreate(m *ice.Message, name string, arg ...string) func
defer s.SaveBack(m, ice.MSG_USERPOD)() defer s.SaveBack(m, ice.MSG_USERPOD)()
kit.If(name == "", func() { name = m.Option(s.Keys(s.Place, model.NAME)) }) kit.If(name == "", func() { name = m.Option(s.Keys(s.Place, model.NAME)) })
s.AutoCmdy(m, api.DASHBOARD_PORTAL, s.PlaceCreate, m.OptionSimple(model.CITY_NAME, model.COMPANY_NAME), model.DASHBOARD_NAME, name, model.DASHBOARD_TYPE, "0") s.AutoCmdy(m, api.DASHBOARD_PORTAL, s.PlaceCreate, m.OptionSimple(model.CITY_NAME, model.COMPANY_NAME), model.DASHBOARD_NAME, name, model.DASHBOARD_TYPE, "0")
s.AutoCmd(m, api.RENZHENGSHOUQUAN_AUTH, s.UpdateField, m.OptionSimple(model.DASHBOARD_UID), model.UID, m.Option(model.AUTH_UID)) s.AutoCmd(m, api.RENZHENGSHOUQUAN_AUTH, s.UpdateField, m.OptionSimple(model.DASHBOARD_UID))
return func() { s.DashboardUpdate(m) } return func() { s.DashboardUpdate(m) }
} }
func (s Portal) DashboardInsert(m *ice.Message, score int, title, unit string, index ice.Any, field string, arg ...ice.Any) { func (s Portal) DashboardInsert(m *ice.Message, score int, title, unit string, index ice.Any, field string, arg ...ice.Any) {
kit.If(len(arg) == 0, func() { arg = append(arg, s.Keys(s.Place, model.UID), m.Option(s.Keys(s.Place, model.UID))) }) kit.If(len(arg) == 0, func() { arg = append(arg, m.OptionSimple(s.Keys(s.Place, model.UID))) })
s.AutoCmd(m, api.DASHBOARD_SUMMARY, s.Insert, model.SPACE, m.Option(ice.MSG_USERPOD), model.INDEX, s.Prefix(m, index), s.AutoCmd(m, api.DASHBOARD_SUMMARY, s.Insert, model.SPACE, m.Option(ice.MSG_USERPOD), model.INDEX, s.Prefix(m, index),
model.QUERY, kit.Format(arg), mdb.FIELD, field, model.TITLE, title, model.SCORE, score, model.UNIT, unit, m.OptionSimple(model.DASHBOARD_UID)) model.QUERY, kit.Format(arg), mdb.FIELD, field, model.TITLE, title, model.SCORE, score, model.UNIT, unit, m.OptionSimple(model.DASHBOARD_UID))
} }
@ -298,7 +288,7 @@ func (s Portal) DashboardUpdate(m *ice.Message, arg ...string) {
func (s Portal) StorageCreate(m *ice.Message, name string, arg ...string) { func (s Portal) StorageCreate(m *ice.Message, name string, arg ...string) {
kit.If(name == "", func() { name = m.Option(s.Keys(s.Place, model.NAME)) }) kit.If(name == "", func() { name = m.Option(s.Keys(s.Place, model.NAME)) })
s.AutoCmdy(m, api.STORAGE_PORTAL, s.PlaceCreate, m.OptionSimple(model.CITY_NAME, model.COMPANY_NAME), model.STORAGE_NAME, name, model.STORAGE_TYPE, "0") s.AutoCmdy(m, api.STORAGE_PORTAL, s.PlaceCreate, m.OptionSimple(model.CITY_NAME, model.COMPANY_NAME), model.STORAGE_NAME, name, model.STORAGE_TYPE, "0")
s.AutoCmd(m, api.RENZHENGSHOUQUAN_AUTH, s.UpdateField, m.OptionSimple(model.STORAGE_UID), model.UID, m.Option(model.AUTH_UID)) s.AutoCmd(m, api.RENZHENGSHOUQUAN_AUTH, s.UpdateField, m.OptionSimple(model.STORAGE_UID))
} }
func (s Portal) StorageInsert(m *ice.Message, title, content string) { func (s Portal) StorageInsert(m *ice.Message, title, content string) {
s.AutoCmd(m, api.STORAGE_FILE, s.Insert, model.TITLE, title, model.CONTENT, content, m.OptionSimple(model.STORAGE_UID, model.USER_UID)) s.AutoCmd(m, api.STORAGE_FILE, s.Insert, model.TITLE, title, model.CONTENT, content, m.OptionSimple(model.STORAGE_UID, model.USER_UID))
@ -325,10 +315,8 @@ func (s Portal) PlaceCmd(m *ice.Message, arg ...string) {
} }
func (s Portal) CommandUpdate(m *ice.Message, arg ...string) { func (s Portal) CommandUpdate(m *ice.Message, arg ...string) {
m.Config(model.SERVICE_UID, arg[0])
s.Hash.Select(m.Spawn()).Table(func(value ice.Maps) { s.Hash.Select(m.Spawn()).Table(func(value ice.Maps) {
uid := m.Cmdx(command{}, s.Table.Modify, model.SERVICE_UID, arg[0], mdb.ICON, value[mdb.ICONS], model.NAME, value[model.NAME], model.INDEX, value[model.INDEX]) m.Cmdx(command{}, s.Table.Modify, model.SERVICE_UID, arg[0], model.INDEX, value[model.INDEX], model.NAME, value[model.NAME], mdb.ICON, value[mdb.ICONS])
s.Hash.Modify(m, ctx.INDEX, value[ctx.INDEX], model.COMMAND_UID, uid)
}) })
} }
func (s Portal) CommandSelect(m *ice.Message, arg ...string) { func (s Portal) CommandSelect(m *ice.Message, arg ...string) {
@ -336,7 +324,7 @@ func (s Portal) CommandSelect(m *ice.Message, arg ...string) {
} }
func (s Portal) Create(m *ice.Message, arg ...string) { func (s Portal) Create(m *ice.Message, arg ...string) {
args := []string{ctx.INDEX, m.Option(ctx.INDEX)} args := m.OptionSimple(ctx.INDEX)
msg := s.Hash.Select(m.Spawn(), m.Option(ctx.INDEX)) msg := s.Hash.Select(m.Spawn(), m.Option(ctx.INDEX))
kit.If(msg.Length() > 0, func() { args = append(args, mdb.TIME, msg.Append(mdb.TIME)) }) kit.If(msg.Length() > 0, func() { args = append(args, mdb.TIME, msg.Append(mdb.TIME)) })
m.Search(m.Option(ctx.INDEX), func(key string, cmd *ice.Command) { m.Search(m.Option(ctx.INDEX), func(key string, cmd *ice.Command) {
@ -353,8 +341,9 @@ func (s Portal) Modify(m *ice.Message, arg ...string) { s.Hash.Modify(m, arg...)
func (s Portal) Show(m *ice.Message, arg ...string) { func (s Portal) Show(m *ice.Message, arg ...string) {
m.Cmd(s.Prefix(m, s), s.Create, ctx.INDEX, m.PrefixKey()) m.Cmd(s.Prefix(m, s), s.Create, ctx.INDEX, m.PrefixKey())
} }
func (s Portal) Link(m *ice.Message, arg ...string) string { func (s Portal) Link(m *ice.Message, arg ...string) {
return m.MergePodCmd("", s.Prefix(m, s)) + "#" + kit.TrimSuffix(kit.Join([]string{arg[0], kit.Select(s.Prefix(m, apply{}), arg, 1), kit.Select("", arg, 2)}, ":"), ":") m.Echo(m.MergePodCmd("", s.Prefix(m, s), s.Keys(s.Place, model.UID), arg[0]) +
"#" + kit.TrimSuffix(kit.Join([]string{arg[0], kit.Select("", arg, 1), kit.Select("", arg, 2)}, ":"), ":", ":"))
} }
func init() { ice.TeamCtxCmd(Portal{Table: newTable()}) } func init() { ice.TeamCtxCmd(Portal{Table: newTable()}) }

View File

@ -32,7 +32,7 @@ Volcanos(chat.ONIMPORT, {
can.onimport.myTrans(can, value, PLACE_UID, PLACE_NAME, PLACE_TYPE, USER_PLACE_ROLE, STREET_NAME) can.onimport.myTrans(can, value, PLACE_UID, PLACE_NAME, PLACE_TYPE, USER_PLACE_ROLE, STREET_NAME)
if (value._uid == can.db.hash[0]) { can.onexport.value(can, value) } if (value._uid == can.db.hash[0]) { can.onexport.value(can, value) }
}) })
return can.run({}, [ctx.COMMAND, can.db.hash[1]], function(msg) { msg.Table(function(value) { return can.runAction({}, ctx.COMMAND, [can.db.hash[1]], function(msg) { msg.Table(function(value) {
value.args = [can.db.hash[0]].concat(can.db.hash.slice(2)), can.onimport.myStory(can, value) value.args = [can.db.hash[0]].concat(can.db.hash.slice(2)), can.onimport.myStory(can, value)
}) }) }) })
} }

View File

@ -8,26 +8,25 @@ import (
type qrcode struct { type qrcode struct {
Tables Tables
apply apply
portal Portal portal Portal
order string `data:"501"` order string `data:"501"`
role string `data:"creator"` role string `data:"leader"`
applyQRCode string `name:"applyQRCode" role:"void"` applyQRCode string `name:"applyQRCode" role:"void"`
} }
func (s qrcode) ApplyQRCode(m *ice.Message, arg ...string) { func (s qrcode) ApplyQRCode(m *ice.Message, arg ...string) {
s.info(m, arg[0], "apply")
m.Option(ice.MSG_FG, "blue") m.Option(ice.MSG_FG, "blue")
m.Echo("请让申请人扫码") s.info(m, arg[0], "apply").EchoQRCode(s.Link(m, arg[0], s.Prefix(m, s.apply))).Echo("请让申请人扫码")
m.EchoQRCode(s.Link(m, arg[0]))
} }
func (s qrcode) List(m *ice.Message, arg ...string) { func (s qrcode) List(m *ice.Message, arg ...string) {
s.info(m, arg[0], "portal") s.info(m, arg[0], "portal").EchoQRCode(s.Link(m, arg[0]))
m.EchoQRCode(m.MergePodCmd("", s.Prefix(m, s.portal), s.Keys(s.Place, model.UID), arg[0]))
} }
func init() { ice.TeamCtxCmd(qrcode{Tables: newTables()}) } func init() { ice.TeamCtxCmd(qrcode{Tables: newTables()}) }
func (s qrcode) info(m *ice.Message, place_uid, typ string) { func (s qrcode) info(m *ice.Message, place_uid, cmd string) *ice.Message {
m.Cmdy(s.Prefix(m, s.portal), s.portal.PlaceList, m.Option(model.USER_UID), place_uid).Cut(model.CITY_NAME, s.Keys(s.Street, model.NAME), s.Keys(s.Place, model.NAME)) m.Cmdy(s.Prefix(m, s.portal), s.portal.PlaceList, m.Option(model.USER_UID), place_uid).Cut(model.CITY_NAME, s.Keys(s.Street, model.NAME), s.Keys(s.Place, model.NAME))
m.Push(model.QRCODE_TYPE, typ).Action(s.ApplyQRCode) m.Push(model.QRCODE_TYPE, cmd).Action(s.ApplyQRCode)
return m
} }

View File

@ -13,7 +13,7 @@ type recent struct {
Table Table
service service service service
order string `data:"903"` order string `data:"903"`
create string `name:"create service_uid args"` create string `name:"create place_uid service_uid"`
remove string `name:"remove" role:"void"` remove string `name:"remove" role:"void"`
open string `name:"open" role:"void"` open string `name:"open" role:"void"`
sticky string `name:"sticky" role:"void"` sticky string `name:"sticky" role:"void"`
@ -21,10 +21,10 @@ type recent struct {
} }
func (s recent) Create(m *ice.Message, arg ...string) { func (s recent) Create(m *ice.Message, arg ...string) {
if args := m.OptionSimple(model.USER_UID, model.SERVICE_UID, ctx.ARGS); s.Select(m, args...).Length() == 0 { if args := m.OptionSimple(model.USER_UID, model.PLACE_UID); s.Select(m, args...).Length() == 0 {
s.Insert(m, kit.Simple(arg, model.UPDATED_AT, m.Time(), m.OptionSimple(model.USER_UID))...) s.Insert(m, kit.Simple(arg, model.UPDATED_AT, m.Time(), m.OptionSimple(model.USER_UID))...)
} else { } else {
s.Update(m, kit.Dict(m.OptionSimple(model.AUTH_STATUS)), args...) s.Update(m, kit.Dict(arg), args...)
} }
} }
func (s recent) Remove(m *ice.Message, arg ...string) { func (s recent) Remove(m *ice.Message, arg ...string) {
@ -35,10 +35,9 @@ func (s recent) List(m *ice.Message, arg ...string) {
s.Tables(m, s.service).Fields(m, s.Key(s, model.UID), s.Key(s, model.UPDATED_AT), s.Tables(m, s.service).Fields(m, s.Key(s, model.UID), s.Key(s, model.UPDATED_AT),
model.SERVICE_ICON, model.SERVICE_NAME, s.Key(s, model.AUTH_STATUS), model.SCORE, model.SERVICE_ICON, model.SERVICE_NAME, s.Key(s, model.AUTH_STATUS), model.SCORE,
s.Key(s, model.CITY_NAME), s.Key(s, model.STREET_NAME), s.Key(s, model.PLACE_NAME), s.Key(s, model.CITY_NAME), s.Key(s, model.STREET_NAME), s.Key(s, model.PLACE_NAME),
s.AS(model.NODENAME, model.SPACE), model.INDEX, model.ARGS, s.AS(model.NODENAME, model.SPACE), model.INDEX, model.PLACE_UID,
) ).Orders(m, s.Desc(model.SCORE), s.Desc(model.UPDATED_AT))
s.Orders(m, s.Desc(model.SCORE), s.Desc(model.UPDATED_AT)) s.Select(m, model.USER_UID, m.Option(model.USER_UID)).Action()
s.Select(m, model.USER_UID, m.Option(model.USER_UID))
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, model.USER_UID, m.Option(model.USER_UID), model.UID, arg[1]) s.SelectDetail(m, model.USER_UID, m.Option(model.USER_UID), model.UID, arg[1])
} }
@ -48,7 +47,7 @@ func (s recent) List(m *ice.Message, arg ...string) {
} else { } else {
m.PushButton(s.UnSticky, s.Remove) m.PushButton(s.UnSticky, s.Remove)
} }
}).Action() })
s.DisplayBase(m, "") s.DisplayBase(m, "")
} }
func (s recent) Open(m *ice.Message, arg ...string) { func (s recent) Open(m *ice.Message, arg ...string) {

View File

@ -1,13 +1,14 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { var args = can.core.Split(value.args) can.onimport.myView(can, msg, function(value) { if (value.score > 0) { value._style = ["sticky"] }
value.icons = can.misc.Resource(can, value.service_icon.split("?")[0], value.space); if (value.score > 0) { value._style = ["sticky"] } value.icons = can.misc.Resource(can, value.service_icon.split("?")[0], value.space)
value._street = value.street_name
return [ return [
{view: html.TITLE, list: [value.place_name, can.onimport.authView(can, value), can.onimport.timeView(can, value)]}, {view: html.TITLE, list: [value.place_name, can.onimport.authView(can, value), can.onimport.timeView(can, value)]},
{view: html.STATUS, list: [can.onimport.cityView(can, value), value.street_name, value.service_name]}, {view: html.STATUS, list: [can.onimport.cityView(can, value), can.onimport.streetView(can, value), value.service_name]},
] ]
}, function(event, value) { can.onaction._goback(can); var args = can.core.Split(value.args) }, function(event, value) { can.onaction._goback(event, function() {
can.onimport.myPlugin(can, {space: value.space, index: value.index, args: [args[0]]}) can.onimport.myPlugin(can, {space: value.space, index: value.index, args: [value.place_uid]})
}) }) })
}, },
}) })

View File

@ -14,11 +14,11 @@ func (s search) List(m *ice.Message, arg ...string) {
} else if len(arg) == 2 { } else if len(arg) == 2 {
m.FieldsSetDetail().Cmdy(s.Place, s.Select, model.UID, arg[1]).Action() m.FieldsSetDetail().Cmdy(s.Place, s.Select, model.UID, arg[1]).Action()
} }
m.RenameAppend(model.TYPE, s.Keys(s.Place, model.TYPE), model.CREATOR, model.USER_UID) m.RenameAppend(model.TYPE, s.Keys(s.Place, model.TYPE))
s.SelectJoin(m, s.Street, model.NAME, model.CITY_UID) s.SelectJoin(m, s.Street, model.NAME, model.CITY_UID)
s.SelectJoinCity(m) s.SelectJoinCity(m)
s.SelectJoinUser(m) s.SelectJoinUser(m)
s.Display(m, "") s.DisplayBase(m, "")
} }
func init() { ice.TeamCtxCmd(search{Tables: newTables()}) } func init() { ice.TeamCtxCmd(search{Tables: newTables()}) }

View File

@ -28,20 +28,15 @@ type service struct {
} }
func ServiceUID(m *ice.Message) string { func ServiceUID(m *ice.Message) string {
return kit.Hashs(ice.Info.Hostname, ice.Info.Pwd, m.Prefix("portal")) return kit.Hashs(ice.Info.Hostname, ice.Info.Pwd, m.Prefix(web.PORTAL))
} }
func (s service) Update(m *ice.Message, arg ...string) { func (s service) Update(m *ice.Message, arg ...string) {
uid := ServiceUID(m) uid := ServiceUID(m)
if s.Select(m.Spawn(), model.UID, uid).Length() == 0 { if s.Select(m.Spawn(), model.UID, uid).Length() == 0 {
s.Insert(m, kit.Simple(model.UID, uid, m.OptionSimple(mdb.ICON, mdb.NAME, ctx.INDEX), nfs.PATHNAME, ice.Info.Pwd, tcp.HOSTNAME, ice.Info.Hostname)...) s.Insert(m, kit.Simple(model.UID, uid, model.INDEX, m.Prefix(web.PORTAL), tcp.NODETYPE, ice.Info.NodeType, tcp.NODENAME, ice.Info.NodeName, nfs.PATHNAME, ice.Info.Pwd, tcp.HOSTNAME, ice.Info.Hostname)...)
m.Cmd(s.PrefixPortal(m)).Table(func(value ice.Maps) { m.Cmd(s.PrefixPortal(m), mdb.MODIFY, value[ctx.INDEX], mdb.ENABLE, ice.TRUE) })
} }
s.Table.Update(m, kit.Dict(arg, m.OptionSimple(mdb.NAME, mdb.ICON), s.Table.Update(m, kit.Dict(arg, m.OptionSimple(mdb.NAME, mdb.ICON), nfs.MODULE, ice.Info.Make.Module, nfs.VERSION, ice.Info.Make.Versions()), model.UID, uid)
nfs.MODULE, ice.Info.Make.Module, nfs.VERSION, ice.Info.Make.Versions(), m.Cmd(s.PrefixPortal(m), Portal{}.CommandUpdate, uid)
tcp.NODENAME, ice.Info.NodeName, tcp.NODETYPE, ice.Info.NodeType,
web.DOMAIN, ice.Info.Make.Domain, web.PORTAL, ctx.GetCmdFile(m.Message, m.Prefix(web.PORTAL)),
), model.UID, uid)
m.Cmd(s.PrefixPortal(m), "updateCommand", uid)
} }
func (s service) Autogen(m *ice.Message, arg ...string) { func (s service) Autogen(m *ice.Message, arg ...string) {
m.Option("CLASS", strings.ToUpper(m.Option(mdb.CLASS))) m.Option("CLASS", strings.ToUpper(m.Option(mdb.CLASS)))
@ -73,35 +68,25 @@ func (s service) Compile(m *ice.Message, arg ...string) {
} }
func (s service) Oauth(m *ice.Message, arg ...string) { func (s service) Oauth(m *ice.Message, arg ...string) {
m.Options(m.Cmd(web.CHAT_WX_ACCESS).AppendSimple()) m.Options(m.Cmd(web.CHAT_WX_ACCESS).AppendSimple())
m.Option("user_cmd", kit.JoinWord(m.Prefix(aaa.USER), mdb.CREATE))
m.Option("sess_cmd", kit.JoinWord(m.Prefix(aaa.SESS), mdb.CREATE)) m.Option("sess_cmd", kit.JoinWord(m.Prefix(aaa.SESS), mdb.CREATE))
m.Cmd(web.CHAT_WX_ACCESS, web.OAUTH) m.Option("user_cmd", kit.JoinWord(m.Prefix(aaa.USER), mdb.CREATE))
m.Cmd(web.SPACE, ice.OPS, ctx.CONFIG, web.CHAT_WX_AGENT, web.SPACE, m.Option(ice.MSG_USERPOD)) m.Cmd(web.SPACE, ice.OPS, ctx.CONFIG, web.CHAT_WX_AGENT, web.SPACE, m.Option(ice.MSG_USERPOD))
m.Cmd(web.CHAT_WX_ACCESS, web.OAUTH)
m.ProcessHold() m.ProcessHold()
} }
func (s service) List(m *ice.Message, arg ...string) { func (s service) List(m *ice.Message, arg ...string) {
if len(arg) == 2 { if len(arg) < 2 {
s.SelectDetail(m, model.UID, arg[1])
} else {
s.Orders(m, s.Desc(model.UPDATED_AT)).Select(m) s.Orders(m, s.Desc(model.UPDATED_AT)).Select(m)
} else {
s.SelectDetail(m, model.UID, arg[1])
} }
list := m.CmdMap(web.SPACE, ice.OPS, web.SPACE, mdb.NAME)
m.Table(func(value ice.Maps) {
if _, ok := list[value[tcp.NODENAME]]; ok && value[ctx.INDEX] != "" {
if m.Cmd(web.SPACE, ice.OPS, web.SPACE, value[tcp.NODENAME], value[ctx.INDEX], kit.Dict(mdb.VIEW, mdb.TABLE)).Length() > 0 {
m.Push(mdb.STATUS, web.ONLINE)
return
}
}
m.Push(mdb.STATUS, "")
})
if m.IsTech() { if m.IsTech() {
m.PushAction(s.Open, s.Conf, s.Project).Action(s.Autogen, s.Compile, s.Oauth) m.PushAction(s.Open, s.Conf).Action(s.Autogen, s.Compile, s.Oauth)
} else { } else {
m.PushAction(s.Open).Action() m.PushAction(s.Open).Action()
} }
m.Sort("status,updated_at", []string{web.ONLINE}, ice.STR_R).Display("") m.RenameAppend(model.NODENAME, model.SPACE, model.NODETYPE, model.SERVICE_TYPE, mdb.STATUS, model.SERVICE_STATUS)
m.RenameAppend("nodetype", model.SERVICE_TYPE, mdb.STATUS, model.SERVICE_STATUS) s.DisplayBase(m, "")
} }
func (s service) Open(m *ice.Message, arg ...string) { func (s service) Open(m *ice.Message, arg ...string) {
m.ProcessOpen(web.S(m.Option(tcp.NODENAME)) + web.C(m.Option(ctx.INDEX))) m.ProcessOpen(web.S(m.Option(tcp.NODENAME)) + web.C(m.Option(ctx.INDEX)))
@ -109,8 +94,5 @@ func (s service) Open(m *ice.Message, arg ...string) {
func (s service) Conf(m *ice.Message, arg ...string) { func (s service) Conf(m *ice.Message, arg ...string) {
m.ProcessOpen(web.S(m.Option(tcp.NODENAME)) + web.C(m.Option(ctx.INDEX)) + "?view=table") m.ProcessOpen(web.S(m.Option(tcp.NODENAME)) + web.C(m.Option(ctx.INDEX)) + "?view=table")
} }
func (s service) Project(m *ice.Message, arg ...string) {
m.ProcessOpen(web.S(m.Option(tcp.NODENAME)) + web.C(web.CODE_VIMER) + "?path=src/&file=" + strings.Split(kit.Select("", strings.Split(m.Option(web.PORTAL), "/src/"), 1), "?")[0])
}
func init() { ice.TeamCtxCmd(service{}) } func init() { ice.TeamCtxCmd(service{}) }

View File

@ -1,12 +1,11 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { value.icon = value.icon.split("?")[0]; return value.service_status == "online" && [ can.onimport.myView(can, msg, function(value) { value.icon = value.icon.split("?")[0]; return [
// {view: html.TITLE, list: [value.name, can.onimport.textView(can, value, "service_type"), can.onimport.textView(can, value, "service_status")]},
{view: html.TITLE, list: [value.name]}, {view: html.TITLE, list: [value.name]},
{view: html.STATUS, list: [value.index]}, {view: html.STATUS, list: [value.index]},
{view: html.STATUS, list: [value.module, value.version]}, {view: html.STATUS, list: [value.module, value.version]},
] }, function(event, value) { can.onaction._goback(can) ] }, function(event, value) { can.onaction._goback(event, function() {
can.onimport.myPlugin(can, {space: value.space||value.nodename, index: value.index}) can.onimport.myPlugin(can, {space: value.space, index: value.index})
}) }) })
}, },
}) })

View File

@ -28,14 +28,5 @@ func (s sess) Check(m *ice.Message, arg ...string) {
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 (s sess) List(m *ice.Message, arg ...string) {
if m.IsTech() {
if len(arg) < 2 {
s.Select(m)
} else {
s.SelectDetail(m, model.UID, arg[1])
}
}
}
func init() { ice.TeamCtxCmd(sess{}) } func init() { ice.TeamCtxCmd(sess{}) }

View File

@ -1,12 +1,6 @@
$output>div.item { $output>div.item { border-radius:10px; background-color:var(--output-bg-color); padding:10px; margin:10px; display:flex; align-items:center; }
border-radius:10px; background-color:var(--output-bg-color); padding:10px; margin:10px; $output>div.item span.name { flex-grow:1; }
display:flex; align-items:center; $output>div.item span.outer { background-color:gray; border-radius:12px; padding:2px; height:24px; width:40px; display:inline-block; float:right; }
}
$output>div.item span.name {
flex-grow:1;
}
$output>div.item span.outer {
background-color:gray; border-radius:12px; padding:2px; height:24px; width:40px; display:inline-block; float:right; }
$output>div.item span.inner { border-radius:10px; background-color:white; height:20px; width:20px; display:inline-block; } $output>div.item span.inner { border-radius:10px; background-color:white; height:20px; width:20px; display:inline-block; }
$output>div.item span.outer.on { background-color:var(--notice-bg-color); } $output>div.item span.outer.on { background-color:var(--notice-bg-color); }
$output>div.item span.outer.on span.inner { float:right; } $output>div.item span.outer.on span.inner { float:right; }

View File

@ -9,20 +9,20 @@ import (
type setting struct { type setting struct {
Table Table
service service
recent recent recent recent
service service
order string `data:"102"` order string `data:"102"`
role string `data:"leader,worker,server"` role string `data:"leader,worker,server"`
short string `data:"name"` short string `data:"name"`
field string `data:"name,type,help"` field string `data:"name,type,help"`
fields string `data:"name,value"` fields string `data:"name,value"`
create string `name:"create name* type* help*" role:"tech"` create string `name:"create name* type* help" role:"tech"`
update string `name:"update" role:"void"` update string `name:"update" role:"void"`
} }
func (s setting) Init(m *ice.Message, arg ...string) { func (s setting) Init(m *ice.Message, arg ...string) {
s.Table.Init(m, arg...) s.Table.Init(m, arg...)
s.Create(m, model.NAME, "profile", model.TYPE, "radio", "help", "将本系统展示到个人名片首页") s.Create(m, model.NAME, "profile", model.TYPE, "radio")
} }
func (s setting) Create(m *ice.Message, arg ...string) { func (s setting) Create(m *ice.Message, arg ...string) {
s.Hash.Create(m, arg...) s.Hash.Create(m, arg...)
@ -35,24 +35,23 @@ func (s setting) Update(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(m.OptionSimple(model.VALUE)), m.OptionSimple(model.PLACE_UID, model.USER_UID, model.NAME)...) s.Table.Update(m, kit.Dict(m.OptionSimple(model.VALUE)), m.OptionSimple(model.PLACE_UID, model.USER_UID, model.NAME)...)
} }
} }
func (s setting) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
data := ice.Maps{}
msg := s.Select(m.Spawn(), model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
msg.Table(func(value ice.Maps) { data[value[model.NAME]] = value[model.VALUE] })
s.Hash.List(m).Table(func(value ice.Maps) { m.Push(model.VALUE, data[value[model.NAME]]) }).Action()
} else if len(arg) == 2 {
s.SelectDetail(m, model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID), model.NAME, arg[1])
}
s.DisplayBase(m, "").DisplayCSS("")
}
func (s setting) Profile(m *ice.Message, arg ...string) { func (s setting) Profile(m *ice.Message, arg ...string) {
s.Fields(m, s.Key(s, model.PLACE_UID)) s.Fields(m, model.PLACE_UID)
s.Select(m, s.Key(s, model.USER_UID), arg[0], s.Key(s, model.NAME), m.ActionKey(), s.Key(s, model.VALUE), "on") s.Select(m, model.USER_UID, arg[0], model.NAME, m.ActionKey(), model.VALUE, "on")
} }
func (s Table) SettingProfile(m *ice.Message, arg ...string) *ice.Message { func (s Table) SettingProfile(m *ice.Message, arg ...string) *ice.Message {
return m.Cmdy(s.Prefix(m, setting{}), setting{}.Profile, arg) return m.Cmdy(s.Prefix(m, setting{}), setting{}.Profile, arg)
} }
func (s setting) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
data := ice.Maps{}
msg := s.Select(m.Spawn(), s.Key(s, model.PLACE_UID), arg[0], s.Key(s, model.USER_UID), m.Option(model.USER_UID))
msg.Table(func(value ice.Maps) { data[value[model.NAME]] = value[model.VALUE] })
s.Hash.List(m).Table(func(value ice.Maps) { m.Push(model.VALUE, data[value[model.NAME]]) })
m.Action()
} else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s, model.PLACE_UID), arg[0], s.Key(s, model.USER_UID), m.Option(model.USER_UID), model.NAME, arg[1])
}
s.Display(m, "").DisplayCSS("")
}
func init() { ice.TeamCtxCmd(setting{Table: newTable()}) } func init() { ice.TeamCtxCmd(setting{Table: newTable()}) }

View File

@ -7,7 +7,7 @@ Volcanos(chat.ONIMPORT, {
radio: function(can, value) { radio: function(can, value) {
return {text: ["", "", ["outer", value.value]], list: [{text: ["", "", "inner"]}], onclick: function(event) { return {text: ["", "", ["outer", value.value]], list: [{text: ["", "", "inner"]}], onclick: function(event) {
if (value.value == "on") { value.value = "off" } else { value.value = "on" } if (value.value == "on") { value.value = "off" } else { value.value = "on" }
can.run(can.request(event, value, can.Option(), {_toast: value.name}), [ctx.ACTION, mdb.UPDATE]) can.runAction(can.request(event, value, can.Option(), {_toast: value.name}), mdb.UPDATE, [])
}} }}
}, },
}) })

View File

@ -9,8 +9,10 @@ import (
type street struct { type street struct {
Table Table
modify string `name:"modify street_info" role:"void"` city city
list string `name:"list street_name auto" role:"void"` modify string `name:"modify street_info" role:"void"`
list string `name:"list city_name street_name auto" role:"void"`
authCreate string `name:"authCreate city_name* company_name* street_name* street_info" role:"void"`
} }
func (s street) FindOrCreateByName(m *ice.Message, arg ...string) { func (s street) FindOrCreateByName(m *ice.Message, arg ...string) {
@ -22,27 +24,22 @@ func (s street) FindOrCreateByName(m *ice.Message, arg ...string) {
} }
} }
func (s street) Modify(m *ice.Message, arg ...string) { func (s street) Modify(m *ice.Message, arg ...string) {
s.Update(m, kit.Dict(model.INFO, m.Option(model.STREET_INFO)), model.NAME, m.Option(model.STREET_NAME)) s.Update(m, kit.Dict(model.INFO, m.Option(model.STREET_INFO)), model.NAME, m.Option(model.STREET_NAME), model.CITY_UID, m.Option(model.CITY_UID))
} }
func (s street) List(m *ice.Message, arg ...string) { func (s street) List(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
if m.IsTech() { m.Cmdy(s.city).RenameAppend(model.NAME, model.CITY_NAME)
s.Select(m, arg...) } else if msg := m.Cmd(s.city, arg[0]); len(arg) == 1 {
s.Select(m, model.CITY_UID, msg.Append(model.UID)).Action()
} else if len(arg) == 2 {
s.SelectDetail(m, model.CITY_UID, msg.Append(model.UID), model.NAME, arg[1])
if m.Append(model.AUTH_UID) == "" && m.IsTech() {
m.EchoInfoButton("请申请街道认证", s.AuthCreate)
} }
} else {
msg := s.Select(m.Spawn(), model.NAME, arg[0])
m.Option(model.STREET_NAME, msg.Append(model.NAME))
m.Option(model.STREET_INFO, msg.Append(model.INFO))
m.Option(model.STREET_AVATAR, msg.Append(model.AVATAR))
m.Option(model.STREET_BACKGROUND, msg.Append(model.BACKGROUND))
msg.Table(func(value ice.Maps) {
if value[model.AUTH_UID] != "" {
m.Cmdy("web.team.renzhengshouquan.auth", value[model.AUTH_UID])
}
})
kit.If(m.IsTech(), func() { m.Action(s.Modify) })
m.Display("")
} }
} }
func (s street) AuthCreate(m *ice.Message, arg ...string) {
s.Table.AuthCreate(m, 6, s.Select(m.Spawn(), m.OptionSimple(model.CITY_UID)...).Append(model.AUTH_UID))
}
func init() { ice.TeamCtxCmd(street{}) } func init() { ice.TeamCtxCmd(street{}) }

View File

@ -1,18 +0,0 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { msg.Option("_share_title", msg.Option("street_name"))
can.ui = can.page.Appends(can, can._output, [html.HEAD, html.LIST])
can.page.Append(can, can.ui.head, [{img: can.misc.Resource(can, "usr/icons/background.jpg")}])
can.page.Append(can, can.ui.head, [can.onimport.itemcard(can, {avatar: msg.Option("street_avatar")}, [
{view: html.TITLE, list: [msg.Option("street_name"), can.onimport.titleAction(can, msg)]},
{view: html.STATUS, list: [msg.Option("street_info")]},
])])
can.onimport.myView(can, msg, function(value) {
return [
{view: html.TITLE, list: [value.name]},
{view: html.STATUS, list: [value.info]},
]
}, function(event, value) {
// can.onimport.myPlugin(can, {space: value.space, index: value.index, args: [value.place_uid]})
}, can.ui.list)
},
})

View File

@ -23,7 +23,7 @@ func (s support) List(m *ice.Message, arg ...string) {
s.Select(m, model.USER_UID, m.Option(model.USER_UID)).Action() s.Select(m, model.USER_UID, m.Option(model.USER_UID)).Action()
} }
s.SelectJoinUser(m) s.SelectJoinUser(m)
s.Display(m, "").DisplayCSS("") s.DisplayBase(m, "").DisplayCSS("")
} }
func init() { ice.TeamCtxCmd(support{Table: newTable()}) } func init() { ice.TeamCtxCmd(support{Table: newTable()}) }

View File

@ -5,6 +5,7 @@ import "shylinux.com/x/mysql-story/src/db"
const ( const (
UID = "uid" UID = "uid"
NAME = "name" NAME = "name"
INFO = "info"
TYPE = "type" TYPE = "type"
TITLE = "title" TITLE = "title"
CONTENT = "content" CONTENT = "content"
@ -14,8 +15,6 @@ const (
{{.Option "CLASS"}}_NAME = "{{.Option "class"}}_name" {{.Option "CLASS"}}_NAME = "{{.Option "class"}}_name"
{{.Option "CLASS"}}_TYPE = "{{.Option "class"}}_type" {{.Option "CLASS"}}_TYPE = "{{.Option "class"}}_type"
{{.Option "TABLE"}}_UID = "{{.Option "what"}}_uid" {{.Option "TABLE"}}_UID = "{{.Option "what"}}_uid"
COMPANY_UID = "company_uid"
CITY_UID = "city_uid"
) )
type User{{.Option "Class"}} struct { type User{{.Option "Class"}} struct {

View File

@ -1,4 +0,0 @@
$output>div.head { margin-bottom:20px; }
$output>div.head>img { height:200px; width:100%; object-fit:cover; }
$output>div.head div.item.card img { border-radius:25px; }
$output>div.head div.item.card div.title div.item.button i { display:none; }

View File

@ -14,19 +14,17 @@ import (
type user struct { type user struct {
Table Table
setting setting setting setting
community string `data:"20240724-community"`
template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"` template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"`
create string `name:"create open_id* usernick avatar"` create string `name:"create open_id* avatar usernick"`
modify string `name:"modify user_name user_info" role:"void"` modify string `name:"modify user_name* user_info" role:"void"`
email string `name:"email email*"` email string `name:"email email*"`
list string `name:"list uid auto" role:"void"` list string `name:"list uid auto" role:"void"`
authCreate string `name:"authCreate city_name* company_name* auth_name* auth_info" role:"void"` authCreate string `name:"authCreate city_uid*" role:"void"`
} }
func (s user) Create(m *ice.Message, arg ...string) { func (s user) Create(m *ice.Message, arg ...string) {
if m.IsTech() { if m.IsTech() {
m.OptionDefault(aaa.AVATAR, m.Option(ice.MSG_AVATAR)) m.OptionDefault(aaa.AVATAR, m.Option(ice.MSG_AVATAR), aaa.USERNICK, m.Option(ice.MSG_USERNICK))
m.OptionDefault(aaa.USERNICK, m.Option(ice.MSG_USERNICK))
} }
if s.Table.Select(m, m.OptionSimple(model.OPEN_ID)...).Length() == 0 { if s.Table.Select(m, m.OptionSimple(model.OPEN_ID)...).Length() == 0 {
s.Insert(m, kit.Simple(m.OptionSimple(model.OPEN_ID, model.AVATAR), model.NAME, m.Option(aaa.USERNICK))...) s.Insert(m, kit.Simple(m.OptionSimple(model.OPEN_ID, model.AVATAR), model.NAME, m.Option(aaa.USERNICK))...)
@ -37,17 +35,10 @@ func (s user) Create(m *ice.Message, arg ...string) {
} }
} }
func (s user) Modify(m *ice.Message, arg ...string) { func (s user) Modify(m *ice.Message, arg ...string) {
s.Update(m, kit.Dict( s.Update(m, kit.Dict(model.NAME, m.Option(model.USER_NAME), model.INFO, m.Option(model.USER_INFO)))
model.NAME, m.Option(model.USER_NAME),
model.INFO, m.Option(model.USER_INFO),
), model.UID, m.Option(model.USER_UID))
} }
func (s user) Delete(m *ice.Message, arg ...string) { func (s user) Delete(m *ice.Message, arg ...string) {
m.Options(model.NAME, "profile", model.VALUE, "off") m.Options(model.NAME, "profile", model.VALUE, "off").Cmd(s.setting, s.Update)
m.Cmd(s.setting, s.Update)
}
func (s user) AuthCreate(m *ice.Message, arg ...string) {
s.Table.AuthCreate(m, m.Option(model.CITY_NAME), m.Option(model.COMPANY_NAME), 2, m.Option(model.AUTH_NAME), m.Option(model.AUTH_INFO), model.UID, m.Option(model.USER_UID))
} }
func (s user) List(m *ice.Message, arg ...string) { func (s user) List(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
@ -61,7 +52,7 @@ func (s user) List(m *ice.Message, arg ...string) {
}) })
} }
} else { } else {
s.Select(m, model.UID, arg[0]) s.SelectDetail(m, model.UID, arg[0])
if m.Append(model.AUTH_UID) == "" && arg[0] == m.Option(model.USER_UID) { if m.Append(model.AUTH_UID) == "" && arg[0] == m.Option(model.USER_UID) {
m.EchoInfoButton("请申请个人认证", s.AuthCreate) m.EchoInfoButton("请申请个人认证", s.AuthCreate)
} }
@ -70,8 +61,9 @@ func (s user) List(m *ice.Message, arg ...string) {
func (s user) SetCookie(m *ice.Message, arg ...string) { func (s user) SetCookie(m *ice.Message, arg ...string) {
m.ProcessCookie(model.USER_UID, m.Option(model.UID)) m.ProcessCookie(model.USER_UID, m.Option(model.UID))
} }
func (s user) Email(m *ice.Message, arg ...string) { func (s user) AuthCreate(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(m.OptionSimple(model.EMAIL)), model.UID, m.Option(model.USER_UID)) msg := s.Select(m.Spawn(), m.OptionSimple(model.CITY_UID)...)
s.Table.AuthCreate(m, 2, msg.Append(model.AUTH_UID), m.Option(model.USER_NAME), m.Option(model.USER_INFO))
} }
func (s user) SendTemplate(m *ice.Message, arg ...string) { // from uid url type name hash func (s user) SendTemplate(m *ice.Message, arg ...string) { // from uid url type name hash
msg := s.Select(m, model.UID, kit.Select(m.Option(model.USER_UID), arg, 1)) msg := s.Select(m, model.UID, kit.Select(m.Option(model.USER_UID), arg, 1))
@ -80,5 +72,8 @@ func (s user) SendTemplate(m *ice.Message, arg ...string) { // from uid url type
"time11", time.Now().Format("2006年01月02日 15:04"), "thing18", kit.Select(kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)), arg, 0), "time11", time.Now().Format("2006年01月02日 15:04"), "thing18", kit.Select(kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)), arg, 0),
) )
} }
func (s user) Email(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(m.OptionSimple(model.EMAIL)))
}
func init() { ice.TeamCtxCmd(user{}) } func init() { ice.TeamCtxCmd(user{}) }

View File

@ -1,21 +0,0 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { msg.Option("_share_title", msg.Option("user_name"))
can.ui = can.page.Appends(can, can._output, [html.HEAD, html.LIST])
can.page.Append(can, can.ui.head, [{img: can.misc.Resource(can, "usr/icons/background.jpg")}])
can.page.Append(can, can.ui.head, [can.onimport.itemcard(can, {user_name: msg.Option("user_name"), user_avatar: msg.Option("user_avatar")}, [
{view: html.TITLE, list: [msg.Option("user_name"), can.onimport.titleAction(can, msg)]},
{view: html.STATUS, list: [msg.Option("user_info")]},
])])
var list = {}
can.onimport.myView(can, msg, function(value) {
if (list[value.place_uid]) { return } list[value.place_uid] = value
value.icon = can.misc.Resource(can, value.service_icon.split("?")[0], value.space);
return [
{view: html.TITLE, list: [value.place_name]},
{view: html.STATUS, list: [value.city_name, value.street_name, value.service_name]},
]
}, function(event, value) {
can.onimport.myPlugin(can, {space: value.space, index: value.index, args: [value.place_uid]})
}, can.ui.list)
},
})

View File

@ -39,8 +39,7 @@ func (s Auth) List(m *ice.Message, arg ...string) {
}).Display("") }).Display("")
} }
func (s Auth) SelectList(m *ice.Message, arg ...string) { func (s Auth) SelectList(m *ice.Message, arg ...string) {
s.Table.SelectList(m, arg...) s.Table.SelectList(m, arg...).RenameAppend(model.TYPE, model.AUTH_TYPE, model.STATUS, model.AUTH_STATUS)
s.RenameAppend(m, model.TYPE, model.AUTH_TYPE, model.STATUS, model.AUTH_STATUS)
s.RewriteAppend(m) s.RewriteAppend(m)
} }
func (s Auth) MemberList(m *ice.Message, arg ...string) { func (s Auth) MemberList(m *ice.Message, arg ...string) {
@ -80,13 +79,13 @@ func init() { ice.TeamCtxCmd(Auth{}) }
type AuthType int type AuthType int
const ( const (
AuthRoot AuthType = iota AuthRoot AuthType = iota
AuthCity AuthCity // 1
AuthPersonal AuthPersonal // 2
AuthService AuthService // 3
AuthCompany AuthCompany // 4
AuthSchool AuthSchool // 5
AuthStreet AuthStreet // 6
) )
var AuthTypeList = map[AuthType]string{ var AuthTypeList = map[AuthType]string{

View File

@ -7,6 +7,7 @@ const (
NAME = "name" NAME = "name"
INFO = "info" INFO = "info"
TYPE = "type" TYPE = "type"
ROLE = "role"
STATUS = "status" STATUS = "status"
TITLE = "title" TITLE = "title"
CONTENT = "content" CONTENT = "content"
@ -16,6 +17,7 @@ const (
USER_AUTH_ROLE = "user_auth_role" USER_AUTH_ROLE = "user_auth_role"
AUTH_UID = "auth_uid" AUTH_UID = "auth_uid"
AUTH_NAME = "auth_name" AUTH_NAME = "auth_name"
AUTH_INFO = "auth_info"
AUTH_TYPE = "auth_type" AUTH_TYPE = "auth_type"
AUTH_STATUS = "auth_status" AUTH_STATUS = "auth_status"
CERT_UID = "cert_uid" CERT_UID = "cert_uid"
@ -38,25 +40,22 @@ type UserAuth struct {
AuthUID string `gorm:"type:char(32);index"` AuthUID string `gorm:"type:char(32);index"`
} }
type Auth struct { type Auth struct {
db.ModelWithUID db.ModelNameInfo
CompanyUID string `gorm:"type:char(32);index"`
FromUID string `gorm:"type:char(32);index"` FromUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:varchar(64)"`
Info string `gorm:"type:varchar(255)"`
Type uint8 `gorm:"default:0"`
Status uint8 `gorm:"default:0"`
Avatar string `gorm:"type:varchar(255)"` Avatar string `gorm:"type:varchar(255)"`
Background string `gorm:"type:varchar(255)"` Background string `gorm:"type:varchar(255)"`
ServiceUID string `gorm:"type:char(32)"` ServiceUID string `gorm:"type:char(32)"`
PlaceUID string `gorm:"type:char(32)"` PlaceUID string `gorm:"type:char(32)"`
UserUID string `gorm:"type:char(32)"`
StorageUID string `gorm:"type:char(32)"` StorageUID string `gorm:"type:char(32)"`
DashboardUID string `gorm:"type:char(32)"` DashboardUID string `gorm:"type:char(32)"`
Status uint8 `gorm:"default:0"`
} }
type Cert struct { type Cert struct {
db.ModelContent db.ModelContent
AuthUID string `gorm:"type:char(32);index"` AuthUID string `gorm:"type:char(32);index"`
Path string `gorm:"type:varchar(255)"` Path string `gorm:"type:varchar(255)"`
Type string `gorm:"type:char(8)"`
Size int `gorm:"default:0"`
} }
func init() { db.CmdModels("", &UserAuth{}, &Auth{}, &Cert{}) } func init() { db.CmdModels("", &UserAuth{}, &Auth{}, &Cert{}) }

View File

@ -12,7 +12,7 @@ import (
type Portal struct { type Portal struct {
guanlixitong.Portal guanlixitong.Portal
placeCreate string `name:"placeCreate city_name* company_name* auth_name* auth_info auth_type*:select" role:"void"` placeCreate string `name:"placeCreate auth_name* auth_info auth_type*:select from_uid*:select" role:"void"`
} }
func (s Portal) List(m *ice.Message, arg ...string) { func (s Portal) List(m *ice.Message, arg ...string) {
@ -20,49 +20,34 @@ func (s Portal) List(m *ice.Message, arg ...string) {
kit.If(len(arg) == 0 && m.Length() > 0, func() { m.PushAction(s.PlaceRemove) }) kit.If(len(arg) == 0 && m.Length() > 0, func() { m.PushAction(s.PlaceRemove) })
} }
func (s Portal) PlaceCreate(m *ice.Message, arg ...string) { func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
if m.Option(model.AUTH_TYPE) == ice.AUTO {
arg = append(arg, model.AUTH_TYPE, m.Option(model.AUTH_TYPE, AuthService))
}
if m.WarnNotRight(AuthType(kit.Int(m.Option(model.AUTH_TYPE))) == AuthRoot && !m.IsTech()) {
return
}
if AuthType(kit.Int(m.Option(model.AUTH_TYPE))) == AuthRoot && m.IsTech() {
arg = append(arg, model.STATUS, kit.Format(AuthIssued))
}
from := ""
switch AuthType(kit.Int(m.Option(model.AUTH_TYPE))) { switch AuthType(kit.Int(m.Option(model.AUTH_TYPE))) {
case AuthRoot: case AuthRoot:
from = aaa.ROOT if m.WarnNotRight(!m.IsTech()) {
case AuthCity: return
from = s.findAuthFrom(m, AuthRoot)
case AuthPersonal:
from = s.findAuthFrom(m, AuthCity, model.NAME, m.Option(model.CITY_NAME))
case AuthCompany:
from = s.findAuthFrom(m, AuthCity, model.NAME, m.Option(model.CITY_NAME))
case AuthService:
if city_uid := s.findAuthFrom(m, AuthCity, model.NAME, m.Option(model.CITY_NAME)); city_uid != "" {
from = s.findAuthFrom(m, AuthCompany, model.NAME, m.Option(model.COMPANY_NAME), model.FROM_UID, city_uid)
} }
arg = append(arg, model.STATUS, kit.Format(AuthIssued))
m.Option(model.FROM_UID, aaa.ROOT)
case AuthCity:
m.Option(model.FROM_UID, s.findAuthFrom(m, AuthRoot))
} }
if from == "" { arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.NAME), model.NAME, s.Keys(s.Place, model.INFO), model.INFO, s.Keys(s.Place, model.TYPE), model.TYPE)
if m.Options(arg).Cmdy(s.Place, s.Insert, arg).IsErr() {
return return
} }
s.Portal.PlaceCreate(m, append(arg, model.FROM_UID, m.Option(model.FROM_UID, from), model.USER_UID, m.Option(model.USER_UID))...) m.Cmd(s.UserPlace, s.Insert, kit.Simple(m.OptionSimple(s.Keys(s.Place, model.UID), model.USER_UID), model.ROLE, 1))
s.RecordEventWithName(m.Options(s.Keys(s.Place, model.UID), m.Result()), "")
} }
func (s Portal) PlaceList(m *ice.Message, arg ...string) *ice.Message { func (s Portal) PlaceList(m *ice.Message, arg ...string) *ice.Message {
s.Tables(m, s.Place).FieldsWithCreatedAT(m, s.UserPlace, s.Tables(m, s.Place).FieldsWithCreatedAT(m, s.UserPlace,
model.AUTH_NAME, model.AUTH_TYPE, model.AUTH_STATUS, model.USER_AUTH_ROLE, model.AUTH_UID, model.AUTH_NAME, model.AUTH_INFO, model.AUTH_TYPE, model.USER_AUTH_ROLE, model.AUTH_STATUS,
s.AS(s.Key(s.Place, model.UID), model.AUTH_UID), model.COMPANY_UID,
) )
if len(arg) == 1 { if len(arg) == 1 {
m.Cmdy(s.UserPlace, s.Table.Select, s.Key(s.UserPlace, model.USER_UID), arg[0]) m.Cmdy(s.UserPlace, s.Table.Select, s.Key(s.UserPlace, model.USER_UID), arg[0])
} else if len(arg) == 2 { } else if len(arg) == 2 {
m.FieldsSetDetail().Cmdy(s.UserPlace, s.Table.Select, s.Key(s.UserPlace, model.USER_UID), arg[0], s.Key(s.UserPlace, model.AUTH_UID), arg[1]) m.FieldsSetDetail().Cmdy(s.UserPlace, s.Table.Select, s.Key(s.UserPlace, model.USER_UID), arg[0], s.Key(s.Place, model.UID), arg[1])
} else { } else {
return m return m
} }
s.SelectJoin(m, s.Street, model.NAME, model.CITY_UID)
s.SelectJoinCity(m)
return m return m
} }

View File

@ -43,11 +43,8 @@ type Queue struct {
CompanyUID string `gorm:"type:char(32);index"` CompanyUID string `gorm:"type:char(32);index"`
} }
type Reception struct { type Reception struct {
db.ModelWithUID db.ModelNameInfo
QueueUID string `gorm:"type:char(32);index"` QueueUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32)"`
Name string `gorm:"type:varchar(64)"`
Info string `gorm:"type:varchar(255)"`
} }
type Volume struct { type Volume struct {
db.ModelWithUID db.ModelWithUID
@ -62,17 +59,16 @@ type Volume struct {
} }
type Schedule struct { type Schedule struct {
db.ModelWithUID db.ModelWithUID
QueueUID string `gorm:"type:char(32);index"` QueueUID string `gorm:"type:char(32);index"`
ReceptionUID string `gorm:"type:char(32)"` VolumeUID string `gorm:"type:char(32)"`
VolumeUID string `gorm:"type:char(32)"` UserUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"` CallUID string `gorm:"type:char(32);index"`
CallUID string `gorm:"type:char(32);index"` Status uint8 `gorm:"default:0"`
Status uint8 `gorm:"default:0"` CancelTime db.Time
CancelTime db.Time TakeTime db.Time
TakeTime db.Time CallTime db.Time
CallTime db.Time ExpireTime db.Time
ExpireTime db.Time FinishTime db.Time
FinishTime db.Time
} }
func init() { db.CmdModels("", &UserQueue{}, &Queue{}, &Reception{}, Volume{}, &Schedule{}) } func init() { db.CmdModels("", &UserQueue{}, &Queue{}, &Reception{}, Volume{}, &Schedule{}) }

View File

@ -5,7 +5,7 @@ import "shylinux.com/x/ice"
type open struct{ Volume } type open struct{ Volume }
func (s open) List(m *ice.Message, arg ...string) { func (s open) List(m *ice.Message, arg ...string) {
s.Volume.List(m, arg...).PushAction(s.MarketInsert) s.Volume.List(m, arg...).PushAction(s.MarketInsert).Action(s.Create)
s.Button(m, "") s.Button(m, "")
} }

View File

@ -45,8 +45,11 @@ func (s Schedule) Call(m *ice.Message, arg ...string) {
return return
} }
s.changeStatus(m, ScheduleTake, ScheduleCall, model.CALL_UID, user_uid) s.changeStatus(m, ScheduleTake, ScheduleCall, model.CALL_UID, user_uid)
s.SendMessage(m, m.Append(model.USER_UID), user_uid) m.Info("what %v %v", arg, m.FormatMeta())
s.SendMessage(m, user_uid, m.Append(model.USER_UID)) arg = append(arg[0:1], m.Append(model.UID))
s.SendMessage(m, m.Append(model.USER_UID), user_uid, arg...)
s.GetCommandUID(m)
s.SendMessage(m, user_uid, m.Append(model.USER_UID), arg...)
s.sendTemplate(m, "已叫号", m.Append(model.UID)) s.sendTemplate(m, "已叫号", m.Append(model.UID))
m.ProcessRewrite(model.UID, m.Append(model.UID)) m.ProcessRewrite(model.UID, m.Append(model.UID))
} }

View File

@ -26,7 +26,7 @@ func (s Volume) List(m *ice.Message, arg ...string) *ice.Message {
model.TOTAL, model.COUNT, model.EXPIRE, model.FINISH, model.USER_UID, model.TOTAL, model.COUNT, model.EXPIRE, model.FINISH, model.USER_UID,
) )
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, s.Key(s, model.QUEUE_UID), arg[0]) s.Select(m, s.Key(s, model.QUEUE_UID), arg[0]).Action()
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s, model.QUEUE_UID), arg[0], s.Key(s, model.UID), arg[1]) s.SelectDetail(m, s.Key(s, model.QUEUE_UID), arg[0], s.Key(s, model.UID), arg[1])
} }