|
|
@@ -1,28 +1,26 @@
|
|
|
package course
|
|
|
|
|
|
import (
|
|
|
+ "dashoo.cn/micro_libary/response"
|
|
|
"dashoo.cn/modi_webapi/app/model/course"
|
|
|
service "dashoo.cn/modi_webapi/app/service/course"
|
|
|
- "github.com/gogf/gf/os/glog"
|
|
|
-
|
|
|
"dashoo.cn/modi_webapi/library/request"
|
|
|
- "dashoo.cn/modi_webapi/library/response"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
|
+ "github.com/gogf/gf/os/glog"
|
|
|
)
|
|
|
|
|
|
// 课程管理API管理对象
|
|
|
type Controller struct {
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 获取课程管理列表
|
|
|
-func (c *Controller) GetAllCourse(r *ghttp.Request){
|
|
|
+func (c *Controller) GetAllCourse(r *ghttp.Request) {
|
|
|
page := request.GetPageInfo(r)
|
|
|
where := ""
|
|
|
|
|
|
if year := r.GetInt("Year"); year != 0 {
|
|
|
- if where == ""{
|
|
|
+ if where == "" {
|
|
|
where = fmt.Sprintf(" Year = %v", year)
|
|
|
} else {
|
|
|
where += fmt.Sprintf(" AND Year = %v", year)
|
|
|
@@ -30,7 +28,7 @@ func (c *Controller) GetAllCourse(r *ghttp.Request){
|
|
|
}
|
|
|
|
|
|
if term := r.GetInt("Term"); term != 0 {
|
|
|
- if where == ""{
|
|
|
+ if where == "" {
|
|
|
where = fmt.Sprintf(" Term LIKE '%%%v%%'", term)
|
|
|
} else {
|
|
|
where += fmt.Sprintf(" AND Term LIKE '%%%v%%'", term)
|
|
|
@@ -38,13 +36,13 @@ func (c *Controller) GetAllCourse(r *ghttp.Request){
|
|
|
}
|
|
|
|
|
|
var result []course.Entity
|
|
|
- if err := course.GetAllCourse(page, where, &result); err != nil{
|
|
|
- if err.Error() == "sql: no rows in result set"{
|
|
|
+ if err := course.GetAllCourse(page, where, &result); err != nil {
|
|
|
+ if err.Error() == "sql: no rows in result set" {
|
|
|
response.Json(r, 0, "")
|
|
|
return
|
|
|
}
|
|
|
response.Json(r, -1, err.Error())
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
count, err1 := course.FindCourseCount(where)
|
|
|
if err1 != nil {
|
|
|
response.Json(r, -1, err1.Error())
|
|
|
@@ -58,15 +56,16 @@ func (c *Controller) GetAllCourse(r *ghttp.Request){
|
|
|
}
|
|
|
|
|
|
// Delete 删除课程主表信息
|
|
|
-func (c *Controller) DeleteCourse(r *ghttp.Request){
|
|
|
+func (c *Controller) DeleteCourse(r *ghttp.Request) {
|
|
|
id := r.GetInt("id")
|
|
|
- if _,err := course.Delete(fmt.Sprintf("Id=%v", id)); err != nil{
|
|
|
+ if _, err := course.Delete(fmt.Sprintf("Id=%v", id)); err != nil {
|
|
|
response.Json(r, 1, err.Error())
|
|
|
r.ExitAll()
|
|
|
} else {
|
|
|
response.Json(r, 0, "该记录已删除!")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// 修改课程信息
|
|
|
func (c *Controller) AddCourse(r *ghttp.Request) {
|
|
|
// tenant 租户模式
|
|
|
@@ -100,6 +99,7 @@ func (c *Controller) AddCourse(r *ghttp.Request) {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
// GetDetailById 根据id信息详情
|
|
|
func (c *Controller) GetDetailById(r *ghttp.Request) {
|
|
|
// tenant 租户模式
|