|
|
@@ -8,6 +8,7 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
|
"github.com/gogf/gf/os/glog"
|
|
|
+ "log"
|
|
|
)
|
|
|
|
|
|
// 课程管理API管理对象
|
|
|
@@ -17,49 +18,24 @@ type Controller struct {
|
|
|
// 获取课程管理列表
|
|
|
func (c *Controller) GetAllCourse(r *ghttp.Request) {
|
|
|
page := request.GetPageInfo(r)
|
|
|
- where := ""
|
|
|
|
|
|
- if year := r.GetInt("Year"); year != 0 {
|
|
|
- if where == "" {
|
|
|
- where = fmt.Sprintf(" Year = %v", year)
|
|
|
- } else {
|
|
|
- where += fmt.Sprintf(" AND Year = %v", year)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if term := r.GetInt("Term"); term != 0 {
|
|
|
- if where == "" {
|
|
|
- where = fmt.Sprintf(" Term = %v", term)
|
|
|
- } else {
|
|
|
- where += fmt.Sprintf(" AND Term = %v", term)
|
|
|
- }
|
|
|
- }
|
|
|
+ var req course.SearchReq
|
|
|
|
|
|
- if classId := r.GetInt("ClassId"); classId != 0 {
|
|
|
- if where == "" {
|
|
|
- where = fmt.Sprintf(" ClassId = %v", classId)
|
|
|
- } else {
|
|
|
- where += fmt.Sprintf(" AND ClassId = %v", classId)
|
|
|
- }
|
|
|
+ if err := r.Parse(&req);err!=nil{
|
|
|
+ response.Json(r, 1, err.Error())
|
|
|
}
|
|
|
|
|
|
- if Status := r.GetInt("Status"); Status != 0 {
|
|
|
- if where == "" {
|
|
|
- where = fmt.Sprintf(" Status = %v", Status)
|
|
|
- } else {
|
|
|
- where += fmt.Sprintf(" AND Status = %v", Status)
|
|
|
- }
|
|
|
- }
|
|
|
+ log.Println(" req ",req)
|
|
|
|
|
|
var result []course.Entity
|
|
|
- if err := course.GetAllCourse(page, where, &result); err != nil {
|
|
|
+ if err := course.GetAllCourse(page, req, &result); err != nil {
|
|
|
if err.Error() == "sql: no rows in result set" {
|
|
|
response.Json(r, 0, "")
|
|
|
return
|
|
|
}
|
|
|
response.Json(r, 1, err.Error())
|
|
|
} else {
|
|
|
- count, err1 := course.FindCourseCount(where)
|
|
|
+ count, err1 := course.FindCourseCount(req)
|
|
|
if err1 != nil {
|
|
|
response.Json(r, 1, err1.Error())
|
|
|
} else {
|