This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-08-24 20:22:22 +08:00
parent 650ef36f22
commit 00ca2bfe20
27 changed files with 581 additions and 51 deletions

52
src/development/common.go Normal file
View File

@ -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) {}

View File

@ -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{}) }

15
src/development/portal.go Normal file
View File

@ -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{})})
}

View File

@ -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": "自由式"
}
}
}

View File

@ -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{}) }

View File

@ -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]},
] })
},
})

23
src/development/repos.go Normal file
View File

@ -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] }

View File

@ -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] }

View File

@ -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{}) }

View File

@ -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"`
}

View File

@ -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) {

View File

@ -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])

View File

@ -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) {})

View File

@ -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"
},

View File

@ -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{}) }

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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 = "云办公" }
func init() { ice.Info.Titles = "云办公" }

23
src/operation/cloud.go Normal file
View File

@ -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] }

52
src/operation/common.go Normal file
View File

@ -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) {}

View File

@ -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{}) }

15
src/operation/portal.go Normal file
View File

@ -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{})})
}

33
src/operation/portal.json Normal file
View File

@ -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": "自由式"
}
}
}

25
src/operation/publish.go Normal file
View File

@ -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{}) }

12
src/operation/publish.js Normal file
View File

@ -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]},
] })
},
})

View File

@ -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] }