完成课程活动Handler
This commit is contained in:
@@ -4,11 +4,14 @@
|
||||
package course_file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func CreateCourseFileHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_file.NewCreateCourseFileLogic(r.Context(), svcCtx)
|
||||
mysqlCfg := cfg.MySQL
|
||||
dsn := fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=true&loc=Local",
|
||||
mysqlCfg.Username,
|
||||
mysqlCfg.Password,
|
||||
mysqlCfg.Host,
|
||||
mysqlCfg.Port,
|
||||
mysqlCfg.Database,
|
||||
mysqlCfg.Charset,
|
||||
)
|
||||
fmt.Println("接收到articlePost请求")
|
||||
|
||||
conn := sqlx.NewSqlConn("mysql", dsn)
|
||||
FileModel := model.NewCourseFileModel(conn)
|
||||
|
||||
l := course_file.NewCreateCourseFileLogic(r.Context(), cfg, FileModel)
|
||||
resp, err := l.CreateCourseFile(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -19,8 +22,22 @@ func DeleteCourseFileHandler(cfg *config.Config) http.HandlerFunc {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
mysqlCfg := cfg.MySQL
|
||||
dsn := fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=true&loc=Local",
|
||||
mysqlCfg.Username,
|
||||
mysqlCfg.Password,
|
||||
mysqlCfg.Host,
|
||||
mysqlCfg.Port,
|
||||
mysqlCfg.Database,
|
||||
mysqlCfg.Charset,
|
||||
)
|
||||
fmt.Println("接收到articlePost请求")
|
||||
|
||||
l := course_file.NewDeleteCourseFileLogic(r.Context(), svcCtx)
|
||||
conn := sqlx.NewSqlConn("mysql", dsn)
|
||||
FileModel := model.NewCourseFileModel(conn)
|
||||
|
||||
l := course_file.NewDeleteCourseFileLogic(r.Context(), cfg, FileModel)
|
||||
resp, err := l.DeleteCourseFile(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func GetCourseFileHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_file.NewGetCourseFileLogic(r.Context(), svcCtx)
|
||||
mysqlCfg := cfg.MySQL
|
||||
dsn := fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=true&loc=Local",
|
||||
mysqlCfg.Username,
|
||||
mysqlCfg.Password,
|
||||
mysqlCfg.Host,
|
||||
mysqlCfg.Port,
|
||||
mysqlCfg.Database,
|
||||
mysqlCfg.Charset,
|
||||
)
|
||||
fmt.Println("接收到articlePost请求")
|
||||
|
||||
conn := sqlx.NewSqlConn("mysql", dsn)
|
||||
FileModel := model.NewCourseFileModel(conn)
|
||||
|
||||
l := course_file.NewGetCourseFileLogic(r.Context(), cfg, FileModel)
|
||||
resp, err := l.GetCourseFile(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func UpdateCourseFileHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_file.NewUpdateCourseFileLogic(r.Context(), svcCtx)
|
||||
mysqlCfg := cfg.MySQL
|
||||
dsn := fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=%s&parseTime=true&loc=Local",
|
||||
mysqlCfg.Username,
|
||||
mysqlCfg.Password,
|
||||
mysqlCfg.Host,
|
||||
mysqlCfg.Port,
|
||||
mysqlCfg.Database,
|
||||
mysqlCfg.Charset,
|
||||
)
|
||||
fmt.Println("接收到articlePost请求")
|
||||
|
||||
conn := sqlx.NewSqlConn("mysql", dsn)
|
||||
FileModel := model.NewCourseFileModel(conn)
|
||||
|
||||
l := course_file.NewUpdateCourseFileLogic(r.Context(), cfg, FileModel)
|
||||
resp, err := l.UpdateCourseFile(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
Reference in New Issue
Block a user