This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-09-02 12:18:55 +08:00
parent 18fbc7fbce
commit 8e782add86
26 changed files with 107 additions and 211 deletions

View File

@ -113,12 +113,6 @@ func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool {
}
return true
}
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) {
s.Table.RecordEvent(m, m.Option(model.STORE_UID), info, kit.Select(m.Option(model.UID), arg, 0))
}
func (s Table) recordEventWithName(m *ice.Message, info string) {
s.Table.RecordEventWithName(m, m.Option(model.STORE_UID), info)
}
type TableView struct {
Table
@ -131,16 +125,16 @@ type TableView struct {
func (s TableView) Create(m *ice.Message, arg ...string) {
arg = s.transPrice(m, arg...)
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.STORE_UID))...)
s.recordEventWithName(m, "")
s.RecordEventWithName(m, "")
}
func (s TableView) Modify(m *ice.Message, arg ...string) {
arg = s.transPrice(m, arg...)
s.Table.Update(m, kit.Dict(arg), m.OptionSimple(model.STORE_UID, model.UID)...)
s.recordEventWithName(m, "")
s.RecordEventWithName(m, "")
}
func (s TableView) Remove(m *ice.Message, arg ...string) {
s.Table.Delete(m, m.OptionSimple(model.STORE_UID, model.UID)...)
s.recordEventWithName(m, "")
s.RecordEventWithName(m, "")
}
func (s TableView) List(m *ice.Message, arg ...string) {
if len(arg) == 0 {
@ -160,5 +154,3 @@ func (s TableView) List(m *ice.Message, arg ...string) {
type Tables struct{ Table }
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
func newTable() Table { return Table{Table: guanlixitong.NewTable(userStore{}, store{})} }

View File

@ -380,7 +380,7 @@ func (s Order) CheckRole(m *ice.Message, arg ...string) {
m.WarnNotValid(OrderStatus(kit.Int(msg.Append(model.STATUS))) != OrderCreate)
}
func init() { ice.TeamCtxCmd(Order{Table: newTable()}) }
func init() { ice.TeamCtxCmd(Order{}) }
func (s Order) changeStatusFrom(m *ice.Message, from OrderStatus, which string, cb func(*ice.Message)) {
defer m.ToastProcess()()
@ -396,13 +396,13 @@ func (s Order) changeStatusFrom(m *ice.Message, from OrderStatus, which string,
})
}
func (s Order) sendTemplate(m *ice.Message, to string, title string) {
s.recordEvent(m, kit.JoinWord(kit.Cut(m.Option(model.UID), 6), title))
s.RecordEvent(m, kit.JoinWord(kit.Cut(m.Option(model.UID), 6), title))
kit.If(to == model.TO_USER_UID, func() { title = "进货" + title })
kit.If(to == model.FROM_USER_UID, func() { title = "出货" + title })
kit.If(to != "" && m.Option(to) != "", func() { s.SendTemplate(m, "", m.Option(to), title) })
}
func newOrder() Order { return Order{Table: newTable()} }
func newOrder() Order { return Order{} }
type OrderType int

View File

@ -6,10 +6,10 @@ import (
)
type Portal struct {
gonganxitong.Portal
guanlixitong.Portal
placeCreate string `name:"placeCreate city_name* company_name* store_type*:select store_name*" role:"void"`
}
func init() {
gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userStore{}, store{}, guanlixitong.Company{})})
gonganxitong.PortalCmd(Portal{Portal: guanlixitong.NewPortal(userStore{}, store{})})
}

View File

@ -14,4 +14,4 @@ func (s produce) List(m *ice.Message, arg ...string) {
kit.If(len(arg) == 1, func() { m.Action(s.Produce) })
}
func init() { ice.TeamCtxCmd(produce{Order: newOrder()}) }
func init() { ice.TeamCtxCmd(produce{}) }

View File

@ -17,4 +17,4 @@ func (s purchase) List(m *ice.Message, arg ...string) {
kit.If(len(arg) == 1, func() { m.Action(s.Purchase) })
}
func init() { ice.TeamCtxCmd(purchase{Order: newOrder()}) }
func init() { ice.TeamCtxCmd(purchase{}) }

View File

@ -17,4 +17,4 @@ func (s sell) List(m *ice.Message, arg ...string) {
kit.If(len(arg) == 1, func() { m.Action(s.Sell) })
}
func init() { ice.TeamCtxCmd(sell{Order: newOrder()}) }
func init() { ice.TeamCtxCmd(sell{}) }

View File

@ -18,8 +18,8 @@ const (
)
var UserStoreRoleList = map[UserStoreRole]string{
UserStoreCreator: "creator",
UserStoreVisitor: "visitor",
UserStoreCreator: "creator",
UserStoreBoss: "boss",
UserStoreWorker: "worker",
UserStoreVendor: "vendor",

View File

@ -21,7 +21,7 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
case model.GROUP_TYPE:
s.InputsList(m, GroupTypeList, arg...)
case model.COMPANY_UID:
m.Cmdy(Company{}, s.Select).Cut(model.UID, model.NAME).RenameAppend(model.UID, arg[0])
m.Cmdy(company{}, s.Select).Cut(model.UID, model.NAME).RenameAppend(model.UID, arg[0])
m.DisplayInputKeyNameIconTitle()
default:
s.Table.Inputs(m, arg...)
@ -55,6 +55,6 @@ type Tables struct{ Table }
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
func NewTable(userGroup gonganxitong.UserPlacer, group gonganxitong.Placer) Table {
return Table{Table: gonganxitong.NewTable(userGroup, group, company{})}
func NewPortal(userPlace gonganxitong.UserPlacer, place gonganxitong.Placer) Portal {
return Portal{Portal: gonganxitong.NewPortal(userPlace, place, company{})}
}

View File

@ -18,7 +18,3 @@ func (s company) FindOrCreateByName(m *ice.Message, arg ...string) {
}
func init() { ice.TeamCtxCmd(company{}) }
type Company struct{ company }
func init() { ice.TeamCtxCmd(Company{}) }

View File

@ -12,18 +12,18 @@ const (
GroupRD GroupType = iota
GroupOP
GroupHR
GroupFinancial
GroupFA
GroupAdmin
GroupSales
)
var GroupTypeList = map[GroupType]string{
GroupRD: "RD",
GroupOP: "OP",
GroupHR: "HR",
GroupFinancial: "financial",
GroupAdmin: "admin",
GroupSales: "sales",
GroupRD: "RD",
GroupOP: "OP",
GroupHR: "HR",
GroupFA: "FA",
GroupAdmin: "admin",
GroupSales: "sales",
}
func (s GroupType) String() string { return GroupTypeList[s] }

View File

@ -7,6 +7,4 @@ type Portal struct {
placeCreate string `name:"placeCreate city_name* company_name* group_type*:select group_name*" role:"void"`
}
func init() {
gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userGroup{}, group{}, company{})})
}
func init() { gonganxitong.PortalCmd(NewPortal(userGroup{}, group{})) }

View File

@ -28,7 +28,7 @@
"RD": "研发",
"OP": "运维",
"HR": "人力",
"financial": "财务",
"FA": "财务",
"Admin": "行政",
"sales": "销售",
"icons": {

View File

@ -4,7 +4,7 @@ import "shylinux.com/x/ice"
type userGroup struct{ Table }
func init() { ice.TeamCtxCmd(userGroup{Table: NewTable(userGroup{}, group{})}) }
func init() { ice.TeamCtxCmd(userGroup{}) }
type UserGroupRole int

View File

@ -9,15 +9,13 @@ func init() { ice.TeamCtxCmd(channel{}) }
type ChannelType int
const (
ChannelRD ChannelType = iota
ChannelOP
ChannelHR
ChannelOnline ChannelType = iota
ChannelOffline
)
var ChannelTypeList = map[ChannelType]string{
ChannelRD: "RD",
ChannelOP: "OP",
ChannelHR: "HR",
ChannelOnline: "online",
ChannelOffline: "offline",
}
func (s ChannelType) String() string { return ChannelTypeList[s] }
func (s ChannelType) String() string { return ChannelTypeList[s] }

View File

@ -35,18 +35,7 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
})
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 }
type Tables struct{ Table }
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}

View File

@ -6,10 +6,8 @@ import (
)
type Portal struct {
gonganxitong.Portal
placeCreate string `name:"placeCreate city_name* company_name* channel_name*" role:"void"`
guanlixitong.Portal
placeCreate string `name:"placeCreate city_name* company_name* channel_type*:select channel_name*" role:"void"`
}
func init() {
gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userChannel{}, channel{}, guanlixitong.Company{})})
}
func init() { gonganxitong.PortalCmd(Portal{Portal: guanlixitong.NewPortal(userChannel{}, channel{})}) }

View File

@ -1,14 +1,14 @@
{
"portal": "市场营销",
"": "场景应用",
"promotion": "促销活动",
"icons": {
"": "https://img.icons8.com/officel/80/activity-grid.png"
"promotion": "https://img.icons8.com/officel/80/activity-grid.png"
},
"input": {
"My Channel": "我的场景",
"My Channel": "我的渠道",
"user_channel_role": "用户角色",
"channel_name": "场景名称",
"channel_type": "场景类型"
"channel_name": "渠道名称",
"channel_type": "渠道类型"
},
"value": {
"user_channel_role": {
@ -18,14 +18,13 @@
"worker": "工作人员",
"server": "服务人员",
"style": {
"creator": "danger"
"creator": "danger",
"leader": "danger"
}
},
"channel_type": {
"term": "学期制",
"weekly": "周期性",
"step": "阶段性",
"free": "自由式"
"online": "线上",
"offline": "线下"
}
}
}

View File

@ -11,15 +11,15 @@ type promotion struct {
Table
channel channel
userChannel userChannel
create string `name:"create title* content*" role:"leader"`
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, "")
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{}) }
func init() { ice.TeamCtxCmd(promotion{}) }

View File

@ -1,27 +1,15 @@
package shichangyingxiao
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
"shylinux.com/x/enterprise/src/guanlixitong"
)
type userChannel struct{ Table }
func init() { ice.TeamCtxCmd(userChannel{}) }
type UserChannelRole int
type UserChannelRole = guanlixitong.UserGroupRole
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] }
var UserChannelRoleList = guanlixitong.UserGroupRoleList

View File

@ -15,10 +15,10 @@ type Table struct {
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...)
case model.USER_CAPITAL_ROLE:
s.InputsListRole(m, UserCapitalRoleList, arg...)
case model.CAPITAL_TYPE:
s.InputsList(m, CapitalTypeList, arg...)
default:
s.Table.Inputs(m, arg...)
}
@ -26,27 +26,16 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
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()
case model.USER_CAPITAL_ROLE:
value = UserCapitalRole(kit.Int(value)).String()
case model.CAPITAL_TYPE:
value = CapitalType(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 }
type Tables struct{ Table }
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}

View File

@ -9,17 +9,17 @@ import (
type investment struct {
Table
investor investor
userInvestor userInvestor
create string `name:"create title* content*" role:"leader"`
capital capital
userCapital userCapital
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, "")
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CAPITAL_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("")
s.TablesWithRole(m, arg, s.userCapital, s.capital, s, model.TITLE, model.CONTENT).Display("")
}
func init() { ice.TeamCtxCmd(investment{}) }
func init() { ice.TeamCtxCmd(investment{}) }

View File

@ -1,23 +0,0 @@
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] }

View File

@ -3,33 +3,33 @@ 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 = "investment_uid"
COMPANY_UID = "company_uid"
CITY_UID = "city_uid"
UID = "uid"
NAME = "name"
TYPE = "type"
ROLE = "role"
TITLE = "title"
CONTENT = "content"
USER_UID = "user_uid"
USER_CAPITAL_ROLE = "user_capital_role"
CAPITAL_UID = "capital_uid"
CAPITAL_NAME = "capital_name"
CAPITAL_TYPE = "capital_type"
INVESTMENT_UID = "investment_uid"
COMPANY_UID = "company_uid"
CITY_UID = "city_uid"
)
type UserInvestor struct {
type UserCapital struct {
db.ModelUserPlace
InvestorUID string `gorm:"type:char(32);index"`
CapitalUID string `gorm:"type:char(32);index"`
}
type Investor struct {
type Capital struct {
db.ModelPlace
CompanyUID string `gorm:"type:char(32);index"`
}
type Investment struct {
db.ModelContent
InvestorUID string `gorm:"type:char(32);index"`
CapitalUID string `gorm:"type:char(32);index"`
}
func init() { db.CmdModels("", &UserInvestor{}, &Investor{}, &Investment{}) }
func init() { db.CmdModels("", &UserCapital{}, &Capital{}, &Investment{}) }

View File

@ -6,10 +6,8 @@ import (
)
type Portal struct {
gonganxitong.Portal
placeCreate string `name:"placeCreate city_name* company_name* investor_name*" role:"void"`
guanlixitong.Portal
placeCreate string `name:"placeCreate city_name* company_name* capital_type*:select capital_name*" role:"void"`
}
func init() {
gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userInvestor{}, investor{}, guanlixitong.Company{})})
}
func init() { gonganxitong.PortalCmd(Portal{Portal: guanlixitong.NewPortal(userCapital{}, capital{})}) }

View File

@ -1,31 +1,32 @@
{
"portal": "资金链",
"": "场景应用",
"investment": "投资",
"icons": {
"": "https://img.icons8.com/officel/80/activity-grid.png"
"investment": "https://img.icons8.com/officel/80/activity-grid.png"
},
"input": {
"My Investor": "我的场景",
"user_investor_role": "用户角色",
"investor_name": "场景名称",
"investor_type": "场景类型"
"My Capital": "我的资本",
"user_capital_role": "用户角色",
"capital_name": "资本名称",
"capital_type": "资本类型"
},
"value": {
"user_investor_role": {
"user_capital_role": {
"visitor": "访客",
"creator": "创建人",
"leader": "管理人员",
"worker": "工作人员",
"server": "服务人员",
"style": {
"creator": "danger"
"creator": "danger",
"leader": "danger"
}
},
"investor_type": {
"term": "学期制",
"weekly": "周期性",
"step": "阶段性",
"free": "自由式"
"capital_type": {
"bank": "银行借贷",
"angel": "天使投资",
"venture": "风险投资",
"private": "私募基金"
}
}
}

View File

@ -1,27 +0,0 @@
package zijinlian
import "shylinux.com/x/ice"
type userInvestor struct{ Table }
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] }