Browse Source

Merge branch 'master' of http://git.shengws.com/zhangbj/scrm-go

zhengchengwu 5 years ago
parent
commit
6de54d2723

+ 49 - 1
controllers/article/article_controller.go View File

@@ -6,12 +6,14 @@ import (
6 6
 	"SCRM/controllers"
7 7
 	"SCRM/service/article_service"
8 8
 	"SCRM/enums"
9
+	"SCRM/models"
9 10
 )
10 11
 
11 12
 func ArticleRouters() {
12 13
 
13 14
 	beego.Router("/api/acticle/createacticle",&ArticleManage{},"Get:CreateArticle")
14 15
 	beego.Router("/api/acticle/getArticleType",&ArticleManage{},"Get:GetArticleType")
16
+	beego.Router("/api/acticle/getAllArticles",&ArticleManage{},"Get:GetAllArticles")
15 17
 }
16 18
 
17 19
 type ArticleManage struct {
@@ -20,8 +22,25 @@ type ArticleManage struct {
20 22
 }
21 23
 
22 24
 func (this *ArticleManage) CreateArticle(){
25
+	adminUserInfo := this.GetAdminUserInfo()
26
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
23 27
 	actname := this.GetString("act_name")
24
-	fmt.Println("姓名:",actname)
28
+	actcontent := this.GetString("act_content")
29
+	orglogo := this.GetString("org_logo")
30
+	acttype, _ := this.GetInt64("act_type")
31
+	fmt.Println("姓名:",actname,"文章内容",actcontent,"图片",orglogo,"文章类型",acttype,userOrgID)
32
+	articles := models.Articles{
33
+				Title: actname,
34
+				Content: actcontent,
35
+				Imgs: orglogo,
36
+				ClassId: acttype,
37
+				UserOrgId:userOrgID,
38
+		}
39
+		err := article_service.AddAritcle(articles)
40
+		if err !=nil{
41
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "插入文章失败")
42
+			return
43
+		}
25 44
 }
26 45
 
27 46
 func (this *ArticleManage) GetArticleType(){
@@ -39,3 +58,32 @@ func (this *ArticleManage) GetArticleType(){
39 58
 	return
40 59
 }
41 60
 
61
+func (this *ArticleManage) GetAllArticles()  {
62
+	page, _ := this.GetInt("page", 1)
63
+	limit, _ := this.GetInt64("limit", 10)
64
+	searchKey := this.GetString("search", "")
65
+	classId,_ := this.GetInt64("classid",0)
66
+    fmt.Println("页面",page,"限制",limit,"关键字",searchKey,"分类号",classId)
67
+
68
+	if page <= 0 {
69
+		page = 1
70
+	}
71
+	if limit <= 0 {
72
+		limit = 10
73
+	}
74
+	adminUserInfo := this.GetAdminUserInfo()
75
+	userOrgID := adminUserInfo.CurrentOrgId
76
+
77
+	articles, total, err := article_service.FindAllArticle(userOrgID, page,10, searchKey, classId)
78
+	fmt.Println("文章内容是是么",articles)
79
+	if err !=nil{
80
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取文章列表失败")
81
+		return
82
+	}
83
+	this.ServeSuccessJSON(map[string]interface{}{
84
+		"articles":articles,
85
+		"total":total,
86
+	})
87
+	return
88
+}
89
+

+ 2 - 1
controllers/base_view_controller.go View File

@@ -1,9 +1,10 @@
1 1
 package controllers
2
-
3 2
 type BaseViewController struct {
4 3
 	BaseController
5 4
 }
6 5
 
6
+
7
+
7 8
 // 设置模板
8 9
 // 第一个参数模板,第二个参数为layout
9 10
 func (this *BaseViewController) SetTpl(template ...string) {

+ 93 - 0
controllers/marketing_tool/activity_controller.go View File

@@ -2,6 +2,10 @@ package marketing_tool
2 2
 
3 3
 import (
4 4
 	"SCRM/controllers"
5
+	"SCRM/enums"
6
+	"SCRM/models"
7
+	"SCRM/service/marketing_tool_service"
8
+	"time"
5 9
 
6 10
 	"github.com/astaxie/beego"
7 11
 )
@@ -19,5 +23,94 @@ type ActivityAPIController struct {
19 23
 // @param keyword?:string
20 24
 // @param status?:int 1.已发布 2.待发布 3.未通过 4.已结束 其他取全部
21 25
 func (this *ActivityAPIController) Activities() {
26
+	page, _ := this.GetInt("page")
27
+	keyword := this.GetString("keyword")
28
+	status, _ := this.GetInt("status")
29
+	if page <= 0 {
30
+		page = 1
31
+	}
32
+	if status < 1 || status > 4 {
33
+		status = 0
34
+	}
22 35
 
36
+	adminUserInfo := this.GetAdminUserInfo()
37
+	var activities []*models.Activity
38
+	var totalCount int64
39
+	var getActivityErr error
40
+	if status == 1 {
41
+		activities, totalCount, getActivityErr = marketing_tool_service.GetActivitiesWithStatus(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, keyword, 1, page, 10)
42
+	} else if status == 2 {
43
+		activities, totalCount, getActivityErr = marketing_tool_service.GetActivitiesWithStatus(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, keyword, 4, page, 10)
44
+	} else if status == 3 {
45
+		activities, totalCount, getActivityErr = marketing_tool_service.GetActivitiesWithStatus(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, keyword, 3, page, 10)
46
+	} else if status == 4 {
47
+		activities, totalCount, getActivityErr = marketing_tool_service.GetDidEndedActivities(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, keyword, page, 10)
48
+	} else {
49
+		activities, totalCount, getActivityErr = marketing_tool_service.GetValidActivities(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, keyword, page, 10)
50
+	}
51
+
52
+	if getActivityErr != nil {
53
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
54
+		return
55
+	}
56
+
57
+	activityJSONList := make([]map[string]interface{}, 0, len(activities))
58
+	for _, activity := range activities {
59
+		var json map[string]interface{}
60
+		// 活动状态 1:已发布 2:待审核 3:未通过 4:草稿 9:已删除
61
+		if activity.Status == 1 { // 已发布/已结束
62
+			json = this._convertToPublishedActivityViewJSON(activity)
63
+		} else if activity.Status == 3 { // 未通过
64
+			json = this._convertToUnapprovedActivityViewJSON(activity)
65
+		} else if activity.Status == 4 { // 草稿
66
+			json = this._convertToActivityDraftsViewJSON(activity)
67
+		}
68
+		activityJSONList = append(activityJSONList, json)
69
+	}
70
+
71
+	this.ServeSuccessJSON(map[string]interface{}{
72
+		"activities": activityJSONList,
73
+		"total":      totalCount,
74
+	})
75
+}
76
+
77
+func (this *ActivityAPIController) _convertToPublishedActivityViewJSON(activity *models.Activity) map[string]interface{} {
78
+	json := make(map[string]interface{})
79
+	now := time.Now().Unix()
80
+	if activity.StartTime < now {
81
+		json["status"] = 4
82
+	} else {
83
+		json["status"] = 1
84
+	}
85
+	json["id"] = activity.Id
86
+	json["poster_photo"] = activity.PosterPhoto
87
+	json["title"] = activity.Title
88
+	json["is_recommend"] = activity.IsRecommend
89
+	json["read_num"] = activity.ReadNum
90
+	json["comment_num"] = activity.CommentNum
91
+	json["star_num"] = activity.StarNum
92
+	json["join_num"] = activity.JoinNum
93
+	json["limit_num"] = activity.LimitNum
94
+	json["start_time"] = activity.StartTime
95
+	return json
96
+}
97
+
98
+func (this *ActivityAPIController) _convertToActivityDraftsViewJSON(activity *models.Activity) map[string]interface{} {
99
+	json := make(map[string]interface{})
100
+	json["status"] = 2
101
+	json["id"] = activity.Id
102
+	json["poster_photo"] = activity.PosterPhoto
103
+	json["title"] = activity.Title
104
+	return json
105
+}
106
+
107
+func (this *ActivityAPIController) _convertToUnapprovedActivityViewJSON(activity *models.Activity) map[string]interface{} {
108
+	json := make(map[string]interface{})
109
+	json["status"] = 3
110
+	json["id"] = activity.Id
111
+	json["poster_photo"] = activity.PosterPhoto
112
+	json["title"] = activity.Title
113
+	json["reason"] = activity.Reason
114
+	json["start_time"] = activity.StartTime
115
+	return json
23 116
 }

+ 2 - 2
controllers/members/members_controller.go View File

@@ -8,7 +8,7 @@ import (
8 8
 	"SCRM/utils"
9 9
 	"reflect"
10 10
 	"time"
11
-
11
+    "fmt"
12 12
 	"encoding/json"
13 13
 
14 14
 	"github.com/astaxie/beego"
@@ -35,7 +35,7 @@ func (c *MembersAPIController) GetMembers() {
35 35
 	source, _ := c.GetInt64("source", 0)
36 36
 	tag, _ := c.GetInt64("tag", 0)
37 37
 	init, _ := c.GetInt64("init", 0)
38
-
38
+	fmt.Println("level",level,"source",source)
39 39
 	if page <= 0 {
40 40
 		page = 1
41 41
 	}

+ 27 - 30
models/activity_models.go View File

@@ -2,36 +2,33 @@ package models
2 2
 
3 3
 // 表
4 4
 type Activity struct {
5
-	Id       int    `gorm:"PRIMARY_KEY;AUTO_INCREMENT"` // 活动 ID
6
-	Title    string // 活动标题
7
-	Subtitle string // 活动副标题
8
-	CityId   int    `gorm:"column:city_id"` // 活动地点 ID
9
-	Address  string // 活动详细地址
10
-	Lng      string `gorm:"column:longitude"` // 活动位置的经度
11
-	Lat      string `gorm:"column:latitude"`  // 活动位置的纬度
12
-	// SignUpStart int64  `gorm:"column:sign_up_start"` // 报名开始时间戳
13
-	SignUpDeadline int64  `gorm:"column:sign_up_deadline"` // 报名截止时间戳
14
-	SignUpNotice   string `gorm:"column:sign_up_notice"`   // 报名须知
15
-	StartTime      int64  `gorm:"column:start_time"`       // 活动开始时间戳
16
-	// EndTime          int64  `gorm:"column:end_time"`            // 活动结束时间戳
17
-	PosterPhoto      string `gorm:"column:poster_photo"`        // 活动海报
18
-	PosterPhotoThumb string `gorm:"column:poster_photo_thumb"`  // 活动海报缩略图
19
-	LimitNum         int    `gorm:"column:limit_num;default:0"` // 限制报名人数,0表示无限制
20
-	JoinNum          int    `gorm:"column:join_num"`            // 已报名人数
21
-	PhoneNumber      string `gorm:"column:phone_number"`        // 联系方式
22
-	Type             int8   // 活动形式
23
-	// Content		string	// 活动内容
24
-	IsInsurance int8   `gorm:"column:is_insurance;default:0"` // 是否提供保险:报名不需要保险0:否;报名需要保险1:是;2不需要报名
25
-	Status      int    // 活动状态 1:已发布 2:待审核 3:未通过 4:草稿 9:已删除
26
-	Reason      string // 审核原因
27
-	IsRecommend int8   `gorm:"column:is_recommend;default:0"` // 0:未推荐;1:已推荐
28
-	CreateTime  int64  `gorm:"column:ctime"`                  // 创建时间
29
-	ModifyTime  int64  `gorm:"column:mtime"`                  // 修改时间
30
-	UserOrgId   int    `gorm:"column:user_org_id"`            // 所属发布机构 ID
31
-	UserAppId   int    `gorm:"column:user_app_id"`            // 所属发布应用 ID
32
-	CommentNum  int    `gorm:"column:comment_num;default:0"`  // 评论数
33
-	StarNum     int    `gorm:"column:star_num;default:0"`     // 点赞书
34
-	ReadNum     int    `gorm:"column:read_num;default:0"`     // 阅读数
5
+	Id               int    `gorm:"column:id" json:"id"`                                 // 活动 ID
6
+	Title            string `json:"title"`                                               // 活动标题
7
+	Subtitle         string `json:"subtitle"`                                            // 活动副标题
8
+	CityId           int    `gorm:"column:city_id" json:"city_id"`                       // 活动地点 ID
9
+	Address          string `json:"address"`                                             // 活动详细地址
10
+	Lng              string `gorm:"column:longitude" json:"lng"`                         // 活动位置的经度
11
+	Lat              string `gorm:"column:latitude" json:"lat"`                          // 活动位置的纬度
12
+	SignUpDeadline   int64  `gorm:"column:sign_up_deadline" json:"sign_up_deadline"`     // 报名截止时间戳
13
+	SignUpNotice     string `gorm:"column:sign_up_notice" json:"sign_up_notice"`         // 报名须知
14
+	StartTime        int64  `gorm:"column:start_time" json:"start_time"`                 // 活动开始时间戳
15
+	PosterPhoto      string `gorm:"column:poster_photo" json:"poster_photo"`             // 活动海报
16
+	PosterPhotoThumb string `gorm:"column:poster_photo_thumb" json:"poster_photo_thumb"` // 活动海报缩略图
17
+	LimitNum         int    `gorm:"column:limit_num;" json:"limit_num"`                  // 限制报名人数,0表示无限制
18
+	JoinNum          int    `gorm:"column:join_num" json:"join_num"`                     // 已报名人数
19
+	PhoneNumber      string `gorm:"column:phone_number" json:"phone_number"`             // 联系方式
20
+	Type             int8   `json:"type"`                                                // 活动形式
21
+	IsInsurance      int8   `gorm:"column:is_insurance;" json:"is_insurance"`            // 是否提供保险:报名不需要保险0:否;报名需要保险1:是;2不需要报名
22
+	Status           int    `json:"status"`                                              // 活动状态 1:已发布 2:待审核 3:未通过 4:草稿 9:已删除
23
+	Reason           string `json:"reason"`                                              // 审核原因
24
+	IsRecommend      int8   `gorm:"column:is_recommend;" json:"is_recommend"`            // 0:未推荐;1:已推荐
25
+	CreateTime       int64  `gorm:"column:ctime" json:"-"`                               // 创建时间
26
+	ModifyTime       int64  `gorm:"column:mtime" json:"-"`                               // 修改时间
27
+	UserOrgId        int    `gorm:"column:user_org_id" json:"-"`                         // 所属发布机构 ID
28
+	UserAppId        int    `gorm:"column:user_app_id" json:"-"`                         // 所属发布应用 ID
29
+	CommentNum       int    `gorm:"column:comment_num;" json:"comment_num"`              // 评论数
30
+	StarNum          int    `gorm:"column:star_num" json:"star_num"`                     // 点赞书
31
+	ReadNum          int    `gorm:"column:read_num;" json:"read_num"`                    // 阅读数
35 32
 }
36 33
 
37 34
 func (Activity) TableName() string {

+ 69 - 0
models/article_models.go View File

@@ -18,3 +18,72 @@ type ArticleCategory struct{
18 18
 func (ArticleCategory) TableName() string  {
19 19
 	return "sgj_patient_articles_menu"
20 20
 }
21
+
22
+type Articles struct {
23
+	ID            int64     `gorm:"column:id" json:"id"`
24
+	Title         string    `gorm:"column:title" json:"title"`
25
+	Summary       string    `gorm:"column:summary" json:"summary"`
26
+	Content       string    `gorm:"column:content" json:"content"`
27
+	Type          int       `gorm:"column:type" json:"type"`
28
+	Num           int       `gorm:"column:num" json:"num"`
29
+	Mtime         int64     `gorm:"column:mtime" json:"mtime"`
30
+	Ctime         int64     `gorm:"column:ctime" json:"ctime"`
31
+	ClassId       int64     `gorm:"column:class_id" json:"class_id"`
32
+	Author        string    `gorm:"column:author" json:"author"`
33
+	Status        int       `gorm:"column:status" json:"status"`
34
+	Reason        string    `gorm:"column:reason" json:"reason"`
35
+	StarNum       int       `gorm:"column:star_num" json:"star_num"`
36
+	CommentNum    int       `gorm:"column:comment_num" json:"comment_num"`
37
+	UserOrgId     int64     `gorm:"column:user_org_id" json:"user_org_id"`
38
+	ArticleStatus int64     `gorm:"column:article_status" json:"article_status"`
39
+	Imgs          string    `gorm:"column:imgs" json:"imgs"`
40
+	VideoUrl      string    `gorm:"column:video_url" json:"video_url"`
41
+	Cover         string    `gorm:"-" json:"cover"`
42
+	PublicTime    string    `gorm:"-" json:"publicTime"`
43
+	Comments      []Comment `gorm:"ForeignKey:ArticleId"`
44
+	ArticleId	  int64		 `gorm:"-"`
45
+}
46
+
47
+func (Articles) TableName() string {
48
+	return "sgj_patient_articles"
49
+}
50
+
51
+type Comment struct {
52
+	ID                int64  `gorm:"column:id" json:"id"`
53
+	ArticleId         int64  `gorm:"column:article_id" json:"article_id"`
54
+	CommentUserId     int64  `gorm:"column:comment_user_id" json:"comment_user_id"`
55
+	ParentId          int64  `gorm:"column:parent_id" json:"parent_id"`
56
+	Content           string `gorm:"column:content" json:"content"`
57
+	Ctime             int64  `gorm:"column:ctime" json:"ctime"`
58
+	Mtime             int64  `gorm:"column:mtime" json:"mtime"`
59
+	Status            int64  `gorm:"column:status" json:"status"`
60
+	StarNum           int64  `gorm:"column:star_num" json:"star_num"`
61
+	CommentNum        int64  `gorm:"column:comment_num" json:"comment_num"`
62
+	CommentId         int64  `gorm:"column:comment_id" json:"comment_id"`
63
+	CommentUserName   string `gorm:"column:comment_user_name" json:"comment_user_name"`
64
+	CommentUserAvater string `gorm:"column:comment_user_avater" json:"comment_user_avater"`
65
+	CommentTime       string `gorm:"-" json:"commentTime"`
66
+	Article           Articles
67
+	Parent            Parents
68
+}
69
+
70
+type Parents struct {
71
+	ID                int64  `gorm:"-" json:"id"`
72
+	ArticleId         int64  `gorm:"-" json:"article_id"`
73
+	CommentUserId     int64  `gorm:"-" json:"comment_user_id"`
74
+	ParentId          int64  `gorm:"-" json:"parent_id"`
75
+	Content           string `gorm:"-" json:"content"`
76
+	Ctime             int64  `gorm:"-" json:"ctime"`
77
+	Mtime             int64  `gorm:"-" json:"mtime"`
78
+	Status            int64  `gorm:"-" json:"status"`
79
+	StarNum           int64  `gorm:"-" json:"star_num"`
80
+	CommentNum        int64  `gorm:"-" json:"comment_num"`
81
+	CommentId         int64  `gorm:"-" json:"comment_id"`
82
+	CommentUserName   string `gorm:"-" json:"comment_user_name"`
83
+	CommentUserAvater string `gorm:"-" json:"comment_user_avater"`
84
+	CommentTime       string `gorm:"-" json:"commentTime"`
85
+}
86
+
87
+func (Comment) TableName() string {
88
+	return "sgj_patient_articles_comment"
89
+}

+ 28 - 1
service/article_service/article_category_service.go View File

@@ -5,8 +5,35 @@ import (
5 5
 	"SCRM/service"
6 6
 )
7 7
 
8
-func FindArticleCategoryType(userOrgId int64)(*[]models.ArticleCategory,error){
8
+func FindArticleCategoryType (userOrgId int64)(*[]models.ArticleCategory,error){
9 9
    cartegory :=	&[]models.ArticleCategory{}
10 10
 	err := service.PatientReadDB().Where("status = ? AND user_org_id = ? ", 1, userOrgId).Find(cartegory).Error
11 11
 	return  cartegory,err
12 12
 }
13
+
14
+func AddAritcle(articles models.Articles) error {
15
+	err := service.PatientWriteDB().Create(&articles).Error
16
+	return  err
17
+}
18
+
19
+func FindAllArticle(orgID int64, page int, count int, searchKey string, classId int64) (articles *[]models.Articles,total int64, err error) {
20
+
21
+	db := service.PatientReadDB().Table("sgj_patient_articles as a ").Where("a.status=1")
22
+	if(orgID>0){
23
+		db.Where("a.user_org_id = ?" ,orgID)
24
+	}
25
+
26
+	if(classId>0){
27
+	  db = db.Joins("JOIN sgj_patient_articles_menu as s ON s.id = a.class_id AND s.status=1 AND user_org_id = ?")
28
+	}
29
+
30
+	if len(searchKey) > 0 {
31
+		searchKey = "%" + searchKey + "%"
32
+		db = db.Where("a.title LIKE ?", searchKey)
33
+	}
34
+
35
+	//err = db.Select("a.id,a.title,a.summary,a.content,a.type,a.num,a.mtime,a.real_read_num,a.ctime,a.class_id,a.author,a.status,a.reason" +
36
+	//	"a.star_num,a.comment_num,a.user_org_id,a.article_status,a.imgs,a.video_url,a.source,a.category_id,a.ttid,a.ttype,a.toid").Count(&total).Find(&articles).Error
37
+
38
+		return
39
+}

+ 90 - 0
service/marketing_tool_service/activity_service.go View File

@@ -0,0 +1,90 @@
1
+package marketing_tool_service
2
+
3
+import (
4
+	"SCRM/models"
5
+	"SCRM/service"
6
+	"time"
7
+)
8
+
9
+func GetValidActivities(orgID int64, appID int64, keyWord string, page int, count int) ([]*models.Activity, int64, error) {
10
+	if count <= 0 {
11
+		return []*models.Activity{}, 0, nil
12
+	}
13
+	if page < 1 {
14
+		page = 1
15
+	}
16
+
17
+	var activities []*models.Activity
18
+	var totalCount int64
19
+	db := service.PatientReadDB().Model(&models.Activity{}).Where("user_org_id = ? AND user_app_id = ? AND status <> 9", orgID, appID)
20
+	if len(keyWord) > 0 {
21
+		likeParam := "%" + keyWord + "%"
22
+		db = db.Where("title LIKE ?", likeParam)
23
+	}
24
+
25
+	err := db.
26
+		Count(&totalCount).
27
+		Order("ctime desc").Limit(count).Offset((page - 1) * count).Find(&activities).
28
+		Error
29
+
30
+	if err == nil {
31
+		return activities, totalCount, nil
32
+	} else {
33
+		return nil, 0, err
34
+	}
35
+}
36
+
37
+func GetActivitiesWithStatus(orgID int64, appID int64, keyWord string, status int, page int, count int) ([]*models.Activity, int64, error) {
38
+	if count <= 0 {
39
+		return []*models.Activity{}, 0, nil
40
+	}
41
+	if page < 1 {
42
+		page = 1
43
+	}
44
+
45
+	var activities []*models.Activity
46
+	var totalCount int64
47
+	db := service.PatientReadDB().Model(&models.Activity{}).Where("user_org_id = ? AND user_app_id = ? AND status = ?", orgID, appID, status)
48
+	if len(keyWord) > 0 {
49
+		likeParam := "%" + keyWord + "%"
50
+		db = db.Where("title LIKE ?", likeParam)
51
+	}
52
+	err := db.
53
+		Count(&totalCount).
54
+		Order("ctime desc").Limit(count).Offset((page - 1) * count).Find(&activities).
55
+		Error
56
+
57
+	if err == nil {
58
+		return activities, totalCount, nil
59
+	} else {
60
+		return nil, 0, err
61
+	}
62
+}
63
+
64
+func GetDidEndedActivities(orgID int64, appID int64, keyWord string, page int, count int) ([]*models.Activity, int64, error) {
65
+	if count <= 0 {
66
+		return []*models.Activity{}, 0, nil
67
+	}
68
+	if page < 1 {
69
+		page = 1
70
+	}
71
+
72
+	var activities []*models.Activity
73
+	var totalCount int64
74
+	now := time.Now().Unix()
75
+	db := service.PatientReadDB().Model(&models.Activity{}).Where("user_org_id = ? AND user_app_id = ? AND status = 1 AND start_time < ?", orgID, appID, now)
76
+	if len(keyWord) > 0 {
77
+		likeParam := "%" + keyWord + "%"
78
+		db = db.Where("title LIKE ?", likeParam)
79
+	}
80
+	err := db.
81
+		Count(&totalCount).
82
+		Order("ctime desc").Limit(count).Offset((page - 1) * count).Find(&activities).
83
+		Error
84
+
85
+	if err == nil {
86
+		return activities, totalCount, nil
87
+	} else {
88
+		return nil, 0, err
89
+	}
90
+}