-
Notifications
You must be signed in to change notification settings - Fork 1
/
render_data.go
94 lines (75 loc) · 2.84 KB
/
render_data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package middleware
import (
"html/template"
"github.com/admpub/nging/v5/application/cmd/bootconfig"
"github.com/admpub/nging/v5/application/library/common"
"github.com/admpub/nging/v5/application/library/license"
"github.com/admpub/webx/application/dbschema"
"github.com/admpub/webx/application/library/logic/articlelogic"
"github.com/admpub/webx/application/model/official"
modelCustomer "github.com/admpub/webx/application/model/official/customer"
"github.com/webx-top/echo"
)
var DefaultRenderDataWrapper = func(ctx echo.Context, data interface{}) interface{} {
return NewRenderData(ctx, data)
}
func NewRenderData(ctx echo.Context, data interface{}) *RenderData {
return &RenderData{
ctx: ctx,
RenderData: echo.NewRenderData(ctx, data),
}
}
type RenderData struct {
ctx echo.Context
*echo.RenderData
}
func (r *RenderData) Customer() *dbschema.OfficialCustomer {
return Customer(r.ctx)
}
func (r *RenderData) CustomerDetail() *modelCustomer.CustomerAndGroup {
return CustomerDetail(r.ctx)
}
func (r *RenderData) Friendlink(limit int, categoryIds ...uint) []*dbschema.OfficialCommonFriendlink {
m := official.NewFriendlink(r.ctx)
list, _ := m.ListShowAndRecord(limit, categoryIds...)
return list
}
func (r *RenderData) FrontendNav(parentIDs ...uint) []*official.NavigateExt {
return NavigateList(r.ctx, dbschema.NewOfficialCommonNavigate(r.ctx), `default`, parentIDs...)
}
func (r *RenderData) CustomerNav(parentIDs ...uint) []*official.NavigateExt {
return NavigateList(r.ctx, dbschema.NewOfficialCommonNavigate(r.ctx), `userCenter`, parentIDs...)
}
func (r *RenderData) SQLQuery() *common.SQLQuery {
return common.NewSQLQuery(r.ctx)
}
func (r *RenderData) SQLQueryLimit(offset int, limit int, linkID ...int) *common.SQLQuery {
return common.NewSQLQueryLimit(r.ctx, offset, limit, linkID...)
}
func (r *RenderData) CaptchaForm(tmpl string, args ...interface{}) template.HTML {
return common.CaptchaForm(r.ctx, tmpl, args...)
}
func (r *RenderData) CaptchaFormWithType(typ string, tmpl string, args ...interface{}) template.HTML {
return common.CaptchaFormWithType(r.ctx, typ, tmpl, args...)
}
func (r *RenderData) TagList(group ...string) []*dbschema.OfficialCommonTags {
list, _ := articlelogic.GetTags(r.ctx, group...)
return list
}
func (r *RenderData) CategoryList(limit int, ctype ...string) []*dbschema.OfficialCommonCategory {
categories, _ := articlelogic.GetCategories(r.ctx, limit, ctype...)
return categories
}
func (r *RenderData) SubCategoryList(parentId int, limit int, ctype ...string) []*dbschema.OfficialCommonCategory {
categories, _ := articlelogic.GetSubCategories(r.ctx, parentId, limit, ctype...)
return categories
}
func (r *RenderData) SoftwareURL() string {
if license.SkipLicenseCheck {
return ``
}
return license.ProductURL()
}
func (r *RenderData) SoftwareName() string {
return bootconfig.SoftwareName
}