|
@@ -460,7 +460,7 @@ func (m *CourseDAO) GetSelectCourseList(orgid string) ([]CourseDetail, error) {
|
460
|
460
|
var courses []CourseDetail
|
461
|
461
|
sql := `select * from ta_course where is_select=` + strconv.Itoa(IS_SELECT) + ` and status=` + strconv.Itoa(models.STATUS_NORMAL) + ` and org_id='` + orgid + `'
|
462
|
462
|
and course_id NOT in (
|
463
|
|
- select course_id from ta_course_detail where begin_date<=NOW()
|
|
463
|
+ select course_id from ta_course_detail where begin_date<=NOW() and status>` + strconv.Itoa(models.STATUS_DEL) + `
|
464
|
464
|
)`
|
465
|
465
|
err := m.db.Sql(sql).Find(&courses)
|
466
|
466
|
return courses, err
|
|
@@ -471,7 +471,7 @@ func (m *CourseDAO) GetCourseByLocation(orgid, locationid string) ([]CourseDetai
|
471
|
471
|
var courses []CourseDetail
|
472
|
472
|
sql := `select * from ta_course where status=` + strconv.Itoa(models.STATUS_NORMAL) + ` and org_id='` + orgid + `' and location_id ='` + locationid + `'
|
473
|
473
|
and course_id NOT in (
|
474
|
|
- select course_id from ta_course_detail where begin_date<=NOW()
|
|
474
|
+ select course_id from ta_course_detail where begin_date<=NOW() and status>` + strconv.Itoa(models.STATUS_DEL) + `
|
475
|
475
|
)`
|
476
|
476
|
err := m.db.Sql(sql).Find(&courses)
|
477
|
477
|
return courses, err
|
|
@@ -635,7 +635,7 @@ func (m *CourseDAO) GetSelectCourseWithCaseList(orgid string) ([]CourseWithCase,
|
635
|
635
|
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) + `
|
636
|
636
|
and a.status=` + strconv.Itoa(models.STATUS_NORMAL) + ` and a.org_id='` + orgid + `'
|
637
|
637
|
and a.course_id NOT in (
|
638
|
|
- select course_id from ta_course_detail where begin_date<=NOW()
|
|
638
|
+ select course_id from ta_course_detail where begin_date<=NOW() and status>` + strconv.Itoa(models.STATUS_DEL) + `
|
639
|
639
|
)`
|
640
|
640
|
err := m.db.Sql(sql).Find(&courses)
|
641
|
641
|
return courses, err
|
|
@@ -647,18 +647,25 @@ func (m *CourseDAO) GetCourseWithCaseByLocation(orgid, locationid string) ([]Cou
|
647
|
647
|
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) + `
|
648
|
648
|
and a.org_id='` + orgid + `' and a.location_id ='` + locationid + `'
|
649
|
649
|
and a.course_id NOT in (
|
650
|
|
- select course_id from ta_course_detail where begin_date<=NOW()
|
|
650
|
+ select course_id from ta_course_detail where begin_date<=NOW() and status>` + strconv.Itoa(models.STATUS_DEL) + `
|
651
|
651
|
)`
|
652
|
652
|
err := m.db.Sql(sql).Find(&courses)
|
653
|
653
|
return courses, err
|
654
|
654
|
}
|
655
|
655
|
|
|
656
|
+// CourseWithType 可用课程
|
|
657
|
+type CourseWithType struct {
|
|
658
|
+ model.TaCourse `xorm:"extends"`
|
|
659
|
+ LocationName string
|
|
660
|
+}
|
|
661
|
+
|
656
|
662
|
// GetCourseCanUse 获取可用课程列表
|
657
|
|
-func (m *CourseDAO) GetCourseCanUse(caseids string, page, pageSize int) ([]model.TaCourse, error) {
|
658
|
|
- var courses []model.TaCourse
|
659
|
|
- sql := `select * from ta_course where status=? and case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `') and course_id not in (
|
660
|
|
- select course_id from ta_course_detail where begin_date<=NOW()
|
661
|
|
- ) order by create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
|
663
|
+func (m *CourseDAO) GetCourseCanUse(caseids string, page, pageSize int) ([]CourseWithType, error) {
|
|
664
|
+ var courses []CourseWithType
|
|
665
|
+ sql := `select a.*,b.location_name from ta_course a inner join td_cms_image_location b on a.location_id=b.location_id where a.status=? and
|
|
666
|
+ a.case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `') and a.course_id not in (
|
|
667
|
+ select course_id from ta_course_detail where begin_date<=NOW() and status>` + strconv.Itoa(models.STATUS_DEL) + `
|
|
668
|
+ ) order by a.create_date desc limit ` + strconv.Itoa((page-1)*pageSize) + `, ` + strconv.Itoa(pageSize)
|
662
|
669
|
err := m.db.Sql(sql, models.STATUS_NORMAL).Find(&courses)
|
663
|
670
|
// err := m.db.Where("status=?", models.STATUS_NORMAL).And("case_id in ('"+strings.Replace(caseids, ",", "','", -1)+"')").And("begin_date>NOW()").Desc("create_date").Limit(pageSize, (page-1)*pageSize).Find(&courses)
|
664
|
671
|
return courses, err
|
|
@@ -668,7 +675,7 @@ func (m *CourseDAO) GetCourseCanUse(caseids string, page, pageSize int) ([]model
|
668
|
675
|
func (m *CourseDAO) GetCourseCanUseCount(caseids string) (int, error) {
|
669
|
676
|
var courses []model.TaCourse
|
670
|
677
|
sql := `select * from ta_course where status=? and case_id in ('` + strings.Replace(caseids, ",", "','", -1) + `') and course_id not in (
|
671
|
|
- select course_id from ta_course_detail where begin_date<=NOW()
|
|
678
|
+ select course_id from ta_course_detail where begin_date<=NOW() and status>` + strconv.Itoa(models.STATUS_DEL) + `
|
672
|
679
|
)`
|
673
|
680
|
err := m.db.Sql(sql, models.STATUS_NORMAL).Find(&courses)
|
674
|
681
|
// err := m.db.Where("status=?", models.STATUS_NORMAL).And("case_id in ('" + strings.Replace(caseids, ",", "','", -1) + "')").And("begin_date>NOW()").Find(&courses)
|