Browse Source

bug修改

wangfei 6 years ago
parent
commit
25b458f1a6

+ 9
- 0
controllers/message/location.go View File

@@ -60,3 +60,12 @@ func (c *MessageController) UpdateLocationSort() {
60 60
 	}
61 61
 	c.ResponseJSON("操作成功!")
62 62
 }
63
+
64
+// GetLocationInfoList 根据位置信息
65
+func (c *MessageController) GetLocationInfoList() {
66
+	infos, err := c.dao.GetLocationInfoList()
67
+	if err != nil {
68
+		c.ResponseError(err)
69
+	}
70
+	c.ResponseJSON(infos)
71
+}

+ 4
- 0
log/common.log View File

@@ -0,0 +1,4 @@
1
+2018/09/19 10:11:21 [E] 获取人员信息失败: 当前用户没有权限查看用户信息
2
+2018/09/19 10:56:30 [E] 获取课程信息失败: Error 1052: Column 'org_id' in where clause is ambiguous
3
+2018/09/19 10:56:35 [E] 获取课程信息失败: Error 1052: Column 'org_id' in where clause is ambiguous
4
+2018/09/19 10:57:05 [E] 获取课程信息失败: Error 1052: Column 'org_id' in where clause is ambiguous

+ 31
- 0
models/course/course.go View File

@@ -574,3 +574,34 @@ func (m *CourseDAO) GetCourseBySendType(typeval, caseids string) ([]model.TaCour
574 574
 	err := m.db.Where("status=?", models.STATUS_NORMAL).And("case_id in ('" + strings.Replace(caseids, ",", "','", -1) + "')").Find(&courses)
575 575
 	return courses, err
576 576
 }
577
+
578
+// CourseWithCase 课程with案场
579
+type CourseWithCase struct {
580
+	model.TaCourse `xorm:"extends"`
581
+	CaseName       string
582
+	CaseAddress    string
583
+}
584
+
585
+// GetSelectCourseWithCaseList 获取精选课程
586
+func (m *CourseDAO) GetSelectCourseWithCaseList(orgid string) ([]CourseWithCase, error) {
587
+	var courses []CourseWithCase
588
+	sql := `select a.*,b.case_name,b.case_address from ta_course a inner join sys_case b on a.case_id=b.case_id where a.is_select=` + strconv.Itoa(IS_SELECT) + ` 
589
+	and a.status=` + strconv.Itoa(models.STATUS_NORMAL) + ` and a.org_id='` + orgid + `'
590
+	and a.course_id NOT in (
591
+		select course_id from ta_course_detail where begin_date<=NOW()
592
+	)`
593
+	err := m.db.Sql(sql).Find(&courses)
594
+	return courses, err
595
+}
596
+
597
+// GetCourseWithCaseByLocation 根据位置获取课程信息
598
+func (m *CourseDAO) GetCourseWithCaseByLocation(orgid, locationid string) ([]CourseWithCase, error) {
599
+	var courses []CourseWithCase
600
+	sql := `select a.*,b.case_name,b.case_address from ta_course a inner join sys_case b on a.case_id=b.case_id where a.status=` + strconv.Itoa(models.STATUS_NORMAL) + ` 
601
+	and a.org_id='` + orgid + `' and a.location_id ='` + locationid + `' 
602
+	and a.course_id NOT in (
603
+		select course_id from ta_course_detail where begin_date<=NOW()
604
+	)`
605
+	err := m.db.Sql(sql).Find(&courses)
606
+	return courses, err
607
+}

+ 20
- 0
models/message/location.go View File

@@ -2,6 +2,7 @@ package message
2 2
 
3 3
 import (
4 4
 	"spaceofcheng/services/models"
5
+	"spaceofcheng/services/models/course"
5 6
 	"spaceofcheng/services/models/model"
6 7
 	"spaceofcheng/services/utils"
7 8
 	"strconv"
@@ -110,3 +111,22 @@ func (m *MessageDAO) UpdateLocationSortByID(orderno int) error {
110 111
 	_, err := m.db.Exec(sql)
111 112
 	return err
112 113
 }
114
+
115
+// LocationInfo 详情
116
+type LocationInfo struct {
117
+	model.TdCmsImageLocation `xorm:"extends"`
118
+	Banners                  []model.TaCmsImages
119
+	News                     []model.TaCmsNews
120
+	Courses                  []course.CourseWithCase
121
+}
122
+
123
+// GetLocationInfoList 获取列表
124
+func (m *MessageDAO) GetLocationInfoList(orgid string) ([]LocationInfo, error) {
125
+	var locations []LocationInfo
126
+	sql := `select * from td_cms_image_location where status>? and location_id<>'index' and org_id=? order by order_no asc`
127
+	err := m.db.Sql(sql, models.STATUS_DEL, orgid).Find(&locations)
128
+	if err != nil {
129
+		return nil, err
130
+	}
131
+	return locations, nil
132
+}

+ 1
- 0
routers/guest.go View File

@@ -23,6 +23,7 @@ func getGuestRoutes() beego.LinkNamespace {
23 23
 		beego.NSRouter("/cms/news", &message.MessageController{}, "get:GetNewsByLocation"),
24 24
 		beego.NSRouter("/cms/case", &message.MessageController{}, "get:GetCmsCaseList"),
25 25
 		beego.NSRouter("/cms/location", &message.MessageController{}, "get:GetLocations"),
26
+		beego.NSRouter("/cms/location/detail", &message.MessageController{}, "get:GetLocationInfoList"),
26 27
 		beego.NSRouter("/cms/course", &course.CourseController{}, "get:GetCourseByLocation"),
27 28
 		beego.NSRouter("/cms/case/:cmscaseid", &message.MessageController{}, "get:GetCmsCaseByID"),
28 29
 

+ 43
- 0
service/message/location.go View File

@@ -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
+}