ソースを参照

修改课程查询条件

dbcgit 5 年 前
コミット
213a9dc047

+ 5 - 4
backend/src/dashoo.cn/modi_webapi/app/api/course/course.go

@@ -29,19 +29,20 @@ func (c *Controller) GetAllCourse(r *ghttp.Request) {
 
 	if term := r.GetInt("Term"); term != 0 {
 		if where == "" {
-			where = fmt.Sprintf(" Term LIKE '%%%v%%'", term)
+			where = fmt.Sprintf(" Term = %v", term)
 		} else {
-			where += fmt.Sprintf(" AND Term LIKE '%%%v%%'", term)
+			where += fmt.Sprintf(" AND Term = %v", term)
 		}
 	}
 
 	if classId := r.GetInt("ClassId"); classId != 0 {
 		if where == "" {
-			where = fmt.Sprintf(" ClassId LIKE '%%%v%%'", classId)
+			where = fmt.Sprintf(" ClassId = %v", classId)
 		} else {
-			where += fmt.Sprintf(" AND ClassId LIKE '%%%v%%'", classId)
+			where += fmt.Sprintf(" AND ClassId = %v", classId)
 		}
 	}
+
 	var result []course.Entity
 	if err := course.GetAllCourse(page, where, &result); err != nil {
 		if err.Error() == "sql: no rows in result set" {