diff --git a/src/gongyinglian/model/model.go b/src/gongyinglian/model/model.go index b82f103..92a29ca 100644 --- a/src/gongyinglian/model/model.go +++ b/src/gongyinglian/model/model.go @@ -114,38 +114,38 @@ type OrderDetail struct { db.ModelWithUID StoreUID string `gorm:"type:char(32);index"` OrderUID string `gorm:"type:char(32);index"` - ProductUID string `gorm:"type:char(32);index"` + ProductUID string `gorm:"type:char(32)"` Price int `gorm:"default:0"` Count int `gorm:"default:0"` } type Payment struct { db.ModelWithUID OrderUID string `gorm:"type:char(32);index"` - CompanyUID string `gorm:"type:char(32);index"` - OpenID string `gorm:"type:varchar(128);index"` + CompanyUID string `gorm:"type:char(32)"` + OpenID string `gorm:"type:varchar(128)"` Status uint8 } type Express struct { db.ModelWithUID OrderUID string `gorm:"type:char(32);index"` - CompanyUID string `gorm:"type:char(32);index"` - OpenID string `gorm:"type:varchar(128);index"` + CompanyUID string `gorm:"type:char(32)"` + OpenID string `gorm:"type:varchar(128)"` Status uint8 } type Return struct { db.ModelWithUID OrderUID string `gorm:"type:char(32);index"` - ExpressUID string `gorm:"type:char(32);index"` - CompanyUID string `gorm:"type:char(32);index"` - OpenID string `gorm:"type:varchar(128);index"` + ExpressUID string `gorm:"type:char(32)"` + CompanyUID string `gorm:"type:char(32)"` + OpenID string `gorm:"type:varchar(128)"` Status uint8 } type Refund struct { db.ModelWithUID OrderUID string `gorm:"type:char(32);index"` - PaymentUID string `gorm:"type:char(32);index"` - CompanyUID string `gorm:"type:char(32);index"` - OpenID string `gorm:"type:varchar(128);index"` + PaymentUID string `gorm:"type:char(32)"` + CompanyUID string `gorm:"type:char(32)"` + OpenID string `gorm:"type:varchar(128)"` Status uint8 } @@ -172,8 +172,8 @@ type Quality struct { type Expense struct { db.ModelWithUID StoreUID string `gorm:"type:char(32);index"` - FromUserUID string `gorm:"type:char(32);index"` - ToUserUID string `gorm:"type:char(32);index"` + FromUserUID string `gorm:"type:char(32)"` + ToUserUID string `gorm:"type:char(32)"` Name string `gorm:"type:varchar(64)"` Info string Type uint8 @@ -182,8 +182,8 @@ type Expense struct { type Loan struct { db.ModelWithUID StoreUID string `gorm:"type:char(32);index"` - FromUserUID string `gorm:"type:char(32);index"` - ToUserUID string `gorm:"type:char(32);index"` + FromUserUID string `gorm:"type:char(32)"` + ToUserUID string `gorm:"type:char(32)"` Name string `gorm:"type:varchar(64)"` Info string Type uint8 diff --git a/src/gongyinglian/portal.shy b/src/gongyinglian/portal.shy index 57609a0..b4131fb 100644 --- a/src/gongyinglian/portal.shy +++ b/src/gongyinglian/portal.shy @@ -1,6 +1,7 @@ chapter "供应链" field web.code.mysql.client field web.code.mysql.query args `mysql gongyinglian` +field web.code.db.models order ` userStore.go diff --git a/src/gongyinglian/product.go b/src/gongyinglian/product.go index 5a6f074..24fddb3 100644 --- a/src/gongyinglian/product.go +++ b/src/gongyinglian/product.go @@ -27,13 +27,10 @@ func (s Product) Create(m *ice.Message, arg ...string) { s.TableView.Create(m, arg...) } func (s Product) List(m *ice.Message, arg ...string) { - m.Info("what %v", 123) if m.Option(model.PRODUCT_TYPE) != kit.Format(ProductGoods) && !s.checkListRole(m, arg...) { return } - m.Info("what %v", 123) if len(arg) == 0 { - m.Info("what %v", 123) args := m.OptionSimple(model.STORE_UID) kit.If(m.Option(model.PRODUCT_TYPE), func(p string) { args = append(args, model.TYPE, p) }) s.Select(m, args...) diff --git a/src/gongyinglian/refund.js b/src/gongyinglian/refund.js index 790d5b3..55d2e29 100644 --- a/src/gongyinglian/refund.js +++ b/src/gongyinglian/refund.js @@ -1,6 +1,5 @@ Volcanos(chat.ONIMPORT, { - _init: function(can, msg) { - can.onimport.shareTitle(can, msg, "uid", "amount") + _init: function(can, msg) { can.onimport.shareTitle(can, msg, "uid", "amount") can.onimport.itemcards(can, msg, function(value) { return [ {view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "refund_status", mdb.STATUS)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at)]}, diff --git a/src/guanlixitong/common.go b/src/guanlixitong/common.go index d82b003..1add638 100644 --- a/src/guanlixitong/common.go +++ b/src/guanlixitong/common.go @@ -28,8 +28,12 @@ func (s Table) Inputs(m *ice.Message, arg ...string) { } func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { m.RewriteAppend(func(value, key string, index int) string { - kit.If(key == model.GROUP_TYPE, func() { value = GroupType(kit.Int(value)).String() }) - kit.If(key == model.USER_GROUP_ROLE, func() { value = UserGroupRole(kit.Int(value)).String() }) + switch key { + case model.USER_GROUP_ROLE: + value = UserGroupRole(kit.Int(value)).String() + case model.GROUP_TYPE: + value = GroupType(kit.Int(value)).String() + } return value }) return s.Table.RewriteAppend(m) @@ -37,20 +41,17 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message { func (s Table) SelectJoinCompany(m *ice.Message) *ice.Message { return s.SelectJoin(m, company{}, model.NAME, model.CITY_UID) } -func (s Table) checkRole(m *ice.Message, arg ...UserGroupRole) bool { - kit.If(len(arg) == 0, func() { arg = append(arg, UserGroupLeader) }) +func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message { role := UserGroupRole(kit.Int(m.Cmd(userGroup{}, s.Select, m.OptionSimple(model.GROUP_UID, model.USER_UID)).Append(model.ROLE))) - for _, v := range append(arg, UserGroupCreator) { - 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.GROUP_UID), info, kit.Select(m.Option(model.UID), arg, 0)) + m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserGroupCreator.String())...), role.String()) return m } +func (s Table) recordEvent(m *ice.Message, info string, arg ...string) { + s.Table.RecordEvent(m, m.Option(model.GROUP_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.GROUP_UID), info) +} type Tables struct{ Table } diff --git a/src/guanlixitong/model/model.go b/src/guanlixitong/model/model.go index 3a9eb65..b57d336 100644 --- a/src/guanlixitong/model/model.go +++ b/src/guanlixitong/model/model.go @@ -28,20 +28,20 @@ type UserGroup struct { type Group struct { db.ModelWithUID CompanyUID string `gorm:"type:char(32);index"` - Name string `gorm:"type:char(64)"` + Name string `gorm:"type:varchar(64)"` Type uint8 } type Company 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 Target struct { db.ModelWithUID GroupUID 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 } diff --git a/src/guanlixitong/portal.go b/src/guanlixitong/portal.go index 8be1114..8ba926a 100644 --- a/src/guanlixitong/portal.go +++ b/src/guanlixitong/portal.go @@ -4,8 +4,6 @@ import "shylinux.com/x/community/src/gonganxitong" type Portal struct { gonganxitong.Portal - name string `data:"管理系统"` - list string `name:"list group_uid index uid auto" role:"void"` placeCreate string `name:"placeCreate city_name* company_name* group_name*" role:"void"` } diff --git a/src/guanlixitong/portal.shy b/src/guanlixitong/portal.shy index df955be..ec30070 100644 --- a/src/guanlixitong/portal.shy +++ b/src/guanlixitong/portal.shy @@ -1,3 +1,4 @@ chapter "管理系统" field web.code.mysql.client -field web.code.mysql.query args `mysql guanlixitong` \ No newline at end of file +field web.code.mysql.query args `mysql guanlixitong` +field web.code.db.models \ No newline at end of file diff --git a/src/guanlixitong/target.go b/src/guanlixitong/target.go index 5643b61..6068c0e 100644 --- a/src/guanlixitong/target.go +++ b/src/guanlixitong/target.go @@ -11,14 +11,12 @@ type target struct { Table group group userGroup userGroup - create string `name:"create title* content*" role:"void"` + create string `name:"create title* content*" role:"leader"` } func (s target) Create(m *ice.Message, arg ...string) { - if s.checkRole(m) { - s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.GROUP_UID, model.USER_UID))...) - s.recordEvent(m, m.Trans("create target ", "创建团队目标 ")+m.Option(model.TITLE), m.Result()) - } + s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.GROUP_UID, model.USER_UID))...) + s.recordEventWithName(m, "") } func (s target) List(m *ice.Message, arg ...string) { s.TablesWithRole(m, arg, s.userGroup, s.group, s, model.TITLE, model.CONTENT).Display("") diff --git a/src/guanlixitong/target.js b/src/guanlixitong/target.js index 75968da..f010ae4 100644 --- a/src/guanlixitong/target.js +++ b/src/guanlixitong/target.js @@ -1,6 +1,5 @@ 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}]}, diff --git a/src/guanlixitong/userGroup.go b/src/guanlixitong/userGroup.go index 3e7ab79..914d8a4 100644 --- a/src/guanlixitong/userGroup.go +++ b/src/guanlixitong/userGroup.go @@ -23,7 +23,6 @@ func (s userGroup) User(m *ice.Message, arg ...string) { } m.RenameAppend(model.ROLE, model.USER_GROUP_ROLE) s.SelectJoinUser(m) - s.RewriteAppend(m) } func (s userGroup) List(m *ice.Message, arg ...string) { s.Tables(m, s.group, s.company).FieldsWithCreatedAT(m, s, @@ -38,7 +37,6 @@ func (s userGroup) List(m *ice.Message, arg ...string) { return } s.SelectJoinCity(m) - s.RewriteAppend(m) } func init() { ice.TeamCtxCmd(userGroup{}) }