From 6ac24bcaab451f7a4c8a816fb3646f78320e55a6 Mon Sep 17 00:00:00 2001 From: jingganjiaoyu Date: Thu, 29 Aug 2024 11:10:28 +0800 Subject: [PATCH] opt some --- src/main.go | 4 +- src/shichangyingxiao/channel.go | 23 ++++++++++ src/shichangyingxiao/common.go | 52 ++++++++++++++++++++++ src/shichangyingxiao/model/model.go | 43 +++++++++++++++++++ src/shichangyingxiao/portal.go | 15 +++++++ src/shichangyingxiao/portal.json | 33 ++++++++++++++ src/shichangyingxiao/promotion.go | 25 +++++++++++ src/shichangyingxiao/promotion.js | 9 ++++ src/shichangyingxiao/userChannel.go | 62 +++++++++++++++++++++++++++ src/zijinlian/common.go | 52 ++++++++++++++++++++++ src/zijinlian/investment.go | 25 +++++++++++ src/zijinlian/investment.js | 9 ++++ src/zijinlian/investor.go | 23 ++++++++++ src/zijinlian/model/model.go | 43 +++++++++++++++++++ src/zijinlian/portal.go | 15 +++++++ src/zijinlian/portal.json | 33 ++++++++++++++ src/zijinlian/userInvestor.go | 62 +++++++++++++++++++++++++++ usr/local/export/mdb.export/hash.json | 14 ++++++ 18 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 src/shichangyingxiao/channel.go create mode 100644 src/shichangyingxiao/common.go create mode 100644 src/shichangyingxiao/model/model.go create mode 100644 src/shichangyingxiao/portal.go create mode 100644 src/shichangyingxiao/portal.json create mode 100644 src/shichangyingxiao/promotion.go create mode 100644 src/shichangyingxiao/promotion.js create mode 100644 src/shichangyingxiao/userChannel.go create mode 100644 src/zijinlian/common.go create mode 100644 src/zijinlian/investment.go create mode 100644 src/zijinlian/investment.js create mode 100644 src/zijinlian/investor.go create mode 100644 src/zijinlian/model/model.go create mode 100644 src/zijinlian/portal.go create mode 100644 src/zijinlian/portal.json create mode 100644 src/zijinlian/userInvestor.go diff --git a/src/main.go b/src/main.go index c47d5cc..a6cc7ca 100644 --- a/src/main.go +++ b/src/main.go @@ -3,10 +3,10 @@ package main import ( "shylinux.com/x/ice" - _ "shylinux.com/x/enterprise/src/development" _ "shylinux.com/x/enterprise/src/gongyinglian" _ "shylinux.com/x/enterprise/src/guanlixitong" - _ "shylinux.com/x/enterprise/src/operation" + _ "shylinux.com/x/enterprise/src/shichangyingxiao" + _ "shylinux.com/x/enterprise/src/zijinlian" ) func main() { print(ice.Run()) } diff --git a/src/shichangyingxiao/channel.go b/src/shichangyingxiao/channel.go new file mode 100644 index 0000000..ca9c44c --- /dev/null +++ b/src/shichangyingxiao/channel.go @@ -0,0 +1,23 @@ +package shichangyingxiao + +import "shylinux.com/x/ice" + +type channel struct{ Table } + +func init() { ice.TeamCtxCmd(channel{}) } + +type ChannelType int + +const ( + ChannelRD ChannelType = iota + ChannelOP + ChannelHR +) + +var ChannelTypeList = map[ChannelType]string{ + ChannelRD: "RD", + ChannelOP: "OP", + ChannelHR: "HR", +} + +func (s ChannelType) String() string { return ChannelTypeList[s] } \ No newline at end of file diff --git a/src/shichangyingxiao/common.go b/src/shichangyingxiao/common.go new file mode 100644 index 0000000..75a63f7 --- /dev/null +++ b/src/shichangyingxiao/common.go @@ -0,0 +1,52 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/enterprise/src/shichangyingxiao/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list channel_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_CHANNEL_ROLE: + s.InputsListRole(m, UserChannelRoleList, arg...) + case model.CHANNEL_TYPE: + s.InputsList(m, ChannelTypeList, arg...) + default: + s.Table.Inputs(m, arg...) + } +} +func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { + m.RewriteAppend(func(value, key string, index int) string { + switch key { + case model.USER_CHANNEL_ROLE: + value = UserChannelRole(kit.Int(value)).String() + case model.CHANNEL_TYPE: + value = ChannelType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserChannelRole(kit.Int(m.Cmd(userChannel{}, s.Select, m.OptionSimple(model.CHANNEL_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserChannelCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.CHANNEL_UID), info, kit.Select(m.Option(model.UID), arg, 0)) +} +func (s Table) recordEventWithName(m *ice.Message, info string, arg ...string) { + s.Table.RecordEventWithName(m, m.Option(model.CHANNEL_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/shichangyingxiao/model/model.go b/src/shichangyingxiao/model/model.go new file mode 100644 index 0000000..dee4a3d --- /dev/null +++ b/src/shichangyingxiao/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_CHANNEL_ROLE = "user_channel_role" + CHANNEL_UID = "channel_uid" + CHANNEL_NAME = "channel_name" + CHANNEL_TYPE = "channel_type" + PROMOTION_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserChannel struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + ChannelUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Channel struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Promotion struct { + db.ModelWithUID + ChannelUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32);index"` + Title string `gorm:"type:varchar(64)"` + Content string +} + + +func init() { db.CmdModels("", &UserChannel{}, &Channel{}, &Promotion{}) } \ No newline at end of file diff --git a/src/shichangyingxiao/portal.go b/src/shichangyingxiao/portal.go new file mode 100644 index 0000000..9713e82 --- /dev/null +++ b/src/shichangyingxiao/portal.go @@ -0,0 +1,15 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Portal struct { + gonganxitong.Portal + placeCreate string `name:"placeCreate city_name* company_name* channel_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userChannel{}, channel{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/shichangyingxiao/portal.json b/src/shichangyingxiao/portal.json new file mode 100644 index 0000000..cf3ae0a --- /dev/null +++ b/src/shichangyingxiao/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "市场营销", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Channel": "我的场景", + "user_channel_role": "用户角色", + "channel_name": "场景名称", + "channel_type": "场景类型" + }, + "value": { + "user_channel_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "channel_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/shichangyingxiao/promotion.go b/src/shichangyingxiao/promotion.go new file mode 100644 index 0000000..81c3187 --- /dev/null +++ b/src/shichangyingxiao/promotion.go @@ -0,0 +1,25 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/shichangyingxiao/model" +) + +type promotion struct { + Table + channel channel + userChannel userChannel + create string `name:"create title* content*" role:"leader"` +} + +func (s promotion) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CHANNEL_UID))...) + s.recordEventWithName(m, "") +} +func (s promotion) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userChannel, s.channel, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(promotion{}) } \ No newline at end of file diff --git a/src/shichangyingxiao/promotion.js b/src/shichangyingxiao/promotion.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/shichangyingxiao/promotion.js @@ -0,0 +1,9 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { can.onimport.shareTitle(can, msg) + can.onimport.itemcards(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.title]}, + {view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at), value.user_name]}, + {view: html.OUTPUT, list: [value.content]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/shichangyingxiao/userChannel.go b/src/shichangyingxiao/userChannel.go new file mode 100644 index 0000000..2765a71 --- /dev/null +++ b/src/shichangyingxiao/userChannel.go @@ -0,0 +1,62 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/enterprise/src/shichangyingxiao/model" +) + +type userChannel struct { + Table + channel channel +} + +func (s userChannel) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.CHANNEL_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.CHANNEL_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_CHANNEL_ROLE) + s.SelectJoinUser(m) +} +func (s userChannel) List(m *ice.Message, arg ...string) { + s.Tables(m, s.channel).FieldsWithCreatedAT(m, s, + model.CHANNEL_NAME, model.CHANNEL_TYPE, model.USER_CHANNEL_ROLE, + model.COMPANY_UID, model.CHANNEL_UID, + ) + if len(arg) == 1 { + 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.CHANNEL_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userChannel{}) } + +type UserChannelRole int + +const ( + UserChannelVisitor UserChannelRole = iota + UserChannelCreator + UserChannelLeader + UserChannelWorker + UserChannelServer +) + +var UserChannelRoleList = map[UserChannelRole]string{ + UserChannelVisitor: "visitor", + UserChannelCreator: "creator", + UserChannelLeader: "leader", + UserChannelWorker: "worker", + UserChannelServer: "server", +} + +func (s UserChannelRole) String() string { return UserChannelRoleList[s] } \ No newline at end of file diff --git a/src/zijinlian/common.go b/src/zijinlian/common.go new file mode 100644 index 0000000..a76c3df --- /dev/null +++ b/src/zijinlian/common.go @@ -0,0 +1,52 @@ +package zijinlian + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/enterprise/src/zijinlian/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list investor_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_INVESTOR_ROLE: + s.InputsListRole(m, UserInvestorRoleList, arg...) + case model.INVESTOR_TYPE: + s.InputsList(m, InvestorTypeList, arg...) + default: + s.Table.Inputs(m, arg...) + } +} +func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { + m.RewriteAppend(func(value, key string, index int) string { + switch key { + case model.USER_INVESTOR_ROLE: + value = UserInvestorRole(kit.Int(value)).String() + case model.INVESTOR_TYPE: + value = InvestorType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserInvestorRole(kit.Int(m.Cmd(userInvestor{}, s.Select, m.OptionSimple(model.INVESTOR_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserInvestorCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.INVESTOR_UID), info, kit.Select(m.Option(model.UID), arg, 0)) +} +func (s Table) recordEventWithName(m *ice.Message, info string, arg ...string) { + s.Table.RecordEventWithName(m, m.Option(model.INVESTOR_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/zijinlian/investment.go b/src/zijinlian/investment.go new file mode 100644 index 0000000..d52c6ed --- /dev/null +++ b/src/zijinlian/investment.go @@ -0,0 +1,25 @@ +package zijinlian + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/zijinlian/model" +) + +type investment struct { + Table + investor investor + userInvestor userInvestor + create string `name:"create title* content*" role:"leader"` +} + +func (s investment) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.INVESTOR_UID))...) + s.recordEventWithName(m, "") +} +func (s investment) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userInvestor, s.investor, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(investment{}) } \ No newline at end of file diff --git a/src/zijinlian/investment.js b/src/zijinlian/investment.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/zijinlian/investment.js @@ -0,0 +1,9 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { can.onimport.shareTitle(can, msg) + can.onimport.itemcards(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.title]}, + {view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at), value.user_name]}, + {view: html.OUTPUT, list: [value.content]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/zijinlian/investor.go b/src/zijinlian/investor.go new file mode 100644 index 0000000..b4984d9 --- /dev/null +++ b/src/zijinlian/investor.go @@ -0,0 +1,23 @@ +package zijinlian + +import "shylinux.com/x/ice" + +type investor struct{ Table } + +func init() { ice.TeamCtxCmd(investor{}) } + +type InvestorType int + +const ( + InvestorRD InvestorType = iota + InvestorOP + InvestorHR +) + +var InvestorTypeList = map[InvestorType]string{ + InvestorRD: "RD", + InvestorOP: "OP", + InvestorHR: "HR", +} + +func (s InvestorType) String() string { return InvestorTypeList[s] } \ No newline at end of file diff --git a/src/zijinlian/model/model.go b/src/zijinlian/model/model.go new file mode 100644 index 0000000..980b7e3 --- /dev/null +++ b/src/zijinlian/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_INVESTOR_ROLE = "user_investor_role" + INVESTOR_UID = "investor_uid" + INVESTOR_NAME = "investor_name" + INVESTOR_TYPE = "investor_type" + INVESTMENT_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserInvestor struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + InvestorUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Investor struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Investment struct { + db.ModelWithUID + InvestorUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32);index"` + Title string `gorm:"type:varchar(64)"` + Content string +} + + +func init() { db.CmdModels("", &UserInvestor{}, &Investor{}, &Investment{}) } \ No newline at end of file diff --git a/src/zijinlian/portal.go b/src/zijinlian/portal.go new file mode 100644 index 0000000..a4a5ae6 --- /dev/null +++ b/src/zijinlian/portal.go @@ -0,0 +1,15 @@ +package zijinlian + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Portal struct { + gonganxitong.Portal + placeCreate string `name:"placeCreate city_name* company_name* investor_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userInvestor{}, investor{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/zijinlian/portal.json b/src/zijinlian/portal.json new file mode 100644 index 0000000..3d70e48 --- /dev/null +++ b/src/zijinlian/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "资金链", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Investor": "我的场景", + "user_investor_role": "用户角色", + "investor_name": "场景名称", + "investor_type": "场景类型" + }, + "value": { + "user_investor_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "investor_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/zijinlian/userInvestor.go b/src/zijinlian/userInvestor.go new file mode 100644 index 0000000..747a91e --- /dev/null +++ b/src/zijinlian/userInvestor.go @@ -0,0 +1,62 @@ +package zijinlian + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/enterprise/src/zijinlian/model" +) + +type userInvestor struct { + Table + investor investor +} + +func (s userInvestor) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.INVESTOR_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.INVESTOR_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_INVESTOR_ROLE) + s.SelectJoinUser(m) +} +func (s userInvestor) List(m *ice.Message, arg ...string) { + s.Tables(m, s.investor).FieldsWithCreatedAT(m, s, + model.INVESTOR_NAME, model.INVESTOR_TYPE, model.USER_INVESTOR_ROLE, + model.COMPANY_UID, model.INVESTOR_UID, + ) + if len(arg) == 1 { + 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.INVESTOR_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userInvestor{}) } + +type UserInvestorRole int + +const ( + UserInvestorVisitor UserInvestorRole = iota + UserInvestorCreator + UserInvestorLeader + UserInvestorWorker + UserInvestorServer +) + +var UserInvestorRoleList = map[UserInvestorRole]string{ + UserInvestorVisitor: "visitor", + UserInvestorCreator: "creator", + UserInvestorLeader: "leader", + UserInvestorWorker: "worker", + UserInvestorServer: "server", +} + +func (s UserInvestorRole) String() string { return UserInvestorRoleList[s] } \ No newline at end of file diff --git a/usr/local/export/mdb.export/hash.json b/usr/local/export/mdb.export/hash.json index 6dfa083..d2f016f 100644 --- a/usr/local/export/mdb.export/hash.json +++ b/usr/local/export/mdb.export/hash.json @@ -251,6 +251,20 @@ "type": "hash" } }, + "cedc4d97efc7332e5d248514294c803e": { + "meta": { + "index": "web.team.shichangyingxiao.portal", + "time": "2024-08-28 10:26:07.864", + "type": "hash" + } + }, + "d25a3621dd190136974678fbe5173c7b": { + "meta": { + "index": "web.team.zijinlian.portal", + "time": "2024-08-28 10:26:07.930", + "type": "hash" + } + }, "d6a7c2908e838d6af1db45a55a1ad98f": { "meta": { "index": "web.team.gongyinglian.portal",