forked from ixre/go2o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_service.go
66 lines (57 loc) · 1.35 KB
/
content_service.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
/**
* Copyright 2015 @ z3q.net.
* name : content_service
* author : jarryliu
* date : -- :
* description :
* history :
*/
package dps
import (
"go2o/src/core/domain/interface/content"
"go2o/src/core/domain/interface/partner"
"go2o/src/core/query"
)
type contentService struct {
_contentRep content.IContentRep
_query *query.ContentQuery
}
func NewContentService(rep content.IContentRep, q *query.ContentQuery) *contentService {
return &contentService{
_contentRep: rep,
_query: q,
}
}
// 获取页面
func (this *contentService) GetPage(partnerId, id int) *content.ValuePage {
c := this._contentRep.GetContent(partnerId)
page := c.GetPage(id)
if page != nil {
return page.GetValue()
}
return nil
}
// 根据标识获取页面
func (this *contentService) GetPageByIndent(partnerId int, indent string) *content.ValuePage {
c := this._contentRep.GetContent(partnerId)
page := c.GetPageByStringIndent(indent)
if page != nil {
return page.GetValue()
}
return nil
}
// 保存页面
func (this *contentService) SavePage(partnerId int, v *content.ValuePage) (int, error) {
c := this._contentRep.GetContent(partnerId)
var page content.IPage
if v.PartnerId != partnerId {
return -1, partner.ErrPartnerNotMatch
}
if v.Id > 0 {
page = c.GetPage(v.Id)
page.SetValue(v)
} else {
page = c.CreatePage(v)
}
return page.Save()
}