From 077186704a688a5df5fc65eb222138fc9cc555b3 Mon Sep 17 00:00:00 2001 From: jingganjiaoyu Date: Thu, 29 Aug 2024 11:10:04 +0800 Subject: [PATCH] opt some --- src/jiaocaiziliao/common.go | 56 ++++++++++++++++++++++++ src/jiaocaiziliao/document.go | 42 ++++++++++++++++++ src/jiaocaiziliao/document.js | 11 +++++ src/jiaocaiziliao/issuer.go | 21 +++++++++ src/jiaocaiziliao/model/model.go | 54 +++++++++++++++++++++++ src/jiaocaiziliao/official.go | 19 ++++++++ src/jiaocaiziliao/portal.go | 15 +++++++ src/jiaocaiziliao/portal.json | 36 +++++++++++++++ src/jiaocaiziliao/userIssuer.go | 63 +++++++++++++++++++++++++++ src/kaoshixitong/common.go | 52 ++++++++++++++++++++++ src/kaoshixitong/exam.go | 23 ++++++++++ src/kaoshixitong/model/model.go | 43 ++++++++++++++++++ src/kaoshixitong/portal.go | 15 +++++++ src/kaoshixitong/portal.json | 33 ++++++++++++++ src/kaoshixitong/question.go | 25 +++++++++++ src/kaoshixitong/question.js | 9 ++++ src/kaoshixitong/userExam.go | 62 ++++++++++++++++++++++++++ src/main.go | 5 +++ src/shichangyingxiao/channel.go | 23 ++++++++++ src/shichangyingxiao/common.go | 52 ++++++++++++++++++++++ src/shichangyingxiao/model/model.go | 43 ++++++++++++++++++ src/shichangyingxiao/portal.go | 15 +++++++ src/shichangyingxiao/portal.json | 33 ++++++++++++++ src/shichangyingxiao/promotion.go | 25 +++++++++++ src/shichangyingxiao/promotion.js | 9 ++++ src/shichangyingxiao/userChannel.go | 62 ++++++++++++++++++++++++++ src/template/web.code.autogen/demo.go | 4 +- src/zaixianketang/common.go | 52 ++++++++++++++++++++++ src/zaixianketang/course.go | 23 ++++++++++ src/zaixianketang/lesson.go | 25 +++++++++++ src/zaixianketang/lesson.js | 9 ++++ src/zaixianketang/model/model.go | 43 ++++++++++++++++++ src/zaixianketang/portal.go | 15 +++++++ src/zaixianketang/portal.json | 33 ++++++++++++++ src/zaixianketang/userCourse.go | 62 ++++++++++++++++++++++++++ src/zhengshuxitong/auth.go | 23 ++++++++++ src/zhengshuxitong/cert.go | 25 +++++++++++ src/zhengshuxitong/cert.js | 9 ++++ src/zhengshuxitong/common.go | 52 ++++++++++++++++++++++ src/zhengshuxitong/model/model.go | 43 ++++++++++++++++++ src/zhengshuxitong/portal.go | 15 +++++++ src/zhengshuxitong/portal.json | 33 ++++++++++++++ src/zhengshuxitong/userAuth.go | 62 ++++++++++++++++++++++++++ src/zijinlian/common.go | 52 ++++++++++++++++++++++ src/zijinlian/investment.go | 25 +++++++++++ src/zijinlian/investment.js | 9 ++++ src/zijinlian/investor.go | 23 ++++++++++ src/zijinlian/model/model.go | 43 ++++++++++++++++++ src/zijinlian/portal.go | 15 +++++++ src/zijinlian/portal.json | 33 ++++++++++++++ src/zijinlian/userInvestor.go | 62 ++++++++++++++++++++++++++ usr/local/export/mdb.export/hash.json | 35 +++++++++++++++ 52 files changed, 1668 insertions(+), 3 deletions(-) create mode 100644 src/jiaocaiziliao/common.go create mode 100644 src/jiaocaiziliao/document.go create mode 100644 src/jiaocaiziliao/document.js create mode 100644 src/jiaocaiziliao/issuer.go create mode 100644 src/jiaocaiziliao/model/model.go create mode 100644 src/jiaocaiziliao/official.go create mode 100644 src/jiaocaiziliao/portal.go create mode 100644 src/jiaocaiziliao/portal.json create mode 100644 src/jiaocaiziliao/userIssuer.go create mode 100644 src/kaoshixitong/common.go create mode 100644 src/kaoshixitong/exam.go create mode 100644 src/kaoshixitong/model/model.go create mode 100644 src/kaoshixitong/portal.go create mode 100644 src/kaoshixitong/portal.json create mode 100644 src/kaoshixitong/question.go create mode 100644 src/kaoshixitong/question.js create mode 100644 src/kaoshixitong/userExam.go create mode 100644 src/shichangyingxiao/channel.go create mode 100644 src/shichangyingxiao/common.go create mode 100644 src/shichangyingxiao/model/model.go create mode 100644 src/shichangyingxiao/portal.go create mode 100644 src/shichangyingxiao/portal.json create mode 100644 src/shichangyingxiao/promotion.go create mode 100644 src/shichangyingxiao/promotion.js create mode 100644 src/shichangyingxiao/userChannel.go create mode 100644 src/zaixianketang/common.go create mode 100644 src/zaixianketang/course.go create mode 100644 src/zaixianketang/lesson.go create mode 100644 src/zaixianketang/lesson.js create mode 100644 src/zaixianketang/model/model.go create mode 100644 src/zaixianketang/portal.go create mode 100644 src/zaixianketang/portal.json create mode 100644 src/zaixianketang/userCourse.go create mode 100644 src/zhengshuxitong/auth.go create mode 100644 src/zhengshuxitong/cert.go create mode 100644 src/zhengshuxitong/cert.js create mode 100644 src/zhengshuxitong/common.go create mode 100644 src/zhengshuxitong/model/model.go create mode 100644 src/zhengshuxitong/portal.go create mode 100644 src/zhengshuxitong/portal.json create mode 100644 src/zhengshuxitong/userAuth.go create mode 100644 src/zijinlian/common.go create mode 100644 src/zijinlian/investment.go create mode 100644 src/zijinlian/investment.js create mode 100644 src/zijinlian/investor.go create mode 100644 src/zijinlian/model/model.go create mode 100644 src/zijinlian/portal.go create mode 100644 src/zijinlian/portal.json create mode 100644 src/zijinlian/userInvestor.go diff --git a/src/jiaocaiziliao/common.go b/src/jiaocaiziliao/common.go new file mode 100644 index 0000000..1222af7 --- /dev/null +++ b/src/jiaocaiziliao/common.go @@ -0,0 +1,56 @@ +package jiaocaiziliao + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/jiaocaiziliao/model" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Table struct { + guanlixitong.Table + list string `name:"list issuer_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_ISSUER_ROLE: + s.InputsListRole(m, UserIssuerRoleList, arg...) + case model.ISSUER_TYPE: + s.InputsList(m, IssuerTypeList, arg...) + case model.DOCUMENT_TYPE: + s.InputsList(m, DocumentTypeList, 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_ISSUER_ROLE: + value = UserIssuerRole(kit.Int(value)).String() + case model.ISSUER_TYPE: + value = IssuerType(kit.Int(value)).String() + case model.DOCUMENT_TYPE: + value = DocumentType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserIssuerRole(kit.Int(m.Cmd(userIssuer{}, s.Select, m.OptionSimple(model.ISSUER_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserIssuerCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.ISSUER_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.ISSUER_UID), info) +} + +type Tables struct{ Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} diff --git a/src/jiaocaiziliao/document.go b/src/jiaocaiziliao/document.go new file mode 100644 index 0000000..eb797f4 --- /dev/null +++ b/src/jiaocaiziliao/document.go @@ -0,0 +1,42 @@ +package jiaocaiziliao + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/jiaocaiziliao/model" +) + +type document struct { + Table + create string `name:"create school* subject* grade* document_type*:select title* content* icon* link*" role:"leader,worker"` +} + +func (s document) Create(m *ice.Message, arg ...string) { + arg = kit.TransArgKeys(arg, model.DOCUMENT_TYPE, model.TYPE) + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.ISSUER_UID))...) +} +func (s document) List(m *ice.Message, arg ...string) { + if len(arg) == 1 { + s.Select(m, model.ISSUER_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.ISSUER_UID, arg[0], model.UID, arg[1]) + } + m.RenameAppend(model.TYPE, model.DOCUMENT_TYPE) +} + +func init() { ice.TeamCtxCmd(document{}) } + +type DocumentType int + +const ( + DocumentBook DocumentType = iota + DocumentPaper +) + +var DocumentTypeList = map[DocumentType]string{ + DocumentBook: "book", + DocumentPaper: "paper", +} + +func (s DocumentType) String() string { return DocumentTypeList[s] } diff --git a/src/jiaocaiziliao/document.js b/src/jiaocaiziliao/document.js new file mode 100644 index 0000000..c848a4c --- /dev/null +++ b/src/jiaocaiziliao/document.js @@ -0,0 +1,11 @@ +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)]}, + {view: html.STATUS, list: [value.school, value.grade, value.subject]}, + {view: html.OUTPUT, list: [value.content]}, + {view: html.OUTPUT, list: [{type: "a", href: value.link, inner: "在线阅读"}]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/jiaocaiziliao/issuer.go b/src/jiaocaiziliao/issuer.go new file mode 100644 index 0000000..7a50746 --- /dev/null +++ b/src/jiaocaiziliao/issuer.go @@ -0,0 +1,21 @@ +package jiaocaiziliao + +import "shylinux.com/x/ice" + +type issuer struct{ Table } + +func init() { ice.TeamCtxCmd(issuer{}) } + +type IssuerType int + +const ( + IssuerPersonal IssuerType = iota + IssuerPublisher +) + +var IssuerTypeList = map[IssuerType]string{ + IssuerPersonal: "personal", + IssuerPublisher: "publisher", +} + +func (s IssuerType) String() string { return IssuerTypeList[s] } diff --git a/src/jiaocaiziliao/model/model.go b/src/jiaocaiziliao/model/model.go new file mode 100644 index 0000000..e9ea3ac --- /dev/null +++ b/src/jiaocaiziliao/model/model.go @@ -0,0 +1,54 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + LINK = "link" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_ISSUER_ROLE = "user_issuer_role" + ISSUER_UID = "issuer_uid" + ISSUER_NAME = "issuer_name" + ISSUER_TYPE = "issuer_type" + DOCUMENT_UID = "document_uid" + DOCUMENT_TYPE = "document_type" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" + INDEX = "index" + INIT = "init" +) + +type UserIssuer struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + IssuerUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Issuer struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` + Link string `gorm:"type:varchar(255)"` + Init uint8 +} +type Document struct { + db.ModelWithUID + IssuerUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32);index"` + School string `gorm:"type:varchar(32)"` + Subject string `gorm:"type:varchar(32)"` + Grade string `gorm:"type:varchar(32)"` + Type uint8 `gorm:"default:0"` + Icon string `gorm:"type:varchar(64)"` + Link string `gorm:"type:varchar(255)"` + Title string `gorm:"type:varchar(64)"` + Content string +} + +func init() { db.CmdModels("", &UserIssuer{}, &Issuer{}, &Document{}) } diff --git a/src/jiaocaiziliao/official.go b/src/jiaocaiziliao/official.go new file mode 100644 index 0000000..ef2c77b --- /dev/null +++ b/src/jiaocaiziliao/official.go @@ -0,0 +1,19 @@ +package jiaocaiziliao + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/jiaocaiziliao/model" +) + +type offical struct { + Tables + userIssuer userIssuer +} + +func (s offical) List(m *ice.Message, arg ...string) { + m.Cmdy(s.userIssuer, m.Option(model.USER_UID), arg) + m.ProcessOpen(m.Append(model.LINK)) +} + +func init() { ice.TeamCtxCmd(offical{}) } diff --git a/src/jiaocaiziliao/portal.go b/src/jiaocaiziliao/portal.go new file mode 100644 index 0000000..a77957c --- /dev/null +++ b/src/jiaocaiziliao/portal.go @@ -0,0 +1,15 @@ +package jiaocaiziliao + +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* issuer_type*:select issuer_name* link" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userIssuer{}, issuer{}, guanlixitong.Company{})}) +} diff --git a/src/jiaocaiziliao/portal.json b/src/jiaocaiziliao/portal.json new file mode 100644 index 0000000..c619718 --- /dev/null +++ b/src/jiaocaiziliao/portal.json @@ -0,0 +1,36 @@ +{ + "portal": "教材资料", + "document": "教材资料", + "official": "官方网站", + "icons": { + "official": "https://img.icons8.com/officel/80/activity-grid.png", + "document": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Issuer": "我的文库", + "user_issuer_role": "用户角色", + "school": "学校", + "subject": "学科", + "grade": "年级", + "document_type": "文档类型", + "issuer_name": "文库名称", + "issuer_type": "文库类型" + }, + "value": { + "user_issuer_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger", + "leader": "danger" + } + }, + "issuer_type": { + "personal": "个人版", + "publisher": "出版社" + } + } +} \ No newline at end of file diff --git a/src/jiaocaiziliao/userIssuer.go b/src/jiaocaiziliao/userIssuer.go new file mode 100644 index 0000000..351baa6 --- /dev/null +++ b/src/jiaocaiziliao/userIssuer.go @@ -0,0 +1,63 @@ +package jiaocaiziliao + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/jiaocaiziliao/model" +) + +type userIssuer struct { + Table + issuer issuer +} + +func (s userIssuer) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.ISSUER_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.ISSUER_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_ISSUER_ROLE) + s.SelectJoinUser(m) +} +func (s userIssuer) List(m *ice.Message, arg ...string) { + s.Tables(m, s.issuer).FieldsWithCreatedAT(m, s, + model.ISSUER_NAME, model.ISSUER_TYPE, model.USER_ISSUER_ROLE, + model.COMPANY_UID, model.ISSUER_UID, + model.INIT, model.LINK, + ) + 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.ISSUER_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userIssuer{}) } + +type UserIssuerRole int + +const ( + UserIssuerVisitor UserIssuerRole = iota + UserIssuerCreator + UserIssuerLeader + UserIssuerWorker + UserIssuerServer +) + +var UserIssuerRoleList = map[UserIssuerRole]string{ + UserIssuerVisitor: "visitor", + UserIssuerCreator: "creator", + UserIssuerLeader: "leader", + UserIssuerWorker: "worker", + UserIssuerServer: "server", +} + +func (s UserIssuerRole) String() string { return UserIssuerRoleList[s] } diff --git a/src/kaoshixitong/common.go b/src/kaoshixitong/common.go new file mode 100644 index 0000000..13e1a7e --- /dev/null +++ b/src/kaoshixitong/common.go @@ -0,0 +1,52 @@ +package kaoshixitong + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/education/src/kaoshixitong/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list exam_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_EXAM_ROLE: + s.InputsListRole(m, UserExamRoleList, arg...) + case model.EXAM_TYPE: + s.InputsList(m, ExamTypeList, 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_EXAM_ROLE: + value = UserExamRole(kit.Int(value)).String() + case model.EXAM_TYPE: + value = ExamType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserExamRole(kit.Int(m.Cmd(userExam{}, s.Select, m.OptionSimple(model.EXAM_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserExamCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.EXAM_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.EXAM_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/kaoshixitong/exam.go b/src/kaoshixitong/exam.go new file mode 100644 index 0000000..10e4f47 --- /dev/null +++ b/src/kaoshixitong/exam.go @@ -0,0 +1,23 @@ +package kaoshixitong + +import "shylinux.com/x/ice" + +type exam struct{ Table } + +func init() { ice.TeamCtxCmd(exam{}) } + +type ExamType int + +const ( + ExamRD ExamType = iota + ExamOP + ExamHR +) + +var ExamTypeList = map[ExamType]string{ + ExamRD: "RD", + ExamOP: "OP", + ExamHR: "HR", +} + +func (s ExamType) String() string { return ExamTypeList[s] } \ No newline at end of file diff --git a/src/kaoshixitong/model/model.go b/src/kaoshixitong/model/model.go new file mode 100644 index 0000000..8bc3b1a --- /dev/null +++ b/src/kaoshixitong/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_EXAM_ROLE = "user_exam_role" + EXAM_UID = "exam_uid" + EXAM_NAME = "exam_name" + EXAM_TYPE = "exam_type" + QUESTION_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserExam struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + ExamUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Exam struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Question struct { + db.ModelWithUID + ExamUID 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("", &UserExam{}, &Exam{}, &Question{}) } \ No newline at end of file diff --git a/src/kaoshixitong/portal.go b/src/kaoshixitong/portal.go new file mode 100644 index 0000000..054c4d7 --- /dev/null +++ b/src/kaoshixitong/portal.go @@ -0,0 +1,15 @@ +package kaoshixitong + +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* exam_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userExam{}, exam{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/kaoshixitong/portal.json b/src/kaoshixitong/portal.json new file mode 100644 index 0000000..095bf06 --- /dev/null +++ b/src/kaoshixitong/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "考试系统", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Exam": "我的场景", + "user_exam_role": "用户角色", + "exam_name": "场景名称", + "exam_type": "场景类型" + }, + "value": { + "user_exam_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "exam_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/kaoshixitong/question.go b/src/kaoshixitong/question.go new file mode 100644 index 0000000..5701e32 --- /dev/null +++ b/src/kaoshixitong/question.go @@ -0,0 +1,25 @@ +package kaoshixitong + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/kaoshixitong/model" +) + +type question struct { + Table + exam exam + userExam userExam + create string `name:"create title* content*" role:"leader"` +} + +func (s question) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.EXAM_UID))...) + s.recordEventWithName(m, "") +} +func (s question) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userExam, s.exam, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(question{}) } \ No newline at end of file diff --git a/src/kaoshixitong/question.js b/src/kaoshixitong/question.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/kaoshixitong/question.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/kaoshixitong/userExam.go b/src/kaoshixitong/userExam.go new file mode 100644 index 0000000..95f8440 --- /dev/null +++ b/src/kaoshixitong/userExam.go @@ -0,0 +1,62 @@ +package kaoshixitong + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/kaoshixitong/model" +) + +type userExam struct { + Table + exam exam +} + +func (s userExam) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.EXAM_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.EXAM_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_EXAM_ROLE) + s.SelectJoinUser(m) +} +func (s userExam) List(m *ice.Message, arg ...string) { + s.Tables(m, s.exam).FieldsWithCreatedAT(m, s, + model.EXAM_NAME, model.EXAM_TYPE, model.USER_EXAM_ROLE, + model.COMPANY_UID, model.EXAM_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.EXAM_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userExam{}) } + +type UserExamRole int + +const ( + UserExamVisitor UserExamRole = iota + UserExamCreator + UserExamLeader + UserExamWorker + UserExamServer +) + +var UserExamRoleList = map[UserExamRole]string{ + UserExamVisitor: "visitor", + UserExamCreator: "creator", + UserExamLeader: "leader", + UserExamWorker: "worker", + UserExamServer: "server", +} + +func (s UserExamRole) String() string { return UserExamRoleList[s] } \ No newline at end of file diff --git a/src/main.go b/src/main.go index 0600d73..a37a154 100644 --- a/src/main.go +++ b/src/main.go @@ -4,6 +4,11 @@ import ( "shylinux.com/x/ice" _ "shylinux.com/x/education/src/jiaowuxitong" + _ "shylinux.com/x/education/src/kaoshixitong" + _ "shylinux.com/x/education/src/zaixianketang" + _ "shylinux.com/x/education/src/zhengshuxitong" + + _ "shylinux.com/x/education/src/jiaocaiziliao" ) func main() { print(ice.Run()) } diff --git a/src/shichangyingxiao/channel.go b/src/shichangyingxiao/channel.go new file mode 100644 index 0000000..ca9c44c --- /dev/null +++ b/src/shichangyingxiao/channel.go @@ -0,0 +1,23 @@ +package shichangyingxiao + +import "shylinux.com/x/ice" + +type channel struct{ Table } + +func init() { ice.TeamCtxCmd(channel{}) } + +type ChannelType int + +const ( + ChannelRD ChannelType = iota + ChannelOP + ChannelHR +) + +var ChannelTypeList = map[ChannelType]string{ + ChannelRD: "RD", + ChannelOP: "OP", + ChannelHR: "HR", +} + +func (s ChannelType) String() string { return ChannelTypeList[s] } \ No newline at end of file diff --git a/src/shichangyingxiao/common.go b/src/shichangyingxiao/common.go new file mode 100644 index 0000000..de346eb --- /dev/null +++ b/src/shichangyingxiao/common.go @@ -0,0 +1,52 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/education/src/shichangyingxiao/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list channel_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_CHANNEL_ROLE: + s.InputsListRole(m, UserChannelRoleList, arg...) + case model.CHANNEL_TYPE: + s.InputsList(m, ChannelTypeList, arg...) + default: + s.Table.Inputs(m, arg...) + } +} +func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { + m.RewriteAppend(func(value, key string, index int) string { + switch key { + case model.USER_CHANNEL_ROLE: + value = UserChannelRole(kit.Int(value)).String() + case model.CHANNEL_TYPE: + value = ChannelType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserChannelRole(kit.Int(m.Cmd(userChannel{}, s.Select, m.OptionSimple(model.CHANNEL_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserChannelCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.CHANNEL_UID), info, kit.Select(m.Option(model.UID), arg, 0)) +} +func (s Table) recordEventWithName(m *ice.Message, info string, arg ...string) { + s.Table.RecordEventWithName(m, m.Option(model.CHANNEL_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/shichangyingxiao/model/model.go b/src/shichangyingxiao/model/model.go new file mode 100644 index 0000000..dee4a3d --- /dev/null +++ b/src/shichangyingxiao/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_CHANNEL_ROLE = "user_channel_role" + CHANNEL_UID = "channel_uid" + CHANNEL_NAME = "channel_name" + CHANNEL_TYPE = "channel_type" + PROMOTION_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserChannel struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + ChannelUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Channel struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Promotion struct { + db.ModelWithUID + ChannelUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32);index"` + Title string `gorm:"type:varchar(64)"` + Content string +} + + +func init() { db.CmdModels("", &UserChannel{}, &Channel{}, &Promotion{}) } \ No newline at end of file diff --git a/src/shichangyingxiao/portal.go b/src/shichangyingxiao/portal.go new file mode 100644 index 0000000..9713e82 --- /dev/null +++ b/src/shichangyingxiao/portal.go @@ -0,0 +1,15 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Portal struct { + gonganxitong.Portal + placeCreate string `name:"placeCreate city_name* company_name* channel_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userChannel{}, channel{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/shichangyingxiao/portal.json b/src/shichangyingxiao/portal.json new file mode 100644 index 0000000..cf3ae0a --- /dev/null +++ b/src/shichangyingxiao/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "市场营销", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Channel": "我的场景", + "user_channel_role": "用户角色", + "channel_name": "场景名称", + "channel_type": "场景类型" + }, + "value": { + "user_channel_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "channel_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/shichangyingxiao/promotion.go b/src/shichangyingxiao/promotion.go new file mode 100644 index 0000000..43d9367 --- /dev/null +++ b/src/shichangyingxiao/promotion.go @@ -0,0 +1,25 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/shichangyingxiao/model" +) + +type promotion struct { + Table + channel channel + userChannel userChannel + create string `name:"create title* content*" role:"leader"` +} + +func (s promotion) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CHANNEL_UID))...) + s.recordEventWithName(m, "") +} +func (s promotion) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userChannel, s.channel, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(promotion{}) } \ No newline at end of file diff --git a/src/shichangyingxiao/promotion.js b/src/shichangyingxiao/promotion.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/shichangyingxiao/promotion.js @@ -0,0 +1,9 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { can.onimport.shareTitle(can, msg) + can.onimport.itemcards(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.title]}, + {view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at), value.user_name]}, + {view: html.OUTPUT, list: [value.content]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/shichangyingxiao/userChannel.go b/src/shichangyingxiao/userChannel.go new file mode 100644 index 0000000..fa3d2b0 --- /dev/null +++ b/src/shichangyingxiao/userChannel.go @@ -0,0 +1,62 @@ +package shichangyingxiao + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/shichangyingxiao/model" +) + +type userChannel struct { + Table + channel channel +} + +func (s userChannel) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.CHANNEL_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.CHANNEL_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_CHANNEL_ROLE) + s.SelectJoinUser(m) +} +func (s userChannel) List(m *ice.Message, arg ...string) { + s.Tables(m, s.channel).FieldsWithCreatedAT(m, s, + model.CHANNEL_NAME, model.CHANNEL_TYPE, model.USER_CHANNEL_ROLE, + model.COMPANY_UID, model.CHANNEL_UID, + ) + if len(arg) == 1 { + s.Select(m, model.USER_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s, model.CHANNEL_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userChannel{}) } + +type UserChannelRole int + +const ( + UserChannelVisitor UserChannelRole = iota + UserChannelCreator + UserChannelLeader + UserChannelWorker + UserChannelServer +) + +var UserChannelRoleList = map[UserChannelRole]string{ + UserChannelVisitor: "visitor", + UserChannelCreator: "creator", + UserChannelLeader: "leader", + UserChannelWorker: "worker", + UserChannelServer: "server", +} + +func (s UserChannelRole) String() string { return UserChannelRoleList[s] } \ No newline at end of file diff --git a/src/template/web.code.autogen/demo.go b/src/template/web.code.autogen/demo.go index 676d21e..599f8c8 100644 --- a/src/template/web.code.autogen/demo.go +++ b/src/template/web.code.autogen/demo.go @@ -2,9 +2,7 @@ package {{.Option "zone"}} import "shylinux.com/x/ice" -type {{.Option "name"}} struct { - Table -} +type {{.Option "name"}} struct{ Tables } func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) { s.Table.List(m, arg...) diff --git a/src/zaixianketang/common.go b/src/zaixianketang/common.go new file mode 100644 index 0000000..92b990d --- /dev/null +++ b/src/zaixianketang/common.go @@ -0,0 +1,52 @@ +package zaixianketang + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/education/src/zaixianketang/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list course_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_COURSE_ROLE: + s.InputsListRole(m, UserCourseRoleList, arg...) + case model.COURSE_TYPE: + s.InputsList(m, CourseTypeList, 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_COURSE_ROLE: + value = UserCourseRole(kit.Int(value)).String() + case model.COURSE_TYPE: + value = CourseType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserCourseRole(kit.Int(m.Cmd(userCourse{}, s.Select, m.OptionSimple(model.COURSE_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserCourseCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.COURSE_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.COURSE_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/zaixianketang/course.go b/src/zaixianketang/course.go new file mode 100644 index 0000000..75e146b --- /dev/null +++ b/src/zaixianketang/course.go @@ -0,0 +1,23 @@ +package zaixianketang + +import "shylinux.com/x/ice" + +type course struct{ Table } + +func init() { ice.TeamCtxCmd(course{}) } + +type CourseType int + +const ( + CourseRD CourseType = iota + CourseOP + CourseHR +) + +var CourseTypeList = map[CourseType]string{ + CourseRD: "RD", + CourseOP: "OP", + CourseHR: "HR", +} + +func (s CourseType) String() string { return CourseTypeList[s] } \ No newline at end of file diff --git a/src/zaixianketang/lesson.go b/src/zaixianketang/lesson.go new file mode 100644 index 0000000..7c0e288 --- /dev/null +++ b/src/zaixianketang/lesson.go @@ -0,0 +1,25 @@ +package zaixianketang + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/zaixianketang/model" +) + +type lesson struct { + Table + course course + userCourse userCourse + create string `name:"create title* content*" role:"leader"` +} + +func (s lesson) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.COURSE_UID))...) + s.recordEventWithName(m, "") +} +func (s lesson) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userCourse, s.course, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(lesson{}) } \ No newline at end of file diff --git a/src/zaixianketang/lesson.js b/src/zaixianketang/lesson.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/zaixianketang/lesson.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/zaixianketang/model/model.go b/src/zaixianketang/model/model.go new file mode 100644 index 0000000..9dcfcfc --- /dev/null +++ b/src/zaixianketang/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_COURSE_ROLE = "user_course_role" + COURSE_UID = "course_uid" + COURSE_NAME = "course_name" + COURSE_TYPE = "course_type" + LESSON_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserCourse struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + CourseUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Course struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Lesson struct { + db.ModelWithUID + CourseUID 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("", &UserCourse{}, &Course{}, &Lesson{}) } \ No newline at end of file diff --git a/src/zaixianketang/portal.go b/src/zaixianketang/portal.go new file mode 100644 index 0000000..210a432 --- /dev/null +++ b/src/zaixianketang/portal.go @@ -0,0 +1,15 @@ +package zaixianketang + +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* course_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userCourse{}, course{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/zaixianketang/portal.json b/src/zaixianketang/portal.json new file mode 100644 index 0000000..dbd270c --- /dev/null +++ b/src/zaixianketang/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "在线课堂", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Course": "我的场景", + "user_course_role": "用户角色", + "course_name": "场景名称", + "course_type": "场景类型" + }, + "value": { + "user_course_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "course_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/zaixianketang/userCourse.go b/src/zaixianketang/userCourse.go new file mode 100644 index 0000000..9b3197f --- /dev/null +++ b/src/zaixianketang/userCourse.go @@ -0,0 +1,62 @@ +package zaixianketang + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/zaixianketang/model" +) + +type userCourse struct { + Table + course course +} + +func (s userCourse) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.COURSE_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.COURSE_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_COURSE_ROLE) + s.SelectJoinUser(m) +} +func (s userCourse) List(m *ice.Message, arg ...string) { + s.Tables(m, s.course).FieldsWithCreatedAT(m, s, + model.COURSE_NAME, model.COURSE_TYPE, model.USER_COURSE_ROLE, + model.COMPANY_UID, model.COURSE_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.COURSE_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userCourse{}) } + +type UserCourseRole int + +const ( + UserCourseVisitor UserCourseRole = iota + UserCourseCreator + UserCourseLeader + UserCourseWorker + UserCourseServer +) + +var UserCourseRoleList = map[UserCourseRole]string{ + UserCourseVisitor: "visitor", + UserCourseCreator: "creator", + UserCourseLeader: "leader", + UserCourseWorker: "worker", + UserCourseServer: "server", +} + +func (s UserCourseRole) String() string { return UserCourseRoleList[s] } \ No newline at end of file diff --git a/src/zhengshuxitong/auth.go b/src/zhengshuxitong/auth.go new file mode 100644 index 0000000..45bf125 --- /dev/null +++ b/src/zhengshuxitong/auth.go @@ -0,0 +1,23 @@ +package zhengshuxitong + +import "shylinux.com/x/ice" + +type auth struct{ Table } + +func init() { ice.TeamCtxCmd(auth{}) } + +type AuthType int + +const ( + AuthRD AuthType = iota + AuthOP + AuthHR +) + +var AuthTypeList = map[AuthType]string{ + AuthRD: "RD", + AuthOP: "OP", + AuthHR: "HR", +} + +func (s AuthType) String() string { return AuthTypeList[s] } \ No newline at end of file diff --git a/src/zhengshuxitong/cert.go b/src/zhengshuxitong/cert.go new file mode 100644 index 0000000..21bb0cb --- /dev/null +++ b/src/zhengshuxitong/cert.go @@ -0,0 +1,25 @@ +package zhengshuxitong + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/zhengshuxitong/model" +) + +type cert struct { + Table + auth auth + userAuth userAuth + create string `name:"create title* content*" role:"leader"` +} + +func (s cert) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.AUTH_UID))...) + s.recordEventWithName(m, "") +} +func (s cert) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userAuth, s.auth, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(cert{}) } \ No newline at end of file diff --git a/src/zhengshuxitong/cert.js b/src/zhengshuxitong/cert.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/zhengshuxitong/cert.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/zhengshuxitong/common.go b/src/zhengshuxitong/common.go new file mode 100644 index 0000000..c45204b --- /dev/null +++ b/src/zhengshuxitong/common.go @@ -0,0 +1,52 @@ +package zhengshuxitong + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/education/src/zhengshuxitong/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list auth_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_AUTH_ROLE: + s.InputsListRole(m, UserAuthRoleList, arg...) + case model.AUTH_TYPE: + s.InputsList(m, AuthTypeList, 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_AUTH_ROLE: + value = UserAuthRole(kit.Int(value)).String() + case model.AUTH_TYPE: + value = AuthType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserAuthRole(kit.Int(m.Cmd(userAuth{}, s.Select, m.OptionSimple(model.AUTH_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserAuthCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.AUTH_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.AUTH_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/zhengshuxitong/model/model.go b/src/zhengshuxitong/model/model.go new file mode 100644 index 0000000..9edafb0 --- /dev/null +++ b/src/zhengshuxitong/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_AUTH_ROLE = "user_auth_role" + AUTH_UID = "auth_uid" + AUTH_NAME = "auth_name" + AUTH_TYPE = "auth_type" + CERT_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserAuth struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + AuthUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Auth struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Cert struct { + db.ModelWithUID + AuthUID 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("", &UserAuth{}, &Auth{}, &Cert{}) } \ No newline at end of file diff --git a/src/zhengshuxitong/portal.go b/src/zhengshuxitong/portal.go new file mode 100644 index 0000000..e601b6c --- /dev/null +++ b/src/zhengshuxitong/portal.go @@ -0,0 +1,15 @@ +package zhengshuxitong + +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* auth_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userAuth{}, auth{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/zhengshuxitong/portal.json b/src/zhengshuxitong/portal.json new file mode 100644 index 0000000..37e58c4 --- /dev/null +++ b/src/zhengshuxitong/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "证书系统", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Auth": "我的场景", + "user_auth_role": "用户角色", + "auth_name": "场景名称", + "auth_type": "场景类型" + }, + "value": { + "user_auth_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "auth_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/zhengshuxitong/userAuth.go b/src/zhengshuxitong/userAuth.go new file mode 100644 index 0000000..b11c4c3 --- /dev/null +++ b/src/zhengshuxitong/userAuth.go @@ -0,0 +1,62 @@ +package zhengshuxitong + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/zhengshuxitong/model" +) + +type userAuth struct { + Table + auth auth +} + +func (s userAuth) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.AUTH_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.AUTH_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_AUTH_ROLE) + s.SelectJoinUser(m) +} +func (s userAuth) List(m *ice.Message, arg ...string) { + s.Tables(m, s.auth).FieldsWithCreatedAT(m, s, + model.AUTH_NAME, model.AUTH_TYPE, model.USER_AUTH_ROLE, + model.COMPANY_UID, model.AUTH_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.AUTH_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userAuth{}) } + +type UserAuthRole int + +const ( + UserAuthVisitor UserAuthRole = iota + UserAuthCreator + UserAuthLeader + UserAuthWorker + UserAuthServer +) + +var UserAuthRoleList = map[UserAuthRole]string{ + UserAuthVisitor: "visitor", + UserAuthCreator: "creator", + UserAuthLeader: "leader", + UserAuthWorker: "worker", + UserAuthServer: "server", +} + +func (s UserAuthRole) String() string { return UserAuthRoleList[s] } \ No newline at end of file diff --git a/src/zijinlian/common.go b/src/zijinlian/common.go new file mode 100644 index 0000000..214bc09 --- /dev/null +++ b/src/zijinlian/common.go @@ -0,0 +1,52 @@ +package zijinlian + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/enterprise/src/guanlixitong" + "shylinux.com/x/education/src/zijinlian/model" +) + +type Table struct { + guanlixitong.Table + list string `name:"list investor_uid uid auto" role:"void"` +} + +func (s Table) Inputs(m *ice.Message, arg ...string) { + switch arg[0] { + case model.USER_INVESTOR_ROLE: + s.InputsListRole(m, UserInvestorRoleList, arg...) + case model.INVESTOR_TYPE: + s.InputsList(m, InvestorTypeList, arg...) + default: + s.Table.Inputs(m, arg...) + } +} +func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { + m.RewriteAppend(func(value, key string, index int) string { + switch key { + case model.USER_INVESTOR_ROLE: + value = UserInvestorRole(kit.Int(value)).String() + case model.INVESTOR_TYPE: + value = InvestorType(kit.Int(value)).String() + } + return value + }) + return s.Table.RewriteAppend(m) +} +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { + role := UserInvestorRole(kit.Int(m.Cmd(userInvestor{}, s.Select, m.OptionSimple(model.INVESTOR_UID, model.USER_UID)).Append(model.ROLE))) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserInvestorCreator.String())...), role.String()) + return m +} +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.INVESTOR_UID), info, kit.Select(m.Option(model.UID), arg, 0)) +} +func (s Table) recordEventWithName(m *ice.Message, info string, arg ...string) { + s.Table.RecordEventWithName(m, m.Option(model.INVESTOR_UID), info) +} + +type Tables struct { Table } + +func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} \ No newline at end of file diff --git a/src/zijinlian/investment.go b/src/zijinlian/investment.go new file mode 100644 index 0000000..95859ab --- /dev/null +++ b/src/zijinlian/investment.go @@ -0,0 +1,25 @@ +package zijinlian + +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/education/src/zijinlian/model" +) + +type investment struct { + Table + investor investor + userInvestor userInvestor + create string `name:"create title* content*" role:"leader"` +} + +func (s investment) Create(m *ice.Message, arg ...string) { + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.INVESTOR_UID))...) + s.recordEventWithName(m, "") +} +func (s investment) List(m *ice.Message, arg ...string) { + s.TablesWithRole(m, arg, s.userInvestor, s.investor, s, model.TITLE, model.CONTENT).Display("") +} + +func init() { ice.TeamCtxCmd(investment{}) } \ No newline at end of file diff --git a/src/zijinlian/investment.js b/src/zijinlian/investment.js new file mode 100644 index 0000000..b7ff53c --- /dev/null +++ b/src/zijinlian/investment.js @@ -0,0 +1,9 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { can.onimport.shareTitle(can, msg) + can.onimport.itemcards(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.title]}, + {view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at), value.user_name]}, + {view: html.OUTPUT, list: [value.content]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/zijinlian/investor.go b/src/zijinlian/investor.go new file mode 100644 index 0000000..b4984d9 --- /dev/null +++ b/src/zijinlian/investor.go @@ -0,0 +1,23 @@ +package zijinlian + +import "shylinux.com/x/ice" + +type investor struct{ Table } + +func init() { ice.TeamCtxCmd(investor{}) } + +type InvestorType int + +const ( + InvestorRD InvestorType = iota + InvestorOP + InvestorHR +) + +var InvestorTypeList = map[InvestorType]string{ + InvestorRD: "RD", + InvestorOP: "OP", + InvestorHR: "HR", +} + +func (s InvestorType) String() string { return InvestorTypeList[s] } \ No newline at end of file diff --git a/src/zijinlian/model/model.go b/src/zijinlian/model/model.go new file mode 100644 index 0000000..980b7e3 --- /dev/null +++ b/src/zijinlian/model/model.go @@ -0,0 +1,43 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + UID = "uid" + NAME = "name" + TYPE = "type" + ROLE = "role" + TITLE = "title" + CONTENT = "content" + USER_UID = "user_uid" + USER_INVESTOR_ROLE = "user_investor_role" + INVESTOR_UID = "investor_uid" + INVESTOR_NAME = "investor_name" + INVESTOR_TYPE = "investor_type" + INVESTMENT_UID = "_uid" + COMPANY_UID = "company_uid" + CITY_UID = "city_uid" +) + +type UserInvestor struct { + db.ModelWithUID + UserUID string `gorm:"type:char(32);index"` + InvestorUID string `gorm:"type:char(32);index"` + Role uint8 `gorm:"default:0"` +} +type Investor struct { + db.ModelWithUID + CompanyUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(64)"` + Type uint8 `gorm:"default:0"` +} +type Investment struct { + db.ModelWithUID + InvestorUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32);index"` + Title string `gorm:"type:varchar(64)"` + Content string +} + + +func init() { db.CmdModels("", &UserInvestor{}, &Investor{}, &Investment{}) } \ No newline at end of file diff --git a/src/zijinlian/portal.go b/src/zijinlian/portal.go new file mode 100644 index 0000000..a4a5ae6 --- /dev/null +++ b/src/zijinlian/portal.go @@ -0,0 +1,15 @@ +package zijinlian + +import ( + "shylinux.com/x/community/src/gonganxitong" + "shylinux.com/x/enterprise/src/guanlixitong" +) + +type Portal struct { + gonganxitong.Portal + placeCreate string `name:"placeCreate city_name* company_name* investor_name*" role:"void"` +} + +func init() { + gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userInvestor{}, investor{}, guanlixitong.Company{})}) +} \ No newline at end of file diff --git a/src/zijinlian/portal.json b/src/zijinlian/portal.json new file mode 100644 index 0000000..3d70e48 --- /dev/null +++ b/src/zijinlian/portal.json @@ -0,0 +1,33 @@ +{ + "portal": "资金链", + "placeCreate": "创建场景", + "placeRemove": "删除场景", + "": "场景应用", + "icons": { + "": "https://img.icons8.com/officel/80/activity-grid.png" + }, + "input": { + "My Investor": "我的场景", + "user_investor_role": "用户角色", + "investor_name": "场景名称", + "investor_type": "场景类型" + }, + "value": { + "user_investor_role": { + "visitor": "访客", + "creator": "创建人", + "leader": "管理人员", + "worker": "工作人员", + "server": "服务人员", + "style": { + "creator": "danger" + } + }, + "investor_type": { + "term": "学期制", + "weekly": "周期性", + "step": "阶段性", + "free": "自由式" + } + } +} \ No newline at end of file diff --git a/src/zijinlian/userInvestor.go b/src/zijinlian/userInvestor.go new file mode 100644 index 0000000..7b551ac --- /dev/null +++ b/src/zijinlian/userInvestor.go @@ -0,0 +1,62 @@ +package zijinlian + +import ( + "shylinux.com/x/ice" + + "shylinux.com/x/education/src/zijinlian/model" +) + +type userInvestor struct { + Table + investor investor +} + +func (s userInvestor) User(m *ice.Message, arg ...string) { + s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE) + if len(arg) == 1 { + s.Select(m, model.INVESTOR_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.INVESTOR_UID, arg[0], model.UID, arg[1]) + } else { + return + } + m.RenameAppend(model.ROLE, model.USER_INVESTOR_ROLE) + s.SelectJoinUser(m) +} +func (s userInvestor) List(m *ice.Message, arg ...string) { + s.Tables(m, s.investor).FieldsWithCreatedAT(m, s, + model.INVESTOR_NAME, model.INVESTOR_TYPE, model.USER_INVESTOR_ROLE, + model.COMPANY_UID, model.INVESTOR_UID, + ) + if len(arg) == 1 { + s.Select(m, model.USER_UID, arg[0]) + } else if len(arg) == 2 { + s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s, model.INVESTOR_UID), arg[1]) + } else { + return + } + s.SelectJoinCompany(m) + s.SelectJoinCity(m) +} + +func init() { ice.TeamCtxCmd(userInvestor{}) } + +type UserInvestorRole int + +const ( + UserInvestorVisitor UserInvestorRole = iota + UserInvestorCreator + UserInvestorLeader + UserInvestorWorker + UserInvestorServer +) + +var UserInvestorRoleList = map[UserInvestorRole]string{ + UserInvestorVisitor: "visitor", + UserInvestorCreator: "creator", + UserInvestorLeader: "leader", + UserInvestorWorker: "worker", + UserInvestorServer: "server", +} + +func (s UserInvestorRole) String() string { return UserInvestorRoleList[s] } \ No newline at end of file diff --git a/usr/local/export/mdb.export/hash.json b/usr/local/export/mdb.export/hash.json index 420f681..148a96c 100644 --- a/usr/local/export/mdb.export/hash.json +++ b/usr/local/export/mdb.export/hash.json @@ -69,6 +69,13 @@ "type": "hash" } }, + "4b1e97b62a44419c00caf65e297abd18": { + "meta": { + "index": "web.team.guanlixitong.portal", + "time": "2024-08-28 10:02:35.167", + "type": "hash" + } + }, "58724bdcc3cae3e26700cb3199e0602c": { "meta": { "index": "web.team.gonganxitong.placeUser", @@ -97,6 +104,13 @@ "type": "hash" } }, + "6d3660df47c3f27241ea96c6274e4aeb": { + "meta": { + "index": "web.team.zaixianketang.portal", + "time": "2024-08-28 10:05:01.033", + "type": "hash" + } + }, "7e64183251edf9e9852903554f37a95c": { "meta": { "index": "web.team.jiaowuxitong.allow", @@ -167,6 +181,13 @@ "type": "hash" } }, + "d1ccc8e267dc41ab546592f93f99c014": { + "meta": { + "index": "web.team.zhengshuxitong.portal", + "time": "2024-08-28 10:02:35.303", + "type": "hash" + } + }, "d8443c1034bfe5917c52126a3306c328": { "meta": { "index": "web.team.gonganxitong.city", @@ -174,6 +195,13 @@ "type": "hash" } }, + "da32a6d81a6a7c21855e5320584fb9c2": { + "meta": { + "index": "web.team.kaoshixitong.portal", + "time": "2024-08-28 10:02:35.295", + "type": "hash" + } + }, "db760ea921c52736461c24f725e78137": { "meta": { "index": "web.team.jiaowuxitong.userClass", @@ -188,6 +216,13 @@ "type": "hash" } }, + "eb7a60fb948cddf6d8b5381d062bb33f": { + "meta": { + "index": "web.team.jiaocaiziliao.portal", + "time": "2024-08-28 10:02:35.207", + "type": "hash" + } + }, "edd3a39c8a4fa35ae7c67117c56b28ae": { "meta": { "index": "web.team.gonganxitong.place",