This commit is contained in:
IT 老营长 @云轩领航-创始人 2025-05-19 18:57:36 +08:00
parent 1565780f04
commit 896f671d60
9 changed files with 100 additions and 15 deletions

79
src/gonganxitong/clean.go Normal file
View File

@ -0,0 +1,79 @@
package gonganxitong
import (
"strings"
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model"
)
type clean struct {
Tables
list string `name:"list place_uid uid auto" help:"清理" role:"tech"`
}
func (s clean) List(m *ice.Message, arg ...string) {
if !m.IsTech() {
return
}
if len(arg) == 0 {
s.Tables.Tables(m, kit.Format("left join %s on %s = %s", s.TableNames(s.UserPlace), s.Key(s.UserPlace, s.Keys(s.Place, model.UID)), s.Key(s.Place, model.UID)))
s.Fields(m, s.Key(s.Place, model.UID), s.Key(s.Place, model.CREATED_AT), s.Key(s.Place, model.NAME), "count(*) AS count", s.Key(s.UserPlace, model.USER_UID)).Groups(m, s.Key(s.Place, model.UID))
s.Orders(m, model.COUNT, s.Key(s.Place, model.CREATED_AT)).Limit(m, 300)
// m.Cmdy(s.Place, s.Select, kit.Format("%s IS NULL", s.Key(s.UserPlace, model.DELETED_AT)))
m.Cmdy(s.Place, s.Select)
m.RenameAppend(model.UID, s.Keys(s.Place, model.UID))
m.PushAction(s.Open, s.Member).Action()
s.SelectJoinUser(m)
} else if len(arg) == 1 {
for k, h := range m.Target().Commands {
if c, ok := m.Target().Configs[k]; !ok || kit.Value(c.Value, "meta.model") == nil {
continue
}
m.Push("cmd", k)
m.Push("uid", k)
m.Push("name", h.Name)
m.Push("help", h.Help)
m.Push("actions", len(h.Actions))
PLACE_UID := kit.Split(h.Name)[1]
s.Fields(m, "count(*) AS count")
msg := m.Cmd(m.Prefix(k), s.Select, PLACE_UID, arg[0])
m.Push("count", msg.Append("count"))
}
m.SortIntR("count,cmd")
m.Action(s.Prune)
} else {
h := m.Target().Commands[arg[1]]
PLACE_UID := kit.Split(h.Name)[1]
s.Fields(m, "*")
if kit.TypeName(s.Place) == arg[1] {
m.Cmdy(m.Prefix(arg[1]), s.Select, model.UID, arg[0])
} else {
m.Cmdy(m.Prefix(arg[1]), s.Select, PLACE_UID, arg[0])
}
}
}
func (s clean) Prune(m *ice.Message, arg ...string) {
for k, h := range m.Target().Commands {
if c, ok := m.Target().Configs[k]; !ok || kit.Value(c.Value, "meta.model") == nil {
continue
}
if k == "service" {
continue
}
PLACE_UID := kit.Split(h.Name)[1]
m.Cmd(m.Prefix(k), s.Exec, kit.Format("update %s set deleted_at = %q where %s = %q", s.TableName(k), m.Time(), PLACE_UID, arg[0]))
}
m.Cmd(s.Prefix(m, s.Place), s.Exec, kit.Format("update %s set deleted_at = %q where %s = %q", s.TableNames(s.Place), m.Time(), model.UID, arg[0]))
}
func (s clean) Open(m *ice.Message, arg ...string) {
m.ProcessOpen(m.MergePodCmd("", s.PrefixPortal(m), m.OptionSimple(s.Keys(s.Place, model.UID))))
}
func (s clean) Member(m *ice.Message, arg ...string) {
m.ProcessOpen(m.MergePodCmd("", s.PrefixPortal(m), m.OptionSimple(s.Keys(s.Place, model.UID))) +
"#" + strings.Join([]string{m.Option(s.Keys(s.Place, model.UID)), s.Prefix(m, member{})}, ":"))
}
func init() { ice.TeamCtxCmd(clean{Tables: newTables()}) }

View File

@ -550,6 +550,9 @@ func (s Table) Prefix(m *ice.Message, target ice.Any) string {
func (s Table) PrefixPortal(m *ice.Message) string {
return m.Prefix(kit.TypeName(Portal{}))
}
func (s Table) PrefixMember(m *ice.Message) string {
return m.Prefix(kit.TypeName(member{}))
}
func (s Table) findSpaceCmd(m *ice.Message, cmd ice.Any) ice.Any {
cmds := ice.GetTypeKey(cmd)
if space, ok := cmdSpace[cmds]; ok && space != ice.Info.NodeName {

View File

@ -1,2 +1,4 @@
body.width1 $output>div.item.myself div.title span { font-weight:bold; }
body.width1 $output>div.item.card div.title span.role { margin-left:auto; }
$output>div.list>div.item.myself { position:sticky; top:0; bottom:0; z-index:2; }
$output>div.list>div.item.myself:not(:hover) { background-color:var(--plugin-bg-color) !important; }
$output>div.list>div.item.myself div.title span { font-weight:bold; }
body.width1 $output>div.list>div.item.card div.title span.role { margin-left:auto; }

View File

@ -86,10 +86,8 @@ func (s member) UserInfo(m *ice.Message, arg ...string) {
func (s member) List(m *ice.Message, arg ...string) {
USER_PLACE_ROLE := s.Keys(s.UserPlace, model.ROLE)
user_uid, isLeader, isCreator := m.Option(model.USER_UID), s.IsLeader(m), s.IsCreator(m)
s.FieldsWithCreatedAT(m, s.UserPlace,
model.INFO,
model.USER_UID, s.Keys(s.UserPlace, model.ROLE), s.AS(s.Key(s.UserPlace, model.STATUS), model.MEMBER_STATUS))
s.Limit(m, 300)
s.FieldsWithCreatedAT(m, s.UserPlace, s.AS(s.Key(s.UserPlace, model.STATUS), model.MEMBER_STATUS),
USER_PLACE_ROLE, model.INFO, model.USER_UID).Limit(m, 300)
if len(arg) == 1 {
m.Cmdy(s.UserPlace, s.Select, s.Keys(s.Place, model.UID), arg[0]).Action()
} else if len(arg) == 2 {
@ -97,7 +95,7 @@ func (s member) List(m *ice.Message, arg ...string) {
} else {
return
}
defer m.Sort(kit.Fields(model.MEMBER_STATUS, USER_PLACE_ROLE, "auth_status", model.CREATED_AT))
defer m.Sort(kit.Fields(model.MEMBER_STATUS, USER_PLACE_ROLE, model.AUTH_STATUS, model.CREATED_AT))
s.SelectJoinUser(m, model.NAME, model.INFO, model.AVATAR, model.AUTH_UID)
s.SelectJoinAuth(m)
m.Table(func(value ice.Maps) {
@ -109,10 +107,9 @@ func (s member) List(m *ice.Message, arg ...string) {
}
}
button := []ice.Any{}
if value[model.USER_UID] == user_uid || isLeader {
button = append(button, s.SetInfo)
}
kit.If(m.IsTech() && value[model.USER_UID] != user_uid, func() { button = append(button, s.SetCookie) })
kit.If(value[model.USER_UID] != user_uid && m.IsTech(), func() {
button = append(button, s.SetCookie)
})
if value[model.AUTH_UID] == "" {
kit.If(value[model.USER_UID] == user_uid, func() {
button = append(button, s.Auth)
@ -129,6 +126,7 @@ func (s member) List(m *ice.Message, arg ...string) {
button = append(button, s.Promote)
}
}
button = append(button, s.SetInfo)
if isLeader {
switch kit.Int(value[USER_PLACE_ROLE]) {
case 3:
@ -148,7 +146,6 @@ func (s member) List(m *ice.Message, arg ...string) {
m.PushButton(button...)
})
s.DisplayBase(m, "").DisplayCSS("")
m.Echo("count: %d", m.Length())
}
func init() { ice.TeamCtxCmd(member{Tables: newTables()}) }

View File

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

View File

@ -104,6 +104,7 @@ $output div.item.title.dealList { border-left:var(--box-danger3); }
$output div.item.title.meetList { border-left:var(--box-danger3); }
$body div.inputs>div.input.float>div.action { display:flex; }
$output div.item.card div.title div.action input { margin-right:0; }
$output div.item.card div.action input { margin-left:0; margin-right:0; padding:0 10px; }
$output div.item.card div.status span { word-break:break-all; }
$output div.item.card img { border-radius:5px; padding:0; margin:0; margin-right:10px; height:48px; width:48px; min-width:48px; object-fit:cover; }
$output div.item.card div.container img { margin-right:0; height:100%; width:100%; }
@ -148,7 +149,9 @@ $output fieldset.story.otherList>div.output { max-height:unset !important; }
$output fieldset.story.otherList>div.output>div.list { height:unset !important; }
$output fieldset.story>div.output>div.tabs { background-color:var(--plugin-bg-color); display:flex; overflow:auto; position:sticky; top:0; z-index:2; }
$output fieldset.story>div.output>div.tabs>div.item { white-space:pre; line-height:22px; padding:5px; }
$output fieldset.story>div.output>div.tabs>div.item.all { position:sticky; left:0; z-index:1; }
$output fieldset.story>div.output>div.tabs>div.item.select { border-top:var(--box-notice); background-color:var(--output-bg-color); }
$output fieldset.story>div.output>div.tabs>div.item.select { position:sticky; right:0; }
$output fieldset.story>div.output>div.tabs>div.item.danger.select { border-top:var(--box-danger); background-color:var(--output-bg-color); }
$output fieldset.story>div.output>div.tabs>div.item:hover { background-color:var(--output-bg-color); }

View File

@ -89,6 +89,7 @@ func (s Portal) Run(m *ice.Message, arg ...string) {
s.DisplayBase(m, "common.js")
m.Option(model.SERVICE_UID, ServiceUID(m))
m.Option(model.COMMAND_UID, CommandUID(m, arg[0]))
m.OptionDefault(ice.MSG_USERUID, m.Option(model.USER_UID))
m.OptionDefault(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))
m.Search(arg[0], func(key string, cmd *ice.Command) {
role := cmd.Role

View File

@ -26,6 +26,7 @@ func (s sess) Check(m *ice.Message, arg ...string) {
m.Option(ice.MSG_USERNAME, msg.Append(model.UID))
m.Option(ice.MSG_USERNICK, msg.Append(model.NAME))
m.Option(ice.MSG_AVATAR, msg.Append(model.AVATAR))
m.Option(ice.MSG_USERUID, msg.Append(model.UID))
m.Option(model.USER_UID, msg.Append(model.UID))
}

View File

@ -33,7 +33,6 @@ func (s Table) SettingCreate(m *ice.Message, arg ...string) {
}
func (s Table) SettingSelect(m *ice.Message, arg ...string) {
m.Cmd(s.Prefix(m, setting{}), s.Select, m.OptionSimple(model.PLACE_UID)).Table(func(value ice.Maps) {
m.Info("what %v", value)
if value[model.USER_UID] != "" && value[model.USER_UID] != m.Option(model.USER_UID) {
return
}