diff --git a/src/development/common.go b/src/development/common.go new file mode 100644 index 0000000..6c8ac64 --- /dev/null +++ b/src/development/common.go @@ -0,0 +1,52 @@ +package development + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/development/model" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Table struct { + guanlixitong.Table + list string `name:"list repos_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_REPOS_ROLE: + s.InputsListRole(m, UserReposRoleList, arg...) + case model.REPOS_TYPE: + s.InputsList(m, ReposTypeList, 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_REPOS_ROLE: + value = UserReposRole(kit.Int(value)).String() + case model.REPOS_TYPE: + value = ReposType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserReposRole(kit.Int(m.Cmd(userRepos{}, s.Select, m.OptionSimple(model.REPOS_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserReposCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.REPOS_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.REPOS_UID), info) +} + +type Tables struct{ Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} diff --git a/src/development/model/model.go b/src/development/model/model.go new file mode 100644 index 0000000..6a11044 --- /dev/null +++ b/src/development/model/model.go @@ -0,0 +1,42 @@ +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_REPOS_ROLE = "user_repos_role" + REPOS_UID = "repos_uid" + REPOS_NAME = "repos_name" + REPOS_TYPE = "repos_type" + RELEASE_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserRepos struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + ReposUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Repos struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Release struct { + db.ModelWithUID + ReposUID 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("", &UserRepos{}, &Repos{}, &Release{}) } diff --git a/src/development/portal.go b/src/development/portal.go new file mode 100644 index 0000000..f003eee --- /dev/null +++ b/src/development/portal.go @@ -0,0 +1,15 @@ +package development + +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* repos_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userRepos{}, repos{}, guanlixitong.Company{})}) +} diff --git a/src/development/portal.json b/src/development/portal.json new file mode 100644 index 0000000..ced4c7e --- /dev/null +++ b/src/development/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "系统开发", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "release": "版本发布", + "icons": { + "release": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Repos": "我的场景", + "user_repos_role": "用户角色", + "repos_name": "场景名称", + "repos_type": "场景类型" + }, + "value": { + "user_repos_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "repos_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/development/release.go b/src/development/release.go new file mode 100644 index 0000000..6b950b9 --- /dev/null +++ b/src/development/release.go @@ -0,0 +1,25 @@ +package development + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/development/model" +) + +type release struct { + Table + repos repos + userRepos userRepos + create string `name:"create title* content*" role:"leader"` +} + +func (s release) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.REPOS_UID))...) + s.recordEventWithName(m, "") +} +func (s release) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userRepos, s.repos, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(release{}) } diff --git a/src/development/release.js b/src/development/release.js new file mode 100644 index 0000000..f2b29a7 --- /dev/null +++ b/src/development/release.js @@ -0,0 +1,12 @@ +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, can.onimport.textView(can, value, "user_repos_role", aaa.ROLE), + ]}, + {view: html.OUTPUT, list: [value.content]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/development/repos.go b/src/development/repos.go new file mode 100644 index 0000000..befec8d --- /dev/null +++ b/src/development/repos.go @@ -0,0 +1,23 @@ +package development + +import "shylinux.com/x/ice" + +type repos struct{ Table } + +func init() { ice.TeamCtxCmd(repos{}) } + +type ReposType int + +const ( + ReposRD ReposType = iota + ReposOP + ReposHR +) + +var ReposTypeList = map[ReposType]string{ + ReposRD: "RD", + ReposOP: "OP", + ReposHR: "HR", +} + +func (s ReposType) String() string { return ReposTypeList[s] } \ No newline at end of file diff --git a/src/development/userRepos.go b/src/development/userRepos.go new file mode 100644 index 0000000..b9d651f --- /dev/null +++ b/src/development/userRepos.go @@ -0,0 +1,62 @@ +package development + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/enterprise/src/development/model" +) + +type userRepos struct { + Table + repos repos +} + +func (s userRepos) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.REPOS_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.REPOS_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_REPOS_ROLE) + s.SelectJoinUser(m) +} +func (s userRepos) List(m *ice.Message, arg ...string) { + s.Tables(m, s.repos).FieldsWithCreatedAT(m, s, + model.REPOS_NAME, model.REPOS_TYPE, model.USER_REPOS_ROLE, + model.COMPANY_UID, model.REPOS_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.REPOS_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userRepos{}) } + +type UserReposRole int + +const ( + UserReposVisitor UserReposRole = iota + UserReposCreator + UserReposLeader + UserReposWorker + UserReposServer +) + +var UserReposRoleList = map[UserReposRole]string{ + UserReposVisitor: "visitor", + UserReposCreator: "creator", + UserReposLeader: "leader", + UserReposWorker: "worker", + UserReposServer: "server", +} + +func (s UserReposRole) String() string { return UserReposRoleList[s] } \ No newline at end of file diff --git a/src/gongyinglian/goods.go b/src/gongyinglian/goods.go index c1c7b33..b0d2404 100644 --- a/src/gongyinglian/goods.go +++ b/src/gongyinglian/goods.go @@ -17,9 +17,7 @@ func (s goods) Create(m *ice.Message, arg ...string) { } func (s goods) List(m *ice.Message, arg ...string) { s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductGoods)), arg...) - if s.checkListRole(m, arg...) { - m.PushAction(s.SetShop, s.SetBrand, s.SetQuality, s.Modify, s.Remove) - } + kit.If(s.checkListRole(m, arg...), func() { m.PushAction(s.SetShop, s.SetBrand, s.SetQuality, s.Modify, s.Remove) }) } func init() { ice.TeamCtxCmd(goods{}) } diff --git a/src/gongyinglian/model/model.go b/src/gongyinglian/model/model.go index 92a29ca..a2e773c 100644 --- a/src/gongyinglian/model/model.go +++ b/src/gongyinglian/model/model.go @@ -56,13 +56,13 @@ type UserStore struct { db.ModelWithUID UserUID string `gorm:"type:char(32);index"` StoreUID string `gorm:"type:char(32);index"` - Role uint8 + Role uint8 `gorm:"default:0"` } type Store struct { db.ModelWithUID CompanyUID string `gorm:"type:char(32);index"` Name string `gorm:"type:varchar(64)"` - Type uint8 + Type uint8 `gorm:"default:0"` } type Shop struct { db.ModelWithUID @@ -85,7 +85,7 @@ type Product struct { BrandUID string `gorm:"type:char(32);index"` Name string `gorm:"type:varchar(64)"` Info string - Type uint8 + Type uint8 `gorm:"default:0"` Price uint `gorm:"default:0"` Stock uint `gorm:"default:0"` Unit string `gorm:"type:varchar(8)"` @@ -96,19 +96,19 @@ type Order struct { FromUserUID string `gorm:"type:char(32);index"` ToStoreUID string `gorm:"type:char(32);index"` ToUserUID string `gorm:"type:char(32);index"` - PaymentStatus uint8 - ExpressStatus uint8 - ReturnStatus uint8 - RefundStatus uint8 + PaymentStatus uint8 `gorm:"default:0"` + ExpressStatus uint8 `gorm:"default:0"` + ReturnStatus uint8 `gorm:"default:0"` + RefundStatus uint8 `gorm:"default:0"` PaymentSuccessTime db.Time ExpressRecvTime db.Time ReturnRecvTime db.Time RefundSuccessTime db.Time Name string `gorm:"type:varchar(64)"` Info string - Total int - Amount int - Status uint8 + Total int `gorm:"default:0"` + Amount int `gorm:"default:0"` + Status uint8 `gorm:"default:0"` } type OrderDetail struct { db.ModelWithUID @@ -123,14 +123,14 @@ type Payment struct { OrderUID string `gorm:"type:char(32);index"` CompanyUID string `gorm:"type:char(32)"` OpenID string `gorm:"type:varchar(128)"` - Status uint8 + Status uint8 `gorm:"default:0"` } type Express struct { db.ModelWithUID OrderUID string `gorm:"type:char(32);index"` CompanyUID string `gorm:"type:char(32)"` OpenID string `gorm:"type:varchar(128)"` - Status uint8 + Status uint8 `gorm:"default:0"` } type Return struct { db.ModelWithUID @@ -138,7 +138,7 @@ type Return struct { ExpressUID string `gorm:"type:char(32)"` CompanyUID string `gorm:"type:char(32)"` OpenID string `gorm:"type:varchar(128)"` - Status uint8 + Status uint8 `gorm:"default:0"` } type Refund struct { db.ModelWithUID @@ -146,7 +146,7 @@ type Refund struct { PaymentUID string `gorm:"type:char(32)"` CompanyUID string `gorm:"type:char(32)"` OpenID string `gorm:"type:varchar(128)"` - Status uint8 + Status uint8 `gorm:"default:0"` } func init() { @@ -176,8 +176,8 @@ type Expense struct { ToUserUID string `gorm:"type:char(32)"` Name string `gorm:"type:varchar(64)"` Info string - Type uint8 - Amount int + Type uint8 `gorm:"default:0"` + Amount int `gorm:"default:0"` } type Loan struct { db.ModelWithUID @@ -186,6 +186,6 @@ type Loan struct { ToUserUID string `gorm:"type:char(32)"` Name string `gorm:"type:varchar(64)"` Info string - Type uint8 - Amount int + Type uint8 `gorm:"default:0"` + Amount int `gorm:"default:0"` } diff --git a/src/gongyinglian/order.go b/src/gongyinglian/order.go index 20d0fb8..0d4a502 100644 --- a/src/gongyinglian/order.go +++ b/src/gongyinglian/order.go @@ -27,8 +27,8 @@ type Order struct { confirmSell string `name:"confirmSell from_store_uid" role:"void"` confirmProduce string `name:"confirmProduce" role:"void"` confirmPurchase string `name:"confirmPurchase to_store_uid" role:"void"` - process string `name:"process" role:"void"` again string `name:"again" role:"void"` + process string `name:"process" role:"void"` payment string `name:"payment company_uid* open_id*" role:"void"` express string `name:"express company_uid* open_id*" role:"void"` refund string `name:"refund company_uid* open_id*" role:"void"` @@ -204,23 +204,38 @@ func (s Order) Cancel(m *ice.Message, arg ...string) { } func (s Order) Submit(m *ice.Message, arg ...string) { s.Table.Update(m, kit.Dict(model.STATUS, OrderSubmit), m.OptionSimple(model.UID)...) - s.SendMessage(m, m.Option(model.USER_UID), m.Option(model.STORE_UID), m.Option(model.UID)) } func (s Order) ConfirmSell(m *ice.Message, arg ...string) { s.changeStatusFrom(m, OrderSubmit, model.FROM_USER_UID, func(msg *ice.Message) { s.Table.Update(m, kit.Dict(model.STATUS, OrderConfirm, m.OptionSimple(model.FROM_STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID)), m.OptionSimple(model.UID)...) + s.SendMessage(m, m.Option(model.USER_UID), msg.Option(model.TO_USER_UID), m.Option(model.STORE_UID), m.Option(model.UID)) + s.SendMessage(m, msg.Option(model.TO_USER_UID), m.Option(model.USER_UID), m.Option(model.STORE_UID), m.Option(model.UID)) }) } func (s Order) ConfirmProduce(m *ice.Message, arg ...string) { s.changeStatusFrom(m, OrderSubmit, model.FROM_USER_UID, func(msg *ice.Message) { s.Table.Update(m, kit.Dict(model.STATUS, OrderConfirm), m.OptionSimple(model.UID)...) + s.SendMessage(m, msg.Option(model.USER_UID), m.Option(model.USER_UID), m.Option(model.STORE_UID), m.Option(model.UID)) }) } func (s Order) ConfirmPurchase(m *ice.Message, arg ...string) { s.changeStatusFrom(m, OrderSubmit, model.TO_USER_UID, func(msg *ice.Message) { s.Table.Update(m, kit.Dict(model.STATUS, OrderConfirm, m.OptionSimple(model.TO_STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID)), m.OptionSimple(model.UID)...) + s.SendMessage(m, msg.Option(model.FROM_USER_UID), m.Option(model.USER_UID), m.Option(model.STORE_UID), m.Option(model.UID)) + s.SendMessage(m, m.Option(model.USER_UID), msg.Option(model.FROM_USER_UID), m.Option(model.STORE_UID), m.Option(model.UID)) }) } +func (s Order) Again(m *ice.Message, arg ...string) { + s.changeStatusFrom(m, OrderDeal, "", func(msg *ice.Message) { + s.Create(m, kit.Simple(model.STATUS, OrderConfirm, msg.AppendSimple(model.FROM_STORE_UID, model.FROM_USER_UID, model.TO_STORE_UID, model.TO_USER_UID))...) + m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) { + m.Cmd(s.orderDetail, s.Create, model.STORE_UID, detail[model.STORE_UID], model.ORDER_UID, m.Result(), + model.PRODUCT_UID, detail[model.PRODUCT_UID], model.PRICE, detail[model.PRICE], model.COUNT, detail[model.COUNT], + ) + }) + }) + m.ProcessRewrite(model.UID, m.Result()) +} func (s Order) Process(m *ice.Message, arg ...string) { s.changeStatusFrom(m, OrderConfirm, model.FROM_USER_UID, func(msg *ice.Message) { s.store.Lock(m) @@ -238,17 +253,6 @@ func (s Order) Process(m *ice.Message, arg ...string) { }) }) } -func (s Order) Again(m *ice.Message, arg ...string) { - s.changeStatusFrom(m, OrderDeal, "", func(msg *ice.Message) { - s.Create(m, kit.Simple(model.STATUS, OrderConfirm, msg.AppendSimple(model.FROM_STORE_UID, model.FROM_USER_UID, model.TO_STORE_UID, model.TO_USER_UID))...) - m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) { - m.Cmd(s.orderDetail, s.Create, model.STORE_UID, detail[model.STORE_UID], model.ORDER_UID, m.Result(), - model.PRODUCT_UID, detail[model.PRODUCT_UID], model.PRICE, detail[model.PRICE], model.COUNT, detail[model.COUNT], - ) - }) - }) - m.ProcessRewrite(model.UID, m.Result()) -} func (s Order) Payment(m *ice.Message, arg ...string) { s.changeStatusFrom(m, OrderConfirm, model.TO_USER_UID, func(msg *ice.Message) { if msg.Append(model.FROM_STORE_UID) == m.Option(model.STORE_UID) { diff --git a/src/gongyinglian/orderDetail.go b/src/gongyinglian/orderDetail.go index 5ba3372..ebe2528 100644 --- a/src/gongyinglian/orderDetail.go +++ b/src/gongyinglian/orderDetail.go @@ -22,7 +22,7 @@ func (s orderDetail) List(m *ice.Message, arg ...string) { } s.Tables(m, s.product).FieldsWithCreatedAT(m, s, model.NAME, model.INFO, s.Key(s, model.PRICE), s.Key(s, model.COUNT), model.UNIT, - model.PRODUCT_UID, + model.PRODUCT_TYPE, model.PRODUCT_UID, ) if len(arg) == 2 { s.Select(m, model.ORDER_UID, arg[1]) diff --git a/src/gongyinglian/orderDetail.js b/src/gongyinglian/orderDetail.js index 2ca5d08..c937d1f 100644 --- a/src/gongyinglian/orderDetail.js +++ b/src/gongyinglian/orderDetail.js @@ -1,7 +1,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { msg.Option("_share_title", can.Option("uid").slice(0, 6)) can.onimport.itemcards(can, msg, function(value) { return [ - {view: html.TITLE, list: [value.name]}, + {view: html.TITLE, list: [value.name, can.onimport.textView(can, value, "product_type", mdb.TYPE)]}, {view: html.STATUS, list: ["单价: ", value.price, " 元", "数量: ", value.count, " ", value.unit]}, {view: html.OUTPUT, list: [value.info]}, ] }, function(event) {}) diff --git a/src/gongyinglian/portal.json b/src/gongyinglian/portal.json index 00e217a..ede35d2 100644 --- a/src/gongyinglian/portal.json +++ b/src/gongyinglian/portal.json @@ -2,11 +2,10 @@ "portal": "供应链", "placeCreate": "创建生意", "placeRemove": "删除生意", "goods": "商品", "sell": "出货", "purchase": "进货", "expense": "开支", "payment": "付款", "express": "寄货", "return": "退贷", "refund": "退款", - "again": "再来一单", + "process": "生产", "again": "再来一单", "material": "原材", "produce": "加工", "quality": "质检", "brand": "贴牌", "product": "货物", "order": "订单", "shop": "店铺", "warehouse": "仓库", "member": "生意伙伴", "loan": "借贷外债", - "process": "生产", "confirmSell": "确认出货", "confirmProduce": "确认加工", "confirmPurchase": "确认进货", @@ -14,10 +13,7 @@ "confirmExpress": "确认收件", "confirmReturn": "确认收到退货", "confirmRefund": "确认收到退款", - "setShop": "店铺", - "setWarehouse": "仓库", - "setQuality": "质检", - "setBrand": "贴牌", + "setShop": "店铺", "setWarehouse": "仓库", "setQuality": "质检", "setBrand": "贴牌", "style": { "return": "danger" }, diff --git a/src/gongyinglian/userStore.go b/src/gongyinglian/userStore.go index 7ec454d..7106c1b 100644 --- a/src/gongyinglian/userStore.go +++ b/src/gongyinglian/userStore.go @@ -35,8 +35,10 @@ func (s userStore) List(m *ice.Message, arg ...string) { } else { return } - s.SelectJoinCompany(m) - s.SelectJoinCity(m) + if m.Length() > 0 { + s.SelectJoinCompany(m) + s.SelectJoinCity(m) + } } func init() { ice.TeamCtxCmd(userStore{}) } diff --git a/src/guanlixitong/common.go b/src/guanlixitong/common.go index 1add638..abd3fa5 100644 --- a/src/guanlixitong/common.go +++ b/src/guanlixitong/common.go @@ -16,9 +16,9 @@ type Table struct { func (s Table) Inputs(m *ice.Message, arg ...string) { switch arg[0] { case model.USER_GROUP_ROLE: - s.InputsListRole(m, UserGroupRoleList) + s.InputsListRole(m, UserGroupRoleList, arg...) case model.GROUP_TYPE: - s.InputsList(m, GroupTypeList) + 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.DisplayInputKeyNameIconTitle() diff --git a/src/guanlixitong/model/model.go b/src/guanlixitong/model/model.go index b57d336..b2cbf82 100644 --- a/src/guanlixitong/model/model.go +++ b/src/guanlixitong/model/model.go @@ -23,13 +23,13 @@ type UserGroup struct { db.ModelWithUID UserUID string `gorm:"type:char(32);index"` GroupUID string `gorm:"type:char(32);index"` - Role uint8 + Role uint8 `gorm:"default:0"` } type Group struct { db.ModelWithUID CompanyUID string `gorm:"type:char(32);index"` Name string `gorm:"type:varchar(64)"` - Type uint8 + Type uint8 `gorm:"default:0"` } type Company struct { db.ModelWithUID diff --git a/src/guanlixitong/userGroup.go b/src/guanlixitong/userGroup.go index 914d8a4..8b296f0 100644 --- a/src/guanlixitong/userGroup.go +++ b/src/guanlixitong/userGroup.go @@ -39,7 +39,7 @@ func (s userGroup) List(m *ice.Message, arg ...string) { s.SelectJoinCity(m) } -func init() { ice.TeamCtxCmd(userGroup{}) } +func init() { ice.TeamCtxCmd(userGroup{Table: NewTable(userGroup{}, group{})}) } type UserGroupRole int diff --git a/src/main.go b/src/main.go index c689dc8..c47d5cc 100644 --- a/src/main.go +++ b/src/main.go @@ -3,10 +3,12 @@ package main import ( "shylinux.com/x/ice" - _ "shylinux.com/x/enterprise/src/guanlixitong" + _ "shylinux.com/x/enterprise/src/development" _ "shylinux.com/x/enterprise/src/gongyinglian" + _ "shylinux.com/x/enterprise/src/guanlixitong" + _ "shylinux.com/x/enterprise/src/operation" ) func main() { print(ice.Run()) } -func init() { ice.Info.Titles = "云办公" } \ No newline at end of file +func init() { ice.Info.Titles = "云办公" } diff --git a/src/operation/cloud.go b/src/operation/cloud.go new file mode 100644 index 0000000..69b3867 --- /dev/null +++ b/src/operation/cloud.go @@ -0,0 +1,23 @@ +package operation + +import "shylinux.com/x/ice" + +type cloud struct{ Table } + +func init() { ice.TeamCtxCmd(cloud{}) } + +type CloudType int + +const ( + CloudRD CloudType = iota + CloudOP + CloudHR +) + +var CloudTypeList = map[CloudType]string{ + CloudRD: "RD", + CloudOP: "OP", + CloudHR: "HR", +} + +func (s CloudType) String() string { return CloudTypeList[s] } diff --git a/src/operation/common.go b/src/operation/common.go new file mode 100644 index 0000000..3f7e14b --- /dev/null +++ b/src/operation/common.go @@ -0,0 +1,52 @@ +package operation + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/enterprise/src/operation/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list cloud_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_CLOUD_ROLE: + s.InputsListRole(m, UserCloudRoleList, arg...) + case model.CLOUD_TYPE: + s.InputsList(m, CloudTypeList, 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_CLOUD_ROLE: + value = UserCloudRole(kit.Int(value)).String() + case model.CLOUD_TYPE: + value = CloudType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserCloudRole(kit.Int(m.Cmd(userCloud{}, s.Select, m.OptionSimple(model.CLOUD_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserCloudCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.CLOUD_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.CLOUD_UID), info) +} + +type Tables struct{ Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} diff --git a/src/operation/model/model.go b/src/operation/model/model.go new file mode 100644 index 0000000..430b331 --- /dev/null +++ b/src/operation/model/model.go @@ -0,0 +1,42 @@ +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_CLOUD_ROLE = "user_cloud_role" + CLOUD_UID = "cloud_uid" + CLOUD_NAME = "cloud_name" + CLOUD_TYPE = "cloud_type" + PUBLISH_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserCloud struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + CloudUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Cloud struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Publish struct { + db.ModelWithUID + CloudUID 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("", &UserCloud{}, &Cloud{}, &Publish{}) } diff --git a/src/operation/portal.go b/src/operation/portal.go new file mode 100644 index 0000000..121e608 --- /dev/null +++ b/src/operation/portal.go @@ -0,0 +1,15 @@ +package operation + +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* cloud_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userCloud{}, cloud{}, guanlixitong.Company{})}) +} diff --git a/src/operation/portal.json b/src/operation/portal.json new file mode 100644 index 0000000..6be219a --- /dev/null +++ b/src/operation/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "系统运维", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "publish": "系统发布", + "icons": { + "系统发布": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Cloud": "我的场景", + "user_cloud_role": "用户角色", + "cloud_name": "场景名称", + "cloud_type": "场景类型" + }, + "value": { + "user_cloud_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "cloud_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/operation/publish.go b/src/operation/publish.go new file mode 100644 index 0000000..1c8e8b7 --- /dev/null +++ b/src/operation/publish.go @@ -0,0 +1,25 @@ +package operation + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/operation/model" +) + +type publish struct { + Table + cloud cloud + userCloud userCloud + create string `name:"create title* content*" role:"leader"` +} + +func (s publish) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CLOUD_UID))...) + s.recordEventWithName(m, "") +} +func (s publish) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userCloud, s.cloud, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(publish{}) } diff --git a/src/operation/publish.js b/src/operation/publish.js new file mode 100644 index 0000000..b384773 --- /dev/null +++ b/src/operation/publish.js @@ -0,0 +1,12 @@ +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, can.onimport.textView(can, value, "user_cloud_role", aaa.ROLE), + ]}, + {view: html.OUTPUT, list: [value.content]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/operation/userCloud.go b/src/operation/userCloud.go new file mode 100644 index 0000000..7033a7e --- /dev/null +++ b/src/operation/userCloud.go @@ -0,0 +1,62 @@ +package operation + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/enterprise/src/operation/model" +) + +type userCloud struct { + Table + cloud cloud +} + +func (s userCloud) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.CLOUD_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.CLOUD_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_CLOUD_ROLE) + s.SelectJoinUser(m) +} +func (s userCloud) List(m *ice.Message, arg ...string) { + s.Tables(m, s.cloud).FieldsWithCreatedAT(m, s, + model.CLOUD_NAME, model.CLOUD_TYPE, model.USER_CLOUD_ROLE, + model.COMPANY_UID, model.CLOUD_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.CLOUD_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userCloud{}) } + +type UserCloudRole int + +const ( + UserCloudVisitor UserCloudRole = iota + UserCloudCreator + UserCloudLeader + UserCloudWorker + UserCloudServer +) + +var UserCloudRoleList = map[UserCloudRole]string{ + UserCloudVisitor: "visitor", + UserCloudCreator: "creator", + UserCloudLeader: "leader", + UserCloudWorker: "worker", + UserCloudServer: "server", +} + +func (s UserCloudRole) String() string { return UserCloudRoleList[s] }