This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-08-12 20:17:25 +08:00
parent 6f8fc7fb1e
commit fd2e13dbde
31 changed files with 176 additions and 139 deletions

View File

@ -11,6 +11,8 @@ type apply struct {
Table Table
user user user user
event event event event
order string `data:"3"`
role string `data:"creator"`
portal string `data:"true"` portal string `data:"true"`
domain string `data:"gonganxitong"` domain string `data:"gonganxitong"`
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"`

View File

@ -14,21 +14,25 @@ import (
"shylinux.com/x/mysql-story/src/db" "shylinux.com/x/mysql-story/src/db"
) )
type Tabler interface { type Placer interface {
Inputs(m *ice.Message, arg ...string) Inputs(m *ice.Message, arg ...string)
Select(m *ice.Message, arg ...string) *ice.Message Select(m *ice.Message, arg ...string) *ice.Message
RewriteAppend(m *ice.Message, arg ...string) *ice.Message RewriteAppend(m *ice.Message, arg ...string) *ice.Message
TransValue(m *ice.Message, key string, arg ...string) string TransValue(m *ice.Message, key string, arg ...string) string
TransRole(m *ice.Message, arg ...string) string TransRole(m *ice.Message, arg ...string) string
} }
type UserPlacer interface {
Placer
User(m *ice.Message, arg ...string)
}
type Container interface { type Container interface {
FindOrCreateByName(m *ice.Message, arg ...string) FindOrCreateByName(m *ice.Message, arg ...string)
} }
type Table struct { type Table struct {
db.Table db.Table
UserPlace Tabler UserPlace UserPlacer
Place Tabler Place Placer
Street Container Street Container
inputs string `name:"inputs" role:"void"` inputs string `name:"inputs" role:"void"`
list string `name:"list place_uid uid auto" role:"void"` list string `name:"list place_uid uid auto" role:"void"`
@ -41,6 +45,9 @@ func (s Table) Init(m *ice.Message, arg ...string) {
func (s Table) Exit(m *ice.Message, arg ...string) { func (s Table) Exit(m *ice.Message, arg ...string) {
s.Table.Exit(m, arg...) s.Table.Exit(m, arg...)
} }
func (s Table) AfterMigrate(m *ice.Message, arg ...string) {
kit.If(m.Config(web.PORTAL) == ice.TRUE, func() { Portal{}.Show(m, m.PrefixKey()) })
}
func (s Table) Inputs(m *ice.Message, arg ...string) { func (s Table) Inputs(m *ice.Message, arg ...string) {
switch arg[0] { switch arg[0] {
case model.PLACE_TYPE: case model.PLACE_TYPE:
@ -71,7 +78,7 @@ func (s Table) List(m *ice.Message, arg ...string) *ice.Message {
} }
return m return m
} }
func (s Table) TablesWithRole(m *ice.Message, arg []string, target, userPlace, place Tabler, fields ...ice.Any) *ice.Message { func (s Table) TablesWithRole(m *ice.Message, arg []string, userPlace UserPlacer, place Placer, target Placer, fields ...ice.Any) *ice.Message {
s.Tables(m, kit.JoinWord("LEFT JOIN", s.TableName(kit.TypeName(userPlace)), s.Tables(m, kit.JoinWord("LEFT JOIN", s.TableName(kit.TypeName(userPlace)),
"ON", s.Key(target, model.USER_UID), "=", s.Key(userPlace, model.USER_UID), "ON", s.Key(target, model.USER_UID), "=", s.Key(userPlace, model.USER_UID),
"AND", s.Key(target, s.Keys(place, model.UID)), "=", s.Key(userPlace, s.Keys(place, model.UID)), "AND", s.Key(target, s.Keys(place, model.UID)), "=", s.Key(userPlace, s.Keys(place, model.UID)),
@ -146,13 +153,9 @@ func (s Table) SendTemplate(m *ice.Message, from, user_uid, title string, arg ..
return return
} }
name := kit.Select("", arg, 0) name := kit.Select("", arg, 0)
m.Info("what %v", name)
if name == "" { if name == "" {
m.Info("what %v", name)
name = m.Option(s.Keys(s.Place, model.NAME)) + " " + s.Place.TransValue(m, s.Keys(s.UserPlace, model.ROLE)) name = m.Option(s.Keys(s.Place, model.NAME)) + " " + s.Place.TransValue(m, s.Keys(s.UserPlace, model.ROLE))
m.Info("what %v", s.Keys(s.Place, model.NAME))
} }
m.Info("what %v", name)
uid := kit.Select(m.Option(model.UID), arg, 1) uid := kit.Select(m.Option(model.UID), arg, 1)
place_uid := kit.Select("", arg, 2) place_uid := kit.Select("", arg, 2)
if place_uid == "" { if place_uid == "" {
@ -187,22 +190,16 @@ func (s Table) Display(m *ice.Message, file string) *ice.Message {
return file return file
}))) })))
} }
func (s Table) Link(m *ice.Message, arg ...string) string {
return Portal{}.Link(m, arg...)
}
type Tables struct { type Tables struct {
Table Table
Portal Portal
portal string `data:"true"` portal string `data:"true"`
} }
func (s Tables) Init(m *ice.Message, arg ...string) { func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
s.Portal.Show(m)
}
func (s Tables) Link(m *ice.Message, arg ...string) string {
return s.Portal.Link(m, arg...)
}
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {
}
func newTable() Table { func newTable() Table {
return Table{UserPlace: userPlace{}, Place: place{}, Street: street{}} return Table{UserPlace: userPlace{}, Place: place{}, Street: street{}}
@ -210,13 +207,13 @@ func newTable() Table {
func newTables() Tables { func newTables() Tables {
return Tables{Table: newTable()} return Tables{Table: newTable()}
} }
func NewTable(userPlace, place Tabler, street Container) Table { func NewTable(userPlace UserPlacer, place Placer, street Container) Table {
return Table{UserPlace: userPlace, Place: place, Street: street} return Table{UserPlace: userPlace, Place: place, Street: street}
} }
func NewTables(userPlace, place Tabler, street Container) Tables { func NewTables(userPlace UserPlacer, place Placer, street Container) Tables {
return Tables{Table: NewTable(userPlace, place, street)} return Tables{Table: NewTable(userPlace, place, street)}
} }
func NewPortal(userPlace, place Tabler, street Container) Portal { func NewPortal(userPlace UserPlacer, place Placer, street Container) Portal {
return Portal{Table: Table{UserPlace: userPlace, Place: place, Street: street}} return Portal{Table: Table{UserPlace: userPlace, Place: place, Street: street}}
} }
func (s Portal) getTable() Table { func (s Portal) getTable() Table {
@ -225,17 +222,13 @@ func (s Portal) getTable() Table {
func PortalCmd(portal ice.Any) { func PortalCmd(portal ice.Any) {
h := kit.FileLine(-1, 100) h := kit.FileLine(-1, 100)
p := kit.Keys("web.team", kit.ModPath(-1)) p := kit.Keys("web.team", kit.ModPath(-1))
base := kit.FileLine(1, 100)
cmd := func(name string, data ice.Any) { cmd := func(name string, data 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(cmd.Actions[ice.CTX_INIT].Hand, func(m *icebergs.Message, arg ...string) { cmd.Actions[ice.CTX_INIT].Hand = icebergs.MergeHand(cmd.Actions[ice.CTX_INIT].Hand, func(m *icebergs.Message, arg ...string) {
msg := m.Cmd("web.team.gonganxitong.apply") ice.LoadTrans(m.Spawn(kit.Dict("_template", path.Join(path.Dir(base), "portal.json"))), m.CommandKey(), cmd)
ice.LoadTrans(msg, m.CommandKey(), cmd)
ice.LoadTrans(m, m.CommandKey(), cmd) ice.LoadTrans(m, m.CommandKey(), cmd)
kit.If(mdb.Config(m, web.PORTAL) == ice.TRUE, func() { Portal{}.Show(&ice.Message{Message: m}, m.PrefixKey()) })
})
cmd.Actions["afterMigrate"].Hand = icebergs.MergeHand(cmd.Actions["afterMigrate"].Hand, func(m *icebergs.Message, arg ...string) {
kit.If(mdb.Config(m, web.PORTAL) == ice.TRUE, func() { Portal{}.Show(&ice.Message{Message: m}, m.PrefixKey()) })
}) })
} }
table := portal.(interface{ getTable() Table }).getTable() table := portal.(interface{ getTable() Table }).getTable()
@ -244,5 +237,6 @@ func PortalCmd(portal ice.Any) {
cmd("apply", apply{Table: table}) cmd("apply", apply{Table: table})
cmd("order", order{Table: table}) cmd("order", order{Table: table})
cmd("event", event{Table: table}) cmd("event", event{Table: table})
cmd("member", placeUser{Tables: Tables{Table: table}})
cmd("service", service{}) cmd("service", service{})
} }

View File

@ -11,6 +11,8 @@ import (
type event struct { type event struct {
Table Table
user user user user
order string `data:"2"`
role string `data:"creator"`
portal string `data:"true"` portal string `data:"true"`
domain string `data:"gonganxitong"` domain string `data:"gonganxitong"`
} }

View File

@ -10,11 +10,7 @@ const (
TYPE = "type" TYPE = "type"
ROLE = "role" ROLE = "role"
STATUS = "status" STATUS = "status"
TABLES = "tables"
CONTENT = "content" CONTENT = "content"
ADDRESS = "address"
EMAIL = "email"
AVATAR = "avatar"
OPERATE = "operate" OPERATE = "operate"
OPERATOR = "operator" OPERATOR = "operator"
CREATED_AT = "created_at" CREATED_AT = "created_at"
@ -39,6 +35,10 @@ const (
APPLY_STATUS = "apply_status" APPLY_STATUS = "apply_status"
ORDER_UID = "order_uid" ORDER_UID = "order_uid"
ORDER_STATUS = "order_status" ORDER_STATUS = "order_status"
TABLES = "tables"
EMAIL = "email"
AVATAR = "avatar"
ADDRESS = "address"
) )
type Sess struct { type Sess struct {
@ -71,28 +71,28 @@ type Place struct {
} }
type Street struct { type Street struct {
db.ModelWithUID db.ModelWithUID
CityUID string `gorm:"type:char(32);index"` CityUID string `gorm:"type:char(32);index:idx_city"`
Name string `gorm:"type:char(64);index"` Name string `gorm:"type:char(64);index:idx_city"`
Info string Info string
} }
type City struct { type City struct {
db.ModelWithUID db.ModelWithUID
Name string `gorm:"type:char(32);index"` Name string `gorm:"type:char(64);index"`
} }
type Event struct { type Event struct {
db.ModelWithUID db.ModelWithUID
UserUID string `gorm:"type:char(32);index"` PlaceUID string `gorm:"type:char(32);index:idx_place"`
PlaceUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index:idx_place"`
Index string `gorm:"type:char(32)"` Index string `gorm:"type:char(32)"`
Operate string `gorm:"type:char(32)"` Operate string `gorm:"type:char(32)"`
Args string `gorm:"type:char(32)"` Args string `gorm:"type:char(32)"`
Info string Info string `gorm:"type:varchar(255)"`
} }
type Apply struct { type Apply struct {
db.ModelWithUID db.ModelWithUID
UserUID string `gorm:"type:char(32);index"` PlaceUID string `gorm:"type:char(32);index:idx_place"`
PlaceUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index:idx_place"`
Tables string `gorm:"type:char(32)"` Tables string `gorm:"type:char(32)"`
Status uint8 Status uint8
Role uint8 Role uint8
@ -102,7 +102,7 @@ type Apply struct {
type Order struct { type Order struct {
db.ModelWithUID db.ModelWithUID
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`
ApplyUID string `gorm:"type:char(32)"` ApplyUID string `gorm:"type:char(32);index"`
Status uint8 Status uint8
} }

View File

@ -12,6 +12,8 @@ type order struct {
user user user user
event event event event
apply apply apply apply
order string `data:"4"`
role string `data:"creator"`
portal string `data:"true"` portal string `data:"true"`
domain string `data:"gonganxitong"` domain string `data:"gonganxitong"`
create string `name:"create user_uid* apply_uid* status*"` create string `name:"create user_uid* apply_uid* status*"`

View File

@ -2,10 +2,7 @@ package gonganxitong
import "shylinux.com/x/ice" import "shylinux.com/x/ice"
type place struct { type place struct{ Table }
Table
user user
}
func init() { ice.TeamCtxCmd(place{}) } func init() { ice.TeamCtxCmd(place{}) }

View File

@ -3,12 +3,13 @@ package gonganxitong
import "shylinux.com/x/ice" import "shylinux.com/x/ice"
type placeUser struct { type placeUser struct {
order string `data:"5"`
Tables Tables
userPlace userPlace
} }
func (s placeUser) List(m *ice.Message, arg ...string) { func (s placeUser) List(m *ice.Message, arg ...string) {
m.Cmdy(s.userPlace, s.userPlace.User, arg).Action() s.Display(m, "")
m.Cmdy(s.UserPlace, s.UserPlace.User, arg).Action()
} }
func init() { ice.TeamCtxCmd(placeUser{}) } func init() { ice.TeamCtxCmd(placeUser{Tables: newTables()}) }

View File

@ -21,13 +21,13 @@ $output>div.action div.item.button input:hover { background-color:var(--hover-bg
$output>div.action div.item.button i { display:none; } $output>div.action div.item.button i { display:none; }
$output>div.action div.item.button span { display:none; } $output>div.action div.item.button span { display:none; }
$output>fieldset table.content td { box-shadow:none; } $output>fieldset table.content td { box-shadow:none; }
$output span.role { border:var(--box-notice); color:var(--notice-bg-color); } $output span.type { border:var(--box-notice); color:var(--notice-bg-color); padding:0 3px; }
$output span.type { border:var(--box-notice); color:var(--notice-bg-color); } $output span.role { border:var(--box-notice); color:var(--notice-bg-color); padding:0 3px; }
// $output span.status { border:var(--box-notice); color:var(--notice-bg-color); } // $output span.status { border:var(--box-notice); color:var(--notice-bg-color); }
$output span.type.danger { border-color:var(--box-danger); color:var(--danger-bg-color); } $output span.type.danger { border:var(--box-danger); color:var(--danger-bg-color); }
$output span.role.danger { border-color:var(--box-danger); color:var(--danger-bg-color); } $output span.role.danger { border:var(--box-danger); color:var(--danger-bg-color); }
$output span.status.danger { border-color:var(--box-danger); color:var(--danger-bg-color); } $output span.status.danger { border:var(--box-danger); color:var(--danger-bg-color); }
$output span.status.expire { border-color:var(--box-danger); color:var(--danger-bg-color); } // $output span.status.expire { border:var(--box-danger); color:var(--danger-bg-color); }
$output table.content.detail tr.action input.icons { display:unset; } $output table.content.detail tr.action input.icons { display:unset; }
$output table.content.detail tr.action i { display:none; } $output table.content.detail tr.action i { display:none; }
$output table.content td.action i { display:none; } $output table.content td.action i { display:none; }

View File

@ -2,6 +2,7 @@ package gonganxitong
import ( import (
"shylinux.com/x/ice" "shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
@ -71,7 +72,7 @@ func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
} else if s.Street.FindOrCreateByName(m, arg...); m.IsErr() { } else if s.Street.FindOrCreateByName(m, arg...); m.IsErr() {
return return
} }
name := m.Option(model.NAME) name := m.Option(s.Keys(s.Place, model.NAME))
arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.TYPE), model.TYPE) arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.TYPE), model.TYPE)
arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.NAME), model.NAME) arg = kit.TransArgKeys(arg, s.Keys(s.Place, model.NAME), model.NAME)
if m.Cmdy(s.Place, s.Create, arg[2:]).IsErr() { if m.Cmdy(s.Place, s.Create, arg[2:]).IsErr() {
@ -106,18 +107,20 @@ func (s Portal) SetIcons(m *ice.Message, arg ...string) {
func init() { ice.TeamCtxCmd(Portal{Table: newTable()}) } func init() { ice.TeamCtxCmd(Portal{Table: newTable()}) }
type portal struct {
Portal
name string `data:"公安系统"`
}
func init() { ice.TeamCtxCmd(portal{Portal: Portal{Table: newTable()}}) }
func (s Portal) Create(m *ice.Message, arg ...string) { func (s Portal) Create(m *ice.Message, arg ...string) {
var _cmd *ice.Command args := []string{ctx.INDEX, m.Option(ctx.INDEX)}
m.Search(m.Option(ctx.INDEX), func(key string, cmd *ice.Command) { _cmd = cmd })
msg := s.Hash.Select(m.Spawn(), m.Option(ctx.INDEX)) msg := s.Hash.Select(m.Spawn(), m.Option(ctx.INDEX))
s.Hash.Create(m, ctx.INDEX, m.Option(ctx.INDEX), mdb.NAME, _cmd.Help, mdb.ICONS, _cmd.Icon, mdb.TIME, msg.Append(mdb.TIME)) if msg.Length() > 0 {
args = append(args, mdb.TIME, msg.Append(mdb.TIME))
}
m.Search(m.Option(ctx.INDEX), func(key string, cmd *ice.Command) {
args = append(args, mdb.NAME, cmd.Help, mdb.ICONS, cmd.Icon)
kit.For([]string{mdb.ORDER, mdb.TYPE, aaa.ROLE, mdb.VIEW}, func(key string) {
value := m.Conf(m.Option(ctx.INDEX), kit.Keym(key))
args = append(args, key, kit.Select(value, msg.Append(key)))
})
})
s.Hash.Create(m, args...)
} }
func (s Portal) Show(m *ice.Message, arg ...string) { func (s Portal) Show(m *ice.Message, arg ...string) {
key := m.PrefixKey() key := m.PrefixKey()
@ -127,3 +130,10 @@ func (s Portal) Link(m *ice.Message, arg ...string) string {
return m.MergePodCmd("", m.Prefix(web.PORTAL)) + "?debug=true" + return m.MergePodCmd("", m.Prefix(web.PORTAL)) + "?debug=true" +
"#" + kit.TrimSuffix(kit.Join([]string{arg[0], kit.Select(m.Prefix("apply"), arg, 1), kit.Select("", arg, 2)}, ":"), ":") "#" + kit.TrimSuffix(kit.Join([]string{arg[0], kit.Select(m.Prefix("apply"), arg, 1), kit.Select("", arg, 2)}, ":"), ":")
} }
type portal struct {
Portal
name string `data:"公安系统"`
}
func init() { ice.TeamCtxCmd(portal{Portal: Portal{Table: newTable()}}) }

View File

@ -11,6 +11,7 @@
"event": "事件流", "event": "事件流",
"email": "邮箱配置", "email": "邮箱配置",
"placeUser": "服务人员", "placeUser": "服务人员",
"member": "服务人员",
"cancel": "取消", "cancel": "取消",
"submit": "提交", "submit": "提交",
"finish": "完成", "finish": "完成",
@ -28,7 +29,8 @@
"order": "https://img.icons8.com/officel/80/receipt-approved.png", "order": "https://img.icons8.com/officel/80/receipt-approved.png",
"event": "https://img.icons8.com/officel/80/property-with-timer.png", "event": "https://img.icons8.com/officel/80/property-with-timer.png",
"email": "https://img.icons8.com/officel/80/reading-confirmation.png", "email": "https://img.icons8.com/officel/80/reading-confirmation.png",
"placeUser": "https://img.icons8.com/officel/80/person-at-home.png" "placeUser": "https://img.icons8.com/officel/80/person-at-home.png",
"member": "https://img.icons8.com/officel/80/person-at-home.png"
}, },
"style": { "style": {
"placeRemove": "danger" "placeRemove": "danger"

View File

@ -6,7 +6,11 @@ import (
"shylinux.com/x/community/src/gonganxitong/model" "shylinux.com/x/community/src/gonganxitong/model"
) )
type qrcode struct{ Tables } type qrcode struct {
order string `data:"1"`
role string `data:"creator"`
Tables
}
func (s qrcode) List(m *ice.Message, arg ...string) { func (s qrcode) List(m *ice.Message, arg ...string) {
m.Cmdy(s.UserPlace, m.Option(model.USER_UID), arg[0]).Cut(model.CITY_NAME, s.Keys(s.Street, model.NAME), s.Keys(s.Place, model.NAME)) m.Cmdy(s.UserPlace, m.Option(model.USER_UID), arg[0]).Cut(model.CITY_NAME, s.Keys(s.Street, model.NAME), s.Keys(s.Place, model.NAME))

View File

@ -6,6 +6,7 @@ import (
"shylinux.com/x/ice" "shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
// "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
@ -19,7 +20,9 @@ import (
type service struct { type service struct {
Table Table
order string `data:"100"`
portal string `data:"true"` portal string `data:"true"`
role string `data:"creator"`
domain string `data:"gonganxitong"` domain string `data:"gonganxitong"`
update string `name:"update name icon index"` update string `name:"update name icon index"`
autogen string `name:"autogen name* help* class* table*" icon:"bi bi-plus-square-dotted"` autogen string `name:"autogen name* help* class* table*" icon:"bi bi-plus-square-dotted"`
@ -62,6 +65,7 @@ func (s service) Autogen(m *ice.Message, arg ...string) {
m.Cmd(nfs.DEFS, path.Join(p, m.Option(mdb.TABLE)+".go"), m.Template(from+"homework.go")) m.Cmd(nfs.DEFS, path.Join(p, m.Option(mdb.TABLE)+".go"), m.Template(from+"homework.go"))
m.Cmd(nfs.DEFS, path.Join(p, m.Option(mdb.TABLE)+".js"), m.Template(from+"homework.js")) m.Cmd(nfs.DEFS, path.Join(p, m.Option(mdb.TABLE)+".js"), m.Template(from+"homework.js"))
}) })
// m.Cmd(cli.SYSTEM, "gofmt", "-w", p)
} }
func (s service) Compile(m *ice.Message, arg ...string) { func (s service) Compile(m *ice.Message, arg ...string) {
m.Cmdy(code.VIMER, code.COMPILE) m.Cmdy(code.VIMER, code.COMPILE)

View File

@ -21,7 +21,7 @@ func (s sess) Create(m *ice.Message, arg ...string) {
} }
func (s sess) Check(m *ice.Message, arg ...string) { func (s sess) Check(m *ice.Message, arg ...string) {
msg := s.Table.Select(m.Spawn(), model.UID, arg[0]) msg := s.Table.Select(m.Spawn(), model.UID, arg[0])
msg = m.Cmd(s.user, s.user.Select, model.UID, msg.Append(model.USER_UID)) msg = m.Cmd(s.user, s.Select, model.UID, msg.Append(model.USER_UID))
m.Option(ice.MSG_USERROLE, aaa.VOID) m.Option(ice.MSG_USERROLE, aaa.VOID)
m.Option(ice.MSG_USERNAME, msg.Append(model.UID)) m.Option(ice.MSG_USERNAME, msg.Append(model.UID))
m.Option(ice.MSG_USERNICK, msg.Append(model.NAME)) m.Option(ice.MSG_USERNICK, msg.Append(model.NAME))

View File

@ -9,17 +9,15 @@ func init() { ice.TeamCtxCmd({{.Option "class"}}{}) }
type {{.Option "Class"}}Type int type {{.Option "Class"}}Type int
const ( const (
{{.Option "Class"}}Term {{.Option "Class"}}Type = iota {{.Option "Class"}}RD {{.Option "Class"}}Type = iota
{{.Option "Class"}}Weekly {{.Option "Class"}}OP
{{.Option "Class"}}Step {{.Option "Class"}}HR
{{.Option "Class"}}Free
) )
var {{.Option "Class"}}TypeList = map[{{.Option "Class"}}Type]string{ var {{.Option "Class"}}TypeList = map[{{.Option "Class"}}Type]string{
{{.Option "Class"}}Term: "term", {{.Option "Class"}}RD: "RD",
{{.Option "Class"}}Weekly: "weekly", {{.Option "Class"}}OP: "OP",
{{.Option "Class"}}Step: "step", {{.Option "Class"}}HR: "HR",
{{.Option "Class"}}Free: "free",
} }
func (s {{.Option "Class"}}Type) String() string { return {{.Option "Class"}}TypeList[s] } func (s {{.Option "Class"}}Type) String() string { return {{.Option "Class"}}TypeList[s] }

View File

@ -8,10 +8,6 @@ import (
"{{.Option "module"}}/model" "{{.Option "module"}}/model"
) )
type Tables struct {
guanlixitong.Tables
list string `name:"list {{.Option "class"}}_uid uid auto" role:"void"`
}
type Table struct { type Table struct {
guanlixitong.Table guanlixitong.Table
list string `name:"list {{.Option "class"}}_uid uid auto" role:"void"` list string `name:"list {{.Option "class"}}_uid uid auto" role:"void"`
@ -44,3 +40,24 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
s.Table.RewriteAppend(m) s.Table.RewriteAppend(m)
return m return m
} }
func (s Table) checkRole(m *ice.Message, arg ...User{{.Option "Class"}}Role) bool {
kit.If(len(arg) == 0, func() { arg = append(arg, User{{.Option "Class"}}Leader) })
role := User{{.Option "Class"}}Role(kit.Int(m.Cmd(user{{.Option "Class"}}{}, s.Select, m.OptionSimple(model.{{.Option "CLASS"}}_UID, model.USER_UID)).Append(model.ROLE)))
for _, v := range append(arg, User{{.Option "Class"}}Creator) {
if role == v {
return true
}
}
return !m.WarnNotRight(true, role.String())
}
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) *ice.Message {
s.Table.RecordEvent(m, m.Option(model.{{.Option "CLASS"}}_UID), info, kit.Select(m.Option(model.UID), arg, 0))
return m
}
type Tables struct {
Table
portal string `data:"true"`
}
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}

View File

@ -12,14 +12,17 @@ type {{.Option "table"}} struct {
{{.Option "class"}} {{.Option "class"}} {{.Option "class"}} {{.Option "class"}}
user{{.Option "Class"}} user{{.Option "Class"}} user{{.Option "Class"}} user{{.Option "Class"}}
portal string `data:"true"` portal string `data:"true"`
create string `name:"create content*" role:"void"` create string `name:"create title* content*" role:"void"`
} }
func (s {{.Option "table"}}) Create(m *ice.Message, arg ...string) { func (s {{.Option "table"}}) Create(m *ice.Message, arg ...string) {
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.{{.Option "CLASS"}}_UID))...) if s.checkRole(m) {
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.{{.Option "CLASS"}}_UID))...)
s.recordEvent(m, m.Trans("create {{.Option "table"}} ", "创建场景数据 ")+m.Option(model.TITLE), m.Result())
}
} }
func (s {{.Option "table"}}) List(m *ice.Message, arg ...string) { func (s {{.Option "table"}}) List(m *ice.Message, arg ...string) {
s.TablesWithRole(m, arg, s, s.user{{.Option "Class"}}, s.{{.Option "class"}}, model.CONTENT).Display("") s.TablesWithRole(m, arg, s.user{{.Option "Class"}}, s.{{.Option "class"}}, s, model.TITLE, model.CONTENT).Display("")
} }
func init() { ice.TeamCtxCmd({{.Option "table"}}{}) } func init() { ice.TeamCtxCmd({{.Option "table"}}{}) }

View File

@ -1,11 +1,13 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.title), msg.Option("_share_content", value.content) }
can.onimport.itemcards(can, msg, function(value) { return [ can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.user_name}, {view: html.TITLE, list: [{text: value.title}]},
{text: [can.user.transValue(can, value, "user_{{.Option "class"}}_role"), "", aaa.ROLE]}, {view: html.STATUS, list: [
{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)},
{text: value.user_name}, {text: [can.user.transValue(can, value, "user_{{.Option "class"}}_role"), "", [aaa.ROLE, can.onimport.roleStyle(can, value, "user_{{.Option "class"}}_role")]]},
]}, ]},
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)},]},
{view: html.OUTPUT, list: [{text: value.content}]}, {view: html.OUTPUT, list: [{text: value.content}]},
] }) ] })
}, },
}) })

View File

@ -7,6 +7,7 @@ const (
NAME = "name" NAME = "name"
TYPE = "type" TYPE = "type"
ROLE = "role" ROLE = "role"
TITLE = "title"
CONTENT = "content" CONTENT = "content"
USER_UID = "user_uid" USER_UID = "user_uid"
USER_{{.Option "CLASS"}}_ROLE = "user_{{.Option "class"}}_role" USER_{{.Option "CLASS"}}_ROLE = "user_{{.Option "class"}}_role"
@ -27,14 +28,15 @@ type User{{.Option "Class"}} struct {
type {{.Option "Class"}} struct { type {{.Option "Class"}} struct {
db.ModelWithUID db.ModelWithUID
CompanyUID string `gorm:"type:char(32);index"` CompanyUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:varchar(255)"` Name string `gorm:"type:char(64)"`
Type uint8 Type uint8
} }
type {{.Option "Table"}} struct { type {{.Option "Table"}} struct {
db.ModelWithUID db.ModelWithUID
{{.Option "Class"}}UID string `gorm:"type:char(32);index"` {{.Option "Class"}}UID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`
Content string `gorm:"type:varchar(255)"` Title string `gorm:"type:char(64)"`
Content string
} }

View File

@ -9,7 +9,7 @@ type Portal struct {
gonganxitong.Portal gonganxitong.Portal
name string `data:"{{.Option "help"}}"` name string `data:"{{.Option "help"}}"`
list string `name:"list {{.Option "class"}}_uid index uid auto" role:"void"` list string `name:"list {{.Option "class"}}_uid index uid auto" role:"void"`
placeCreate string `name:"placeCreate city_name* company_name* name*" role:"void"` placeCreate string `name:"placeCreate city_name* company_name* {{.Option "class"}}_name*" role:"void"`
} }
func init() { func init() {

View File

@ -4,20 +4,24 @@
"placeRemove": "删除场景", "placeRemove": "删除场景",
"{{.Option "table"}}": "场景应用", "{{.Option "table"}}": "场景应用",
"icons": { "icons": {
"{{.Option "table"}}": "https://img.icons8.com/officel/80/activity-grid.png", "{{.Option "table"}}": "https://img.icons8.com/officel/80/activity-grid.png"
"service": "https://img.icons8.com/officel/80/activity-grid.png"
}, },
"input": { "input": {
"My {{.Option "Class"}}": "我的场景", "My {{.Option "Class"}}": "我的场景",
"user_{{.Option "class"}}_role": "用户角色", "user_{{.Option "class"}}_role": "用户角色",
"{{.Option "class"}}_uid": "场景",
"{{.Option "class"}}_name": "场景名称", "{{.Option "class"}}_name": "场景名称",
"{{.Option "class"}}_type": "场景类型" "{{.Option "class"}}_type": "场景类型"
}, },
"value": { "value": {
"user_{{.Option "class"}}_role": { "user_{{.Option "class"}}_role": {
"creator": "创建人", "creator": "创建人",
"visitor": "访客" "visitor": "访客",
"leader": "管理人员",
"worker": "工作人员",
"server": "服务人员",
"style": {
"creator": "danger"
}
}, },
"{{.Option "class"}}_type": { "{{.Option "class"}}_type": {
"term": "学期制", "term": "学期制",

View File

@ -12,6 +12,7 @@ type user{{.Option "Class"}} struct {
} }
func (s user{{.Option "Class"}}) User(m *ice.Message, arg ...string) { func (s user{{.Option "Class"}}) User(m *ice.Message, arg ...string) {
s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE)
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.{{.Option "CLASS"}}_UID, arg[0]) s.Select(m, model.{{.Option "CLASS"}}_UID, arg[0])
} else if len(arg) == 2 { } else if len(arg) == 2 {
@ -26,12 +27,12 @@ func (s user{{.Option "Class"}}) User(m *ice.Message, arg ...string) {
func (s user{{.Option "Class"}}) List(m *ice.Message, arg ...string) { func (s user{{.Option "Class"}}) List(m *ice.Message, arg ...string) {
s.Tables(m, s.{{.Option "class"}}).FieldsWithCreatedAT(m, s, s.Tables(m, s.{{.Option "class"}}).FieldsWithCreatedAT(m, s,
model.{{.Option "CLASS"}}_NAME, model.{{.Option "CLASS"}}_TYPE, model.USER_{{.Option "CLASS"}}_ROLE, model.{{.Option "CLASS"}}_NAME, model.{{.Option "CLASS"}}_TYPE, model.USER_{{.Option "CLASS"}}_ROLE,
model.{{.Option "CLASS"}}_UID, model.COMPANY_UID, model.COMPANY_UID, model.{{.Option "CLASS"}}_UID,
) )
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.USER_UID, arg[0]) s.Select(m, model.USER_UID, arg[0])
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s.{{.Option "class"}}, model.UID), arg[1]) s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s, model.{{.Option "CLASS"}}_UID), arg[1])
} else { } else {
return return
} }
@ -47,11 +48,17 @@ type User{{.Option "Class"}}Role int
const ( const (
User{{.Option "Class"}}Creator User{{.Option "Class"}}Role = iota User{{.Option "Class"}}Creator User{{.Option "Class"}}Role = iota
User{{.Option "Class"}}Visitor User{{.Option "Class"}}Visitor
User{{.Option "Class"}}Leader
User{{.Option "Class"}}Worker
User{{.Option "Class"}}Server
) )
var User{{.Option "Class"}}RoleList = map[User{{.Option "Class"}}Role]string{ var User{{.Option "Class"}}RoleList = map[User{{.Option "Class"}}Role]string{
User{{.Option "Class"}}Creator: "creator", User{{.Option "Class"}}Creator: "creator",
User{{.Option "Class"}}Visitor: "visitor", User{{.Option "Class"}}Visitor: "visitor",
User{{.Option "Class"}}Leader: "leader",
User{{.Option "Class"}}Worker: "worker",
User{{.Option "Class"}}Server: "server",
} }
func (s User{{.Option "Class"}}Role) String() string { return User{{.Option "Class"}}RoleList[s] } func (s User{{.Option "Class"}}Role) String() string { return User{{.Option "Class"}}RoleList[s] }

View File

@ -6,6 +6,7 @@ import (
"shylinux.com/x/ice" "shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model" "shylinux.com/x/community/src/gonganxitong/model"
@ -13,9 +14,10 @@ import (
type user struct { type user struct {
Table Table
template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"` community string `data:"20240724-community"`
create string `name:"create open_id* name usernick"` template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"`
email string `name:"email email*"` create string `name:"create open_id* name usernick"`
email string `name:"email email*"`
} }
func (s user) Create(m *ice.Message, arg ...string) { func (s user) Create(m *ice.Message, arg ...string) {
@ -43,6 +45,10 @@ 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) 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
if ice.Info.NodeName != m.Config("community") {
m.AdminCmd(web.SPACE, m.Config("community"), m.PrefixKey(), m.ActionKey(), arg, kit.Dict(ice.MSG_USERROLE, aaa.TECH))
return
}
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))
m.Cmdy("web.chat.wx.template", "", m.Config(nfs.TEMPLATE), msg.Append(model.OPEN_ID), kit.Select("", arg, 2), m.Cmdy("web.chat.wx.template", "", m.Config(nfs.TEMPLATE), msg.Append(model.OPEN_ID), kit.Select("", arg, 2),
"thing7", kit.Select("", arg, 3), "thing12", kit.Select("", arg, 4), "character_string2", kit.Cut(kit.Select("", arg, 5), 6), "thing7", kit.Select("", arg, 3), "thing12", kit.Select("", arg, 4), "character_string2", kit.Cut(kit.Select("", arg, 5), 6),

View File

@ -30,14 +30,10 @@ func (s userPlace) User(m *ice.Message, arg ...string) {
func (s userPlace) List(m *ice.Message, arg ...string) { func (s userPlace) List(m *ice.Message, arg ...string) {
s.Tables(m, s.place, s.street, s.city).FieldsWithCreatedAT(m, s, s.Tables(m, s.place, s.street, s.city).FieldsWithCreatedAT(m, s,
model.PLACE_NAME, model.PLACE_TYPE, model.USER_PLACE_ROLE, model.PLACE_NAME, model.PLACE_TYPE, model.USER_PLACE_ROLE,
model.PLACE_UID, model.CITY_NAME, model.STREET_NAME, model.PLACE_ADDRESS, model.CITY_NAME, model.STREET_NAME, model.PLACE_ADDRESS, model.PLACE_UID,
) )
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.USER_UID, arg[0]) s.Select(m, model.USER_UID, arg[0])
} else if len(arg) == 2 {
s.SelectDetail(m, model.USER_UID, arg[0], model.PLACE_UID, arg[1])
} else {
return
} }
s.RewriteAppend(m) s.RewriteAppend(m)
} }

View File

@ -5,8 +5,9 @@ import (
_ "shylinux.com/x/community/src/gonganxitong" _ "shylinux.com/x/community/src/gonganxitong"
_ "shylinux.com/x/community/src/gonganxitong/express" _ "shylinux.com/x/community/src/gonganxitong/express"
_ "shylinux.com/x/community/src/yuehaoxitong" _ "shylinux.com/x/community/src/yuehaoxitong"
_ "shylinux.com/x/community/src/baoanxitong"
) )
func main() { print(ice.Run()) } func main() { print(ice.Run()) }

View File

@ -1,13 +1,12 @@
package {{.Option "zone"}} package ludengguanli
import "shylinux.com/x/ice" import "shylinux.com/x/ice"
type {{.Option "name"}} struct { type good struct {
Table Tables
} }
func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) { func (s good) List(m *ice.Message, arg ...string) {
s.Table.List(m, arg...)
} }
func init() { ice.TeamCtxCmd({{.Option "name"}}{}) } func init() { ice.TeamCtxCmd(good{}) }

View File

@ -1,10 +1,10 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.itemcards(can, msg, function(value) { if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.title), msg.Option("_share_content", value.content) }
return [ can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list:[{text: [value.name||value.user_name]}]}, {view: html.TITLE, list: [{text: value.title}]},
{view: html.STATUS, list: [value.uid && {text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at||value.updated_at)}]}, {view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}, {text: value.user_name}]},
] {view: html.OUTPUT, list: [{text: value.content}]},
}) ] })
}, },
}) })

View File

@ -61,9 +61,7 @@ type Tables struct {
portal string `data:"true"` portal string `data:"true"`
} }
func (s Tables) Init(m *ice.Message, arg ...string) { func (s Tables) Init(m *ice.Message, arg ...string) { s.Portal.Show(m) }
s.Portal.Show(m)
}
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) { func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {
} }

View File

@ -44,13 +44,13 @@ type UserQueue struct {
type Queue struct { type Queue struct {
db.ModelWithUID db.ModelWithUID
CompanyUID string `gorm:"type:char(32);index"` CompanyUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:varchar(64)"` Name string `gorm:"type:char(64)"`
Type uint8 Type uint8
} }
type Reception struct { type Reception struct {
db.ModelWithUID db.ModelWithUID
QueueUID string `gorm:"type:char(32);index"` QueueUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:varchar(64)"` Name string `gorm:"type:char(64)"`
} }
type Volume struct { type Volume struct {
db.ModelWithUID db.ModelWithUID

View File

@ -1,14 +0,0 @@
package yuehaoxitong
import "shylinux.com/x/ice"
type queueUser struct {
Tables
userQueue userQueue
}
func (s queueUser) List(m *ice.Message, arg ...string) {
m.Cmdy(s.userQueue, s.userQueue.User, arg)
}
func init() { ice.TeamCtxCmd(queueUser{}) }

View File

@ -18,7 +18,7 @@ type reception struct {
func (s reception) Create(m *ice.Message, arg ...string) { func (s reception) Create(m *ice.Message, arg ...string) {
if s.checkRole(m) { if s.checkRole(m) {
s.Table.Create(m, append(arg, m.OptionSimple(model.QUEUE_UID)...)...) s.Table.Create(m, append(arg, m.OptionSimple(model.QUEUE_UID)...)...)
s.RecordEvent(m, m.Trans("create reception ", "创建服务场所 ")+m.Option(mdb.NAME), m.Result()) s.recordEvent(m, m.Trans("create reception ", "创建服务场所 ")+m.Option(mdb.NAME), m.Result())
} }
} }
func (s reception) List(m *ice.Message, arg ...string) { func (s reception) List(m *ice.Message, arg ...string) {

View File

@ -17,6 +17,8 @@ func (s userQueue) User(m *ice.Message, arg ...string) {
s.Select(m, model.QUEUE_UID, arg[0]) s.Select(m, model.QUEUE_UID, arg[0])
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, model.QUEUE_UID, arg[0], model.UID, arg[1]) s.SelectDetail(m, model.QUEUE_UID, arg[0], model.UID, arg[1])
} else {
return
} }
m.RenameAppend(model.ROLE, model.USER_QUEUE_ROLE) m.RenameAppend(model.ROLE, model.USER_QUEUE_ROLE)
s.SelectJoinUser(m) s.SelectJoinUser(m)
@ -25,12 +27,10 @@ func (s userQueue) User(m *ice.Message, arg ...string) {
func (s userQueue) List(m *ice.Message, arg ...string) { func (s userQueue) List(m *ice.Message, arg ...string) {
s.Tables(m, s.queue).FieldsWithCreatedAT(m, s, s.Tables(m, s.queue).FieldsWithCreatedAT(m, s,
model.QUEUE_NAME, model.QUEUE_TYPE, model.USER_QUEUE_ROLE, model.QUEUE_NAME, model.QUEUE_TYPE, model.USER_QUEUE_ROLE,
model.QUEUE_UID, model.COMPANY_UID, model.COMPANY_UID, model.QUEUE_UID,
) )
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.USER_UID, arg[0]) s.Select(m, model.USER_UID, arg[0])
} else if len(arg) == 2 {
s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s, model.QUEUE_UID), arg[1])
} }
s.SelectJoinCompany(m) s.SelectJoinCompany(m)
s.SelectJoinCity(m) s.SelectJoinCity(m)