mirror of
https://shylinux.com/x/education
synced 2025-04-25 01:58:05 +08:00
add some
This commit is contained in:
parent
fd0aec6d3d
commit
10ef85d162
@ -15,48 +15,38 @@ type Table struct {
|
||||
|
||||
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case model.CLASS_TYPE:
|
||||
for k, v := range ClassTypeList {
|
||||
m.Push(arg[0], k).Push(model.NAME, v)
|
||||
}
|
||||
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
|
||||
case model.USER_CLASS_ROLE:
|
||||
for k, v := range UserClassRoleList {
|
||||
if k != UserClassCreator && k != UserClassVisitor {
|
||||
m.Push(arg[0], k).Push(model.NAME, v)
|
||||
}
|
||||
}
|
||||
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
|
||||
s.InputsListRole(m, UserClassRoleList, arg...)
|
||||
case model.CLASS_TYPE:
|
||||
s.InputsList(m, ClassTypeList, 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 {
|
||||
kit.If(key == model.CLASS_TYPE, func() { value = ClassType(kit.Int(value)).String() })
|
||||
kit.If(key == model.USER_CLASS_ROLE, func() { value = UserClassRole(kit.Int(value)).String() })
|
||||
switch key {
|
||||
case model.USER_CLASS_ROLE:
|
||||
value = UserClassRole(kit.Int(value)).String()
|
||||
case model.CLASS_TYPE:
|
||||
value = ClassType(kit.Int(value)).String()
|
||||
}
|
||||
return value
|
||||
})
|
||||
return s.Table.RewriteAppend(m)
|
||||
}
|
||||
func (s Table) checkRole(m *ice.Message, arg ...UserClassRole) bool {
|
||||
kit.If(len(arg) == 0, func() { arg = append(arg, UserClassTeacher) })
|
||||
func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message {
|
||||
role := UserClassRole(kit.Int(m.Cmd(userClass{}, s.Select, m.OptionSimple(model.CLASS_UID, model.USER_UID)).Append(model.ROLE)))
|
||||
for _, v := range append(arg, UserClassCreator) {
|
||||
if role == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return !m.WarnNotRight(true, role.String())
|
||||
}
|
||||
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) *ice.Message {
|
||||
s.Table.RecordEvent(m, m.Option(model.CLASS_UID), info, kit.Select(m.Option(model.UID), arg, 0))
|
||||
m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserClassCreator.String())...), role.String())
|
||||
return m
|
||||
}
|
||||
|
||||
type Tables struct {
|
||||
Table
|
||||
portal string `data:"true"`
|
||||
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) {
|
||||
s.Table.RecordEvent(m, m.Option(model.CLASS_UID), info, kit.Select(m.Option(model.UID), arg, 0))
|
||||
}
|
||||
func (s Table) recordEventWithName(m *ice.Message, info string) {
|
||||
s.Table.RecordEventWithName(m, m.Option(model.CLASS_UID), info)
|
||||
}
|
||||
|
||||
type Tables struct{ Table }
|
||||
|
||||
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
|
||||
|
@ -11,14 +11,12 @@ type homework struct {
|
||||
Table
|
||||
class class
|
||||
userClass userClass
|
||||
create string `name:"create title* content*" role:"void"`
|
||||
create string `name:"create title* content*" role:"teacher"`
|
||||
}
|
||||
|
||||
func (s homework) Create(m *ice.Message, arg ...string) {
|
||||
if s.checkRole(m) {
|
||||
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.CLASS_UID, model.USER_UID))...)
|
||||
s.recordEvent(m, m.Trans("create homework ", "创建家庭作业 ")+m.Option(model.TITLE), m.Result())
|
||||
}
|
||||
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.CLASS_UID, model.USER_UID))...)
|
||||
s.recordEventWithName(m, "")
|
||||
}
|
||||
func (s homework) List(m *ice.Message, arg ...string) {
|
||||
s.TablesWithRole(m, arg, s.userClass, s.class, s, model.TITLE, model.CONTENT).Display("")
|
||||
|
@ -1,10 +1,9 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.title), msg.Option("_share_content", value.content) }
|
||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg)
|
||||
can.onimport.itemcards(can, msg, function(value) { return [
|
||||
{view: html.TITLE, list: [{text: value.title}]},
|
||||
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}, {text: value.user_name}]},
|
||||
{view: html.OUTPUT, list: [{text: value.content}]},
|
||||
{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]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -29,21 +29,21 @@ type UserClass struct {
|
||||
type Class struct {
|
||||
db.ModelWithUID
|
||||
SchoolUID string `gorm:"type:char(32);index"`
|
||||
Grade string `gorm:"type:char(32)"`
|
||||
Name string `gorm:"type:char(64)"`
|
||||
Grade string `gorm:"type:varchar(32)"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Type uint8
|
||||
}
|
||||
type School struct {
|
||||
db.ModelWithUID
|
||||
CityUID string `gorm:"type:char(32);index:idx_city"`
|
||||
Name string `gorm:"type:char(64);index:idx_city"`
|
||||
Name string `gorm:"type:varchar(64);index:idx_city"`
|
||||
Info string
|
||||
}
|
||||
type Homework struct {
|
||||
db.ModelWithUID
|
||||
ClassUID string `gorm:"type:char(32);index"`
|
||||
UserUID string `gorm:"type:char(32)"`
|
||||
Title string `gorm:"type:char(64)"`
|
||||
Title string `gorm:"type:varchar(64)"`
|
||||
Content string
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,6 @@ import "shylinux.com/x/community/src/gonganxitong"
|
||||
|
||||
type Portal struct {
|
||||
gonganxitong.Portal
|
||||
name string `data:"教务系统"`
|
||||
list string `name:"list class_uid index uid auto" role:"void"`
|
||||
placeCreate string `name:"placeCreate city_name* school_name* grade*:select class_name*" role:"void"`
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
chapter "教务系统"
|
||||
field web.code.mysql.client
|
||||
field web.code.mysql.query args `mysql jiaowuxitong`
|
||||
field web.code.mysql.query args `mysql jiaowuxitong`
|
||||
field web.code.db.models
|
@ -23,7 +23,6 @@ func (s userClass) User(m *ice.Message, arg ...string) {
|
||||
}
|
||||
m.RenameAppend(model.ROLE, model.USER_CLASS_ROLE)
|
||||
s.SelectJoinUser(m)
|
||||
s.RewriteAppend(m)
|
||||
}
|
||||
func (s userClass) List(m *ice.Message, arg ...string) {
|
||||
s.Tables(m, s.class, s.school).FieldsWithCreatedAT(m, s,
|
||||
@ -38,7 +37,6 @@ func (s userClass) List(m *ice.Message, arg ...string) {
|
||||
return
|
||||
}
|
||||
s.SelectJoinCity(m)
|
||||
s.RewriteAppend(m)
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(userClass{}) }
|
||||
|
@ -86,6 +86,7 @@
|
||||
"a89a7c09e326295aaa7e7ea3d66fb28a": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.support",
|
||||
"order": "103",
|
||||
"time": "2024-08-20 17:15:51.782"
|
||||
}
|
||||
},
|
||||
@ -100,6 +101,13 @@
|
||||
"time": "2024-08-03 14:36:39.469"
|
||||
}
|
||||
},
|
||||
"be08ca65be90feca325df128a06e440f": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.recent",
|
||||
"order": "101",
|
||||
"time": "2024-08-20 21:47:27.340"
|
||||
}
|
||||
},
|
||||
"c73251765fb5286cea9c8ceefb74530c": {
|
||||
"meta": {
|
||||
"icons": "https://img.icons8.com/officel/80/property-with-timer.png",
|
||||
@ -119,6 +127,13 @@
|
||||
"time": "2024-08-03 14:32:27.153"
|
||||
}
|
||||
},
|
||||
"fd1884bbeb1f1a83f4e12f857bfe5b15": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.message",
|
||||
"order": "100",
|
||||
"time": "2024-08-20 21:47:27.312"
|
||||
}
|
||||
},
|
||||
"fd86aad80a667152781bb188fb1249a2": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
|
@ -42,9 +42,11 @@
|
||||
},
|
||||
"2012c7765aca492cdec6427c9ab24ad9": {
|
||||
"meta": {
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/customer-support.png",
|
||||
"index": "web.team.jiaowuxitong.support",
|
||||
"name": "客服支持",
|
||||
"order": "103",
|
||||
"time": "2024-08-20 21:24:20.298"
|
||||
}
|
||||
},
|
||||
@ -96,8 +98,7 @@
|
||||
"icons": "https://img.icons8.com/officel/80/activity-grid.png",
|
||||
"index": "web.team.jiaowuxitong.service",
|
||||
"name": "服务发现",
|
||||
"order": "100",
|
||||
"role": "creator",
|
||||
"order": "102",
|
||||
"time": "2024-08-06 18:36:54.304"
|
||||
}
|
||||
},
|
||||
@ -121,6 +122,7 @@
|
||||
"icons": "https://img.icons8.com/officel/80/test-partial-passed.png",
|
||||
"index": "web.team.jiaowuxitong.message",
|
||||
"name": "消息待办",
|
||||
"order": "100",
|
||||
"time": "2024-08-20 17:15:51.825"
|
||||
}
|
||||
},
|
||||
@ -130,6 +132,7 @@
|
||||
"icons": "https://img.icons8.com/officel/80/multiple-smartphones.png",
|
||||
"index": "web.team.jiaowuxitong.recent",
|
||||
"name": "最近访问",
|
||||
"order": "101",
|
||||
"time": "2024-08-20 17:15:51.804"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user