From 4fe3e79a486df90801cd9a3315655482ef9e7501 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 15 Sep 2024 20:00:11 +0800 Subject: [PATCH] add some --- src/jiaocaiziliao/document.go | 6 ++---- src/jiaocaiziliao/document.js | 2 +- src/jiaowuxitong/common.go | 4 ++-- src/jiaowuxitong/homework.go | 6 ++---- src/jiaowuxitong/homework.js | 2 +- src/jiaowuxitong/model/model.go | 1 + src/jiaowuxitong/school.go | 2 +- src/kaoshixitong/portal.json | 2 +- src/kaoshixitong/question.go | 6 ++---- src/kaoshixitong/question.js | 2 +- src/template/web.code.autogen/demo.go | 11 +++++++---- src/zaixianketang/lesson.go | 6 ++---- src/zaixianketang/lesson.js | 2 +- src/zaixianketang/portal.json | 2 -- 14 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/jiaocaiziliao/document.go b/src/jiaocaiziliao/document.go index 4c12174..0bee0fc 100644 --- a/src/jiaocaiziliao/document.go +++ b/src/jiaocaiziliao/document.go @@ -4,14 +4,12 @@ import "shylinux.com/x/ice" type document struct { Table - fields string `data:"subject,grade,document_type,title,content,icon,link"` + fields string `data:"subject,grade,document_type,title,content,icon,link,user_uid"` create string `name:"create subject* grade* document_type*:select title* content* icon link" role:"teacher"` remove string `name:"remove" role:"teacher"` } -func (s document) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) } -func (s document) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) } -func (s document) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } +func (s document) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } func init() { ice.TeamCtxCmd(document{}) } diff --git a/src/jiaocaiziliao/document.js b/src/jiaocaiziliao/document.js index 51191be..41446bf 100644 --- a/src/jiaocaiziliao/document.js +++ b/src/jiaocaiziliao/document.js @@ -2,7 +2,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(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.uid.slice(0, 6), can.onimport.timeView(can, value)]}, {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: "在线阅读"}]}, diff --git a/src/jiaowuxitong/common.go b/src/jiaowuxitong/common.go index 652ae19..ed0bb0f 100644 --- a/src/jiaowuxitong/common.go +++ b/src/jiaowuxitong/common.go @@ -48,10 +48,10 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { func (s Table) SelectJoinSchool(m *ice.Message) *ice.Message { return s.SelectJoin(m, school{}, model.NAME, model.CITY_UID) } -func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { +func (s Table) CheckRole(m *ice.Message, arg ...string) { role := UserClassRole(s.UserPlaceRole(m)) m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserClassCreator.String())...), role.String()) - return m + m.Option(model.USER_ROLE, kit.Format(role)) } type Tables struct{ Table } diff --git a/src/jiaowuxitong/homework.go b/src/jiaowuxitong/homework.go index 558d000..3f97130 100644 --- a/src/jiaowuxitong/homework.go +++ b/src/jiaowuxitong/homework.go @@ -4,13 +4,11 @@ import "shylinux.com/x/ice" type homework struct { Table - fields string `data:"title,content"` + fields string `data:"title,content,user_uid"` create string `name:"create title* content*" role:"teacher"` remove string `name:"remove" role:"leader"` } -func (s homework) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) } -func (s homework) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) } -func (s homework) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } +func (s homework) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } func init() { ice.TeamCtxCmd(homework{}) } diff --git a/src/jiaowuxitong/homework.js b/src/jiaowuxitong/homework.js index 3be5f6e..d3e4f08 100644 --- a/src/jiaowuxitong/homework.js +++ b/src/jiaowuxitong/homework.js @@ -2,7 +2,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, {view: html.OUTPUT, list: [value.content]}, ] }) }, diff --git a/src/jiaowuxitong/model/model.go b/src/jiaowuxitong/model/model.go index 8b1f7de..98aa674 100644 --- a/src/jiaowuxitong/model/model.go +++ b/src/jiaowuxitong/model/model.go @@ -10,6 +10,7 @@ const ( TITLE = "title" CONTENT = "content" USER_UID = "user_uid" + USER_ROLE = "user_role" USER_CLASS_ROLE = "user_class_role" CLASS_UID = "class_uid" CLASS_NAME = "class_name" diff --git a/src/jiaowuxitong/school.go b/src/jiaowuxitong/school.go index 824e455..2d3a0e3 100644 --- a/src/jiaowuxitong/school.go +++ b/src/jiaowuxitong/school.go @@ -15,7 +15,7 @@ func (s school) List(m *ice.Message, arg ...string) { } func (s school) FindOrCreateByName(m *ice.Message, arg ...string) { if msg := m.Cmd(s, s.Select, model.NAME, arg[3], arg[0], arg[1]); msg.Length() == 0 { - msg := m.Cmd(s, s.Create, model.NAME, arg[3], arg[0], arg[1]) + msg := m.Cmd(s, s.Insert, model.NAME, arg[3], arg[0], arg[1]) arg[2], arg[3] = model.SCHOOL_UID, msg.Result() } else { arg[2], arg[3] = model.SCHOOL_UID, msg.Append(model.UID) diff --git a/src/kaoshixitong/portal.json b/src/kaoshixitong/portal.json index 0bde934..1f35882 100644 --- a/src/kaoshixitong/portal.json +++ b/src/kaoshixitong/portal.json @@ -1,6 +1,6 @@ { "portal": "考试系统", - "question": "场景应用", + "question": "试题", "icons": { "question": "https://img.icons8.com/officel/80/activity-grid.png" }, diff --git a/src/kaoshixitong/question.go b/src/kaoshixitong/question.go index d868163..bb63072 100644 --- a/src/kaoshixitong/question.go +++ b/src/kaoshixitong/question.go @@ -4,13 +4,11 @@ import "shylinux.com/x/ice" type question struct { Table - fields string `data:"title,content"` + fields string `data:"title,content,user_uid"` create string `name:"create title* content*" role:"teacher"` remove string `name:"remove" role:"teacher"` } -func (s question) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) } -func (s question) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) } -func (s question) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } +func (s question) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } func init() { ice.TeamCtxCmd(question{}) } diff --git a/src/kaoshixitong/question.js b/src/kaoshixitong/question.js index 3be5f6e..d3e4f08 100644 --- a/src/kaoshixitong/question.js +++ b/src/kaoshixitong/question.js @@ -2,7 +2,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, {view: html.OUTPUT, list: [value.content]}, ] }) }, diff --git a/src/template/web.code.autogen/demo.go b/src/template/web.code.autogen/demo.go index 599f8c8..e115ec0 100644 --- a/src/template/web.code.autogen/demo.go +++ b/src/template/web.code.autogen/demo.go @@ -2,10 +2,13 @@ package {{.Option "zone"}} import "shylinux.com/x/ice" -type {{.Option "name"}} struct{ Tables } - -func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) { - s.Table.List(m, arg...) +type {{.Option "name"}} struct { + Table + fields string `data:"title,content,user_uid"` + create string `name:"create title* content*" role:"leader"` + remove string `name:"remove" role:"leader"` } +func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } + func init() { ice.TeamCtxCmd({{.Option "name"}}{}) } diff --git a/src/zaixianketang/lesson.go b/src/zaixianketang/lesson.go index 97f7b01..b3a0ec2 100644 --- a/src/zaixianketang/lesson.go +++ b/src/zaixianketang/lesson.go @@ -4,13 +4,11 @@ import "shylinux.com/x/ice" type lesson struct { Table - fields string `data:"title,content"` + fields string `data:"title,content,user_uid"` create string `name:"create title* content*" role:"teacher"` remove string `name:"remove" role:"teacher"` } -func (s lesson) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) } -func (s lesson) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) } -func (s lesson) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } +func (s lesson) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } func init() { ice.TeamCtxCmd(lesson{}) } diff --git a/src/zaixianketang/lesson.js b/src/zaixianketang/lesson.js index 3be5f6e..d3e4f08 100644 --- a/src/zaixianketang/lesson.js +++ b/src/zaixianketang/lesson.js @@ -2,7 +2,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, {view: html.OUTPUT, list: [value.content]}, ] }) }, diff --git a/src/zaixianketang/portal.json b/src/zaixianketang/portal.json index fc7eed6..c933006 100644 --- a/src/zaixianketang/portal.json +++ b/src/zaixianketang/portal.json @@ -1,9 +1,7 @@ { "portal": "在线课堂", - "course": "课程", "lesson": "章节", "icons": { - "course": "https://img.icons8.com/officel/80/activity-grid.png", "lesson": "https://img.icons8.com/officel/80/activity-grid.png" }, "input": {