|
@@ -2,6 +2,7 @@ package message
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"errors"
|
|
5
|
+ "spaceofcheng/services/models/message"
|
5
|
6
|
"spaceofcheng/services/models/model"
|
6
|
7
|
"spaceofcheng/services/utils"
|
7
|
8
|
"strings"
|
|
@@ -86,3 +87,45 @@ func (s *MessageServ) UpdateLocationSort(locations string) error {
|
86
|
87
|
}
|
87
|
88
|
return nil
|
88
|
89
|
}
|
|
90
|
+
|
|
91
|
+// GetLocationInfoList 获取详情
|
|
92
|
+func (s *MessageServ) GetLocationInfoList() ([]message.LocationInfo, error) {
|
|
93
|
+ var org = s.ctx.Get("org").(model.SysOrg)
|
|
94
|
+ locations, err := s.dao.GetLocationInfoList(org.OrgId)
|
|
95
|
+ if err != nil {
|
|
96
|
+ utils.LogError("获取Location失败: " + err.Error())
|
|
97
|
+ return nil, errors.New("获取失败")
|
|
98
|
+ }
|
|
99
|
+ for inx, l := range locations {
|
|
100
|
+ news, err := s.dao.GetNewsByLocation(l.LocationId, org.OrgId)
|
|
101
|
+ if err != nil {
|
|
102
|
+ utils.LogError("获取新闻信息失败: " + err.Error())
|
|
103
|
+ return nil, errors.New("获取新闻信息失败")
|
|
104
|
+ }
|
|
105
|
+ locations[inx].News = news
|
|
106
|
+
|
|
107
|
+ imgs, err := s.dao.GetImgByLocation(l.LocationId, org.OrgId)
|
|
108
|
+ if err != nil {
|
|
109
|
+ utils.LogError("获取图片信息失败: " + err.Error())
|
|
110
|
+ return nil, errors.New("获取图片信息失败")
|
|
111
|
+ }
|
|
112
|
+ locations[inx].Banners = imgs
|
|
113
|
+ if l.LocationId == "selected" {
|
|
114
|
+ courses, err := s.coursedao.GetSelectCourseWithCaseList(org.OrgId)
|
|
115
|
+ if err != nil {
|
|
116
|
+ utils.LogError("获取课程信息失败: " + err.Error())
|
|
117
|
+ return nil, errors.New("获取课程信息失败")
|
|
118
|
+ }
|
|
119
|
+ locations[inx].Courses = courses
|
|
120
|
+ } else {
|
|
121
|
+ courses, err := s.coursedao.GetCourseWithCaseByLocation(org.OrgId, l.LocationId)
|
|
122
|
+ if err != nil {
|
|
123
|
+ utils.LogError("获取课程信息失败: " + err.Error())
|
|
124
|
+ return nil, errors.New("获取课程信息失败")
|
|
125
|
+ }
|
|
126
|
+ locations[inx].Courses = courses
|
|
127
|
+ }
|
|
128
|
+ }
|
|
129
|
+
|
|
130
|
+ return locations, nil
|
|
131
|
+}
|