diff --git a/Makefile b/Makefile index 5ed7821..da655ab 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ flags = -ldflags "-w -s" -v all: def @date +"%Y-%m-%d %H:%M:%S" - go build ${flags} -o ${binarys} src/main.go src/option.go${version} ${binpack} && ./${binarys} forever restart &>/dev/null + go build ${flags} -o ${binarys} src/main.go src/option.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null def: @[ -f ${version} ] || echo "package main">${version} - @[ -f ${binpack} ] || echo "package main">${binpack} \ No newline at end of file + @[ -f ${binpack} ] || echo "package main">${binpack} diff --git a/go.mod b/go.mod index 351a837..3d86825 100644 --- a/go.mod +++ b/go.mod @@ -5,4 +5,5 @@ go 1.13 require ( shylinux.com/x/community v0.0.5 // indirect shylinux.com/x/ice v1.5.44 // indirect + shylinux.com/x/mysql-story v0.6.18 // indirect ) diff --git a/go.sum b/go.sum index 2bc0ee5..cc0e5d2 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,7 @@ github.com/glerchundi/subcommands v0.0.0-20181212083838-923a6ccb11f8/go.mod h1:r github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -170,6 +171,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= gorm.io/driver/sqlite v1.5.6/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4= gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= diff --git a/src/dashboard/client.go b/src/dashboard/client.go new file mode 100644 index 0000000..8816d69 --- /dev/null +++ b/src/dashboard/client.go @@ -0,0 +1,21 @@ +package dashboard + +import "shylinux.com/x/ice" + +type client struct{ Table } + +func init() { ice.TeamCtxCmd(client{}) } + +type ClientType int + +const ( + ClientMySQL ClientType = iota + ClientRedis +) + +var ClientTypeList = map[ClientType]string{ + ClientMySQL: "mysql", + ClientRedis: "redis", +} + +func (s ClientType) String() string { return ClientTypeList[s] } diff --git a/src/dashboard/common.go b/src/dashboard/common.go new file mode 100644 index 0000000..059c312 --- /dev/null +++ b/src/dashboard/common.go @@ -0,0 +1,41 @@ +package dashboard + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/dashboard/model" + "shylinux.com/x/operation/src/operation" +) + +type Table struct { + operation.Table + list string `name:"list client_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_CLIENT_ROLE: + s.InputsListRole(m, UserClientRoleList, arg...) + case model.CLIENT_TYPE: + s.InputsList(m, ClientTypeList, 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_CLIENT_ROLE: + value = UserClientRole(kit.Int(value)).String() + case model.CLIENT_TYPE: + value = ClientType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} + +type Tables struct{ Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} diff --git a/src/dashboard/model/model.go b/src/dashboard/model/model.go new file mode 100644 index 0000000..6423ece --- /dev/null +++ b/src/dashboard/model/model.go @@ -0,0 +1,35 @@ +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_CLIENT_ROLE = "user_client_role" + CLIENT_UID = "client_uid" + CLIENT_NAME = "client_name" + CLIENT_TYPE = "client_type" + SUMMARY_UID = "summary_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserClient struct { + db.ModelUserPlace + ClientUID string `gorm:"type:char(32);index"` +} +type Client struct { + db.ModelPlace + CompanyUID string `gorm:"type:char(32);index"` +} +type Summary struct { + db.ModelContent + ClientUID string `gorm:"type:char(32);index"` +} + +func init() { db.CmdModels("", &UserClient{}, &Client{}, &Summary{}) } diff --git a/src/dashboard/portal.go b/src/dashboard/portal.go new file mode 100644 index 0000000..826178a --- /dev/null +++ b/src/dashboard/portal.go @@ -0,0 +1,13 @@ +package dashboard + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/operation/src/operation" +) + +type Portal struct { + operation.Portal + placeCreate string `name:"placeCreate city_name* company_name* client_type*:select client_name*" role:"void"` +} + +func init() { gonganxitong.PortalCmd(Portal{Portal: operation.NewPortal(userClient{}, client{})}) } diff --git a/src/dashboard/portal.json b/src/dashboard/portal.json new file mode 100644 index 0000000..235ddc2 --- /dev/null +++ b/src/dashboard/portal.json @@ -0,0 +1,34 @@ +{ + "portal": "数据分析", + "summary": "数据汇总", + "icons": { + "summary": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Client": "我的数据", + "user_client_role": "用户角色", + "client_name": "数据名称", + "client_type": "数据类型" + }, + "value": { + "user_client_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger", + "leader": "danger" + } + }, + "client_type": { + "mysql": "MySQL", + "redis": "Redis", + "icons": { + "mysql": "https://2023-contexts.shylinux.com/p/src/studio/studio.png?pod=20230511-mysql-story", + "redis": "https://2023-contexts.shylinux.com/p/src/client/redis.png?pod=20230511-redis-story" + } + } + } +} \ No newline at end of file diff --git a/src/dashboard/summary.go b/src/dashboard/summary.go new file mode 100644 index 0000000..f819831 --- /dev/null +++ b/src/dashboard/summary.go @@ -0,0 +1,25 @@ +package dashboard + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/dashboard/model" +) + +type summary struct { + Table + client client + userClient userClient + create string `name:"create title* content*" role:"leader"` +} + +func (s summary) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CLIENT_UID))...) + s.RecordEventWithName(m, "") +} +func (s summary) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userClient, s.client, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(summary{}) } diff --git a/src/dashboard/summary.js b/src/dashboard/summary.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/dashboard/summary.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/dashboard/userClient.go b/src/dashboard/userClient.go new file mode 100644 index 0000000..83aa10f --- /dev/null +++ b/src/dashboard/userClient.go @@ -0,0 +1,15 @@ +package dashboard + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/operation/src/operation" +) + +type userClient struct{ Table } + +func init() { ice.TeamCtxCmd(userClient{}) } + +type UserClientRole = operation.UserCloudRole + +var UserClientRoleList = operation.UserCloudRoleList diff --git a/src/development/common.go b/src/development/common.go new file mode 100644 index 0000000..bd30285 --- /dev/null +++ b/src/development/common.go @@ -0,0 +1,41 @@ +package development + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/development/model" + "shylinux.com/x/operation/src/operation" +) + +type Table struct { + operation.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) +} + +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..1b9e884 --- /dev/null +++ b/src/development/model/model.go @@ -0,0 +1,35 @@ +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" + VERSION_UID = "version_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserRepos struct { + db.ModelUserPlace + ReposUID string `gorm:"type:char(32);index"` +} +type Repos struct { + db.ModelPlace + CompanyUID string `gorm:"type:char(32);index"` +} +type Version struct { + db.ModelContent + ReposUID string `gorm:"type:char(32);index"` +} + +func init() { db.CmdModels("", &UserRepos{}, &Repos{}, &Version{}) } diff --git a/src/development/portal.go b/src/development/portal.go new file mode 100644 index 0000000..7ecd0a1 --- /dev/null +++ b/src/development/portal.go @@ -0,0 +1,13 @@ +package development + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/operation/src/operation" +) + +type Portal struct { + operation.Portal + placeCreate string `name:"placeCreate city_name* company_name* repos_type*:select repos_name*" role:"void"` +} + +func init() { gonganxitong.PortalCmd(Portal{Portal: operation.NewPortal(userRepos{}, repos{})}) } diff --git a/src/development/portal.json b/src/development/portal.json new file mode 100644 index 0000000..83af8fd --- /dev/null +++ b/src/development/portal.json @@ -0,0 +1,30 @@ +{ + "portal": "软件开发", + "version": "版本", + "icons": { + "version": "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", + "leader": "danger" + } + }, + "repos_type": { + "local": "本地库", + "remote": "远程库" + } + } +} \ No newline at end of file diff --git a/src/development/repos.go b/src/development/repos.go new file mode 100644 index 0000000..044cb30 --- /dev/null +++ b/src/development/repos.go @@ -0,0 +1,21 @@ +package development + +import "shylinux.com/x/ice" + +type repos struct{ Table } + +func init() { ice.TeamCtxCmd(repos{}) } + +type ReposType int + +const ( + ReposLocal ReposType = iota + ReposRemote +) + +var ReposTypeList = map[ReposType]string{ + ReposLocal: "local", + ReposRemote: "remote", +} + +func (s ReposType) String() string { return ReposTypeList[s] } diff --git a/src/development/userRepos.go b/src/development/userRepos.go new file mode 100644 index 0000000..feea3ec --- /dev/null +++ b/src/development/userRepos.go @@ -0,0 +1,15 @@ +package development + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/operation/src/operation" +) + +type userRepos struct{ Table } + +func init() { ice.TeamCtxCmd(userRepos{}) } + +type UserReposRole = operation.UserCloudRole + +var UserReposRoleList = operation.UserCloudRoleList diff --git a/src/development/version.go b/src/development/version.go new file mode 100644 index 0000000..955f815 --- /dev/null +++ b/src/development/version.go @@ -0,0 +1,25 @@ +package development + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/development/model" +) + +type version struct { + Table + repos repos + userRepos userRepos + create string `name:"create title* content*" role:"leader"` +} + +func (s version) 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 version) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userRepos, s.repos, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(version{}) } diff --git a/src/development/version.js b/src/development/version.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/development/version.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/main.go b/src/main.go index f19cfe4..c892629 100644 --- a/src/main.go +++ b/src/main.go @@ -3,7 +3,10 @@ package main import ( "shylinux.com/x/ice" - _ "shylinux.com/x/community/src/gonganxitong" + _ "shylinux.com/x/operation/src/dashboard" + _ "shylinux.com/x/operation/src/development" + _ "shylinux.com/x/operation/src/operation" + _ "shylinux.com/x/operation/src/production" ) func main() { print(ice.Run()) } diff --git a/src/main.jpg b/src/main.jpg new file mode 100644 index 0000000..63fad23 Binary files /dev/null and b/src/main.jpg differ diff --git a/src/operation/cloud.go b/src/operation/cloud.go new file mode 100644 index 0000000..e1f69f1 --- /dev/null +++ b/src/operation/cloud.go @@ -0,0 +1,21 @@ +package operation + +import "shylinux.com/x/ice" + +type cloud struct{ Table } + +func init() { ice.TeamCtxCmd(cloud{}) } + +type CloudType int + +const ( + CloudAliyun CloudType = iota + CloudTencent +) + +var CloudTypeList = map[CloudType]string{ + CloudAliyun: "aliyun", + CloudTencent: "tencent", +} + +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..e0254f1 --- /dev/null +++ b/src/operation/common.go @@ -0,0 +1,51 @@ +package operation + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/operation/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(s.UserPlaceRole(m)) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserCloudCreator.String())...), role.String()) + return m +} + +type Tables struct{ Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} + +func NewPortal(userPlace gonganxitong.UserPlacer, place gonganxitong.Placer) Portal { + return Portal{Portal: guanlixitong.NewPortal(userPlace, place)} +} diff --git a/src/operation/model/model.go b/src/operation/model/model.go new file mode 100644 index 0000000..3f16f07 --- /dev/null +++ b/src/operation/model/model.go @@ -0,0 +1,35 @@ +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" + RELEASE_UID = "release_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserCloud struct { + db.ModelUserPlace + CloudUID string `gorm:"type:char(32);index"` +} +type Cloud struct { + db.ModelPlace + CompanyUID string `gorm:"type:char(32);index"` +} +type Release struct { + db.ModelContent + CloudUID string `gorm:"type:char(32);index"` +} + +func init() { db.CmdModels("", &UserCloud{}, &Cloud{}, &Release{}) } diff --git a/src/operation/portal.go b/src/operation/portal.go new file mode 100644 index 0000000..e229601 --- /dev/null +++ b/src/operation/portal.go @@ -0,0 +1,13 @@ +package operation + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Portal struct { + guanlixitong.Portal + placeCreate string `name:"placeCreate city_name* company_name* cloud_type*:select cloud_name*" role:"void"` +} + +func init() { gonganxitong.PortalCmd(Portal{Portal: guanlixitong.NewPortal(userCloud{}, cloud{})}) } diff --git a/src/operation/portal.json b/src/operation/portal.json new file mode 100644 index 0000000..9d8b774 --- /dev/null +++ b/src/operation/portal.json @@ -0,0 +1,30 @@ +{ + "portal": "系统运维", + "release": "发布", + "icons": { + "release": "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", + "leader": "danger" + } + }, + "cloud_type": { + "aliyun": "阿里云", + "tencent": "腾讯云" + } + } +} \ No newline at end of file diff --git a/src/operation/release.go b/src/operation/release.go new file mode 100644 index 0000000..4633a35 --- /dev/null +++ b/src/operation/release.go @@ -0,0 +1,25 @@ +package operation + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/operation/model" +) + +type release struct { + Table + cloud cloud + userCloud userCloud + 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.CLOUD_UID))...) + s.RecordEventWithName(m, "") +} +func (s release) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userCloud, s.cloud, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(release{}) } diff --git a/src/operation/release.js b/src/operation/release.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/operation/release.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/operation/userCloud.go b/src/operation/userCloud.go new file mode 100644 index 0000000..4aaf27a --- /dev/null +++ b/src/operation/userCloud.go @@ -0,0 +1,27 @@ +package operation + +import "shylinux.com/x/ice" + +type userCloud struct{ Table } + +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] } diff --git a/src/option.go b/src/option.go new file mode 100644 index 0000000..4a3afff --- /dev/null +++ b/src/option.go @@ -0,0 +1,5 @@ +package main + +import ( + _ "shylinux.com/x/mysql-story/src/db/mysql" +) diff --git a/src/production/common.go b/src/production/common.go new file mode 100644 index 0000000..597dfcf --- /dev/null +++ b/src/production/common.go @@ -0,0 +1,41 @@ +package production + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/operation" + "shylinux.com/x/operation/src/production/model" +) + +type Table struct { + operation.Table + list string `name:"list story_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_STORY_ROLE: + s.InputsListRole(m, UserStoryRoleList, arg...) + case model.STORY_TYPE: + s.InputsList(m, StoryTypeList, 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_STORY_ROLE: + value = UserStoryRole(kit.Int(value)).String() + case model.STORY_TYPE: + value = StoryType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} + +type Tables struct{ Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} diff --git a/src/production/issue.go b/src/production/issue.go new file mode 100644 index 0000000..4fcbf5a --- /dev/null +++ b/src/production/issue.go @@ -0,0 +1,39 @@ +package production + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/operation/src/production/model" +) + +type issue struct { + Table + story story + userStory userStory + create string `name:"create title* content*" role:"leader"` +} + +func (s issue) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.STORY_UID))...) + s.RecordEventWithName(m, "") +} +func (s issue) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userStory, s.story, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(issue{}) } + +type IssueType int + +const ( + IssueFeature IssueType = iota + IssueBugfix +) + +var IssueTypeList = map[IssueType]string{ + IssueFeature: "feature", + IssueBugfix: "bugfix", +} + +func (s IssueType) String() string { return IssueTypeList[s] } diff --git a/src/production/issue.js b/src/production/issue.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/production/issue.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/production/model/model.go b/src/production/model/model.go new file mode 100644 index 0000000..fe31cfa --- /dev/null +++ b/src/production/model/model.go @@ -0,0 +1,35 @@ +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_STORY_ROLE = "user_story_role" + STORY_UID = "story_uid" + STORY_NAME = "story_name" + STORY_TYPE = "story_type" + ISSUE_UID = "issue_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserStory struct { + db.ModelUserPlace + StoryUID string `gorm:"type:char(32);index"` +} +type Story struct { + db.ModelPlace + CompanyUID string `gorm:"type:char(32);index"` +} +type Issue struct { + db.ModelContent + StoryUID string `gorm:"type:char(32);index"` +} + +func init() { db.CmdModels("", &UserStory{}, &Story{}, &Issue{}) } diff --git a/src/production/portal.go b/src/production/portal.go new file mode 100644 index 0000000..fad7069 --- /dev/null +++ b/src/production/portal.go @@ -0,0 +1,13 @@ +package production + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Portal struct { + guanlixitong.Portal + placeCreate string `name:"placeCreate city_name* company_name* story_type*:select story_name*" role:"void"` +} + +func init() { gonganxitong.PortalCmd(Portal{Portal: guanlixitong.NewPortal(userStory{}, story{})}) } diff --git a/src/production/portal.json b/src/production/portal.json new file mode 100644 index 0000000..cf37ab7 --- /dev/null +++ b/src/production/portal.json @@ -0,0 +1,35 @@ +{ + "portal": "产品迭代", + "issue": "场景应用", + "icons": { + "issue": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Story": "我的场景", + "user_story_role": "用户角色", + "story_name": "场景名称", + "story_type": "场景类型" + }, + "value": { + "user_story_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger", + "leader": "danger" + } + }, + "story_type": { + "RD": "研发群", + "OP": "运维群", + "HR": "人力群" + }, + "issue_type": { + "feature": "新功能", + "bugfix": "问题修复" + } + } +} \ No newline at end of file diff --git a/src/production/story.go b/src/production/story.go new file mode 100644 index 0000000..47cee23 --- /dev/null +++ b/src/production/story.go @@ -0,0 +1,23 @@ +package production + +import "shylinux.com/x/ice" + +type story struct{ Table } + +func init() { ice.TeamCtxCmd(story{}) } + +type StoryType int + +const ( + StoryRD StoryType = iota + StoryOP + StoryHR +) + +var StoryTypeList = map[StoryType]string{ + StoryRD: "RD", + StoryOP: "OP", + StoryHR: "HR", +} + +func (s StoryType) String() string { return StoryTypeList[s] } diff --git a/src/production/userStory.go b/src/production/userStory.go new file mode 100644 index 0000000..c084ec9 --- /dev/null +++ b/src/production/userStory.go @@ -0,0 +1,15 @@ +package production + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/operation/src/operation" +) + +type userStory struct{ Table } + +func init() { ice.TeamCtxCmd(userStory{}) } + +type UserStoryRole = operation.UserCloudRole + +var UserStoryRoleList = operation.UserCloudRoleList