feat:完善项目

This commit is contained in:
henry
2022-01-14 09:56:55 +08:00
parent cce3717dfa
commit cf68cfbd96
10 changed files with 61 additions and 67 deletions

View File

@ -12,9 +12,10 @@ import (
type Activity struct {
*session.Enterprise
tenantID uint64
}
type ActivityHandle func(session *session.Enterprise) *Activity
type ActivityHandle func(session *session.Enterprise, tenantID uint64) *Activity
type (
// ActivityInfo 活动信息
@ -37,7 +38,7 @@ func (c *Activity) Instance(title string, mode, page, pageSize int) (*controller
var count int64
where := make([]*model2.ModelWhere, 0)
where := []*model2.ModelWhere{model2.NewWhere("a.tenant_id", c.tenantID)}
if title != "" {
where = append(where, model2.NewWhereLike("a.title", title))
@ -82,7 +83,7 @@ func (c *Activity) Join(id uint64) error {
mActivityInstance := model.NewActivityInstance()
isExist, err := model2.FirstField(mActivityInstance.ActivityInstance, []string{"id", "mode", "join_deadline"},
model2.NewWhere("status", model2.NewWhere("id", id)),
model2.NewWhere("id", id), model2.NewWhere("tenant_id", c.tenantID),
model2.NewWhere("status", model2.ActivityInstanceStatusForShow))
if err != nil {
@ -115,7 +116,7 @@ func (c *Activity) Join(id uint64) error {
}
func NewActivity() ActivityHandle {
return func(session *session.Enterprise) *Activity {
return &Activity{session}
return func(session *session.Enterprise, tenantID uint64) *Activity {
return &Activity{Enterprise: session, tenantID: tenantID}
}
}

View File

@ -1,13 +1,15 @@
package controller
package sys
import (
"SciencesServer/app/api/website/model"
model2 "SciencesServer/app/common/model"
)
type About struct{}
type About struct {
tenantID uint64
}
type AboutHandle func() *About
type AboutHandle func(tenantID uint64) *About
type (
// AboutInfo 基本信息
@ -45,6 +47,7 @@ func (c *About) Navigation() ([]*AboutNavigationInfo, error) {
Where: model2.NewWhere("parent_id", 0),
Order: model2.NewOrder("sort", model2.OrderModeToDesc),
}, &model2.ModelWhereOrder{
Where: model2.NewWhere("tenant_id", c.tenantID),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
}); err != nil {
return nil, err
@ -60,7 +63,7 @@ func (c *About) Navigation() ([]*AboutNavigationInfo, error) {
}
func NewAbout() AboutHandle {
return func() *About {
return &About{}
return func(tenantID uint64) *About {
return &About{tenantID: tenantID}
}
}

View File

@ -3,17 +3,15 @@ package sys
import (
"SciencesServer/app/api/website/model"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/session"
"errors"
)
// Agreement 协议信息
type Agreement struct {
*session.Enterprise
tenantID uint64
}
type AgreementHandle func(session *session.Enterprise, tenantID uint64) *Agreement
type AgreementHandle func(tenantID uint64) *Agreement
type (
// AgreementInfo 协议信息
@ -68,10 +66,9 @@ func (c *Agreement) Detail(id uint64) (*AgreementDetailInfo, error) {
}
func NewAgreement() AgreementHandle {
return func(session *session.Enterprise, tenantID uint64) *Agreement {
return func(tenantID uint64) *Agreement {
return &Agreement{
Enterprise: session,
tenantID: tenantID,
tenantID: tenantID,
}
}
}

View File

@ -1,13 +1,15 @@
package controller
package sys
import (
"SciencesServer/app/api/website/model"
model2 "SciencesServer/app/common/model"
)
type Navigation struct{}
type Navigation struct {
tenantID uint64
}
type NavigationHandle func() *Navigation
type NavigationHandle func(tenantID uint64) *Navigation
type NavigationInfo struct {
Title string `json:"title"`
@ -36,7 +38,7 @@ func (c *Navigation) tree(src []*model2.SysNavigation, parentID uint64) []*Navig
// Instance 导航栏信息
func (c *Navigation) Instance() ([]*NavigationInfo, error) {
mSysNavigation := model.NewSysNavigation()
out, err := mSysNavigation.Navigation()
out, err := mSysNavigation.Navigation(model2.NewWhere("tenant_id", c.tenantID))
if err != nil {
return nil, err
@ -45,7 +47,7 @@ func (c *Navigation) Instance() ([]*NavigationInfo, error) {
}
func NewNavigation() NavigationHandle {
return func() *Navigation {
return &Navigation{}
return func(tenantID uint64) *Navigation {
return &Navigation{tenantID: tenantID}
}
}