添加课程活动router
This commit is contained in:
@@ -4,11 +4,14 @@
|
||||
package course_activity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func CreateCourseActivityHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_activity.NewCreateCourseActivityLogic(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)
|
||||
ActivityModel := model.NewCourseActivityModel(conn)
|
||||
|
||||
l := course_activity.NewCreateCourseActivityLogic(r.Context(), cfg, ActivityModel)
|
||||
resp, err := l.CreateCourseActivity(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_activity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func DeleteCourseActivityHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_activity.NewDeleteCourseActivityLogic(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)
|
||||
ActivityModel := model.NewCourseActivityModel(conn)
|
||||
|
||||
l := course_activity.NewDeleteCourseActivityLogic(r.Context(), cfg, ActivityModel)
|
||||
resp, err := l.DeleteCourseActivity(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_activity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -19,8 +22,22 @@ func GetCourseActivityHandler(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_activity.NewGetCourseActivityLogic(r.Context(), svcCtx)
|
||||
conn := sqlx.NewSqlConn("mysql", dsn)
|
||||
ActivityModel := model.NewCourseActivityModel(conn)
|
||||
|
||||
l := course_activity.NewGetCourseActivityLogic(r.Context(), cfg, ActivityModel)
|
||||
resp, err := l.GetCourseActivity(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_activity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func ListCourseActivityHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_activity.NewListCourseActivityLogic(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)
|
||||
ActivityModel := model.NewCourseActivityModel(conn)
|
||||
|
||||
l := course_activity.NewListCourseActivityLogic(r.Context(), cfg, ActivityModel)
|
||||
resp, err := l.ListCourseActivity(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
package course_activity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/model"
|
||||
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
@@ -20,7 +23,22 @@ func UpdateCourseActivityHandler(cfg *config.Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
l := course_activity.NewUpdateCourseActivityLogic(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)
|
||||
ActivityModel := model.NewCourseActivityModel(conn)
|
||||
|
||||
l := course_activity.NewUpdateCourseActivityLogic(r.Context(), cfg, ActivityModel)
|
||||
resp, err := l.UpdateCourseActivity(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
|
||||
Reference in New Issue
Block a user