完成教学案例和视频案例的实现层
This commit is contained in:
@@ -4,11 +4,14 @@
|
|||||||
package video_case
|
package video_case
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +23,23 @@ func CreateVideoCaseHandler(cfg *config.Config) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := video_case.NewCreateVideoCaseLogic(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)
|
||||||
|
|
||||||
|
video_caseModel := model.NewVideoCaseModel(conn)
|
||||||
|
|
||||||
|
l := video_case.NewCreateVideoCaseLogic(r.Context(), cfg, video_caseModel)
|
||||||
resp, err := l.CreateVideoCase(&req)
|
resp, err := l.CreateVideoCase(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
package video_case
|
package video_case
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +23,23 @@ func DeleteVideoCaseHandler(cfg *config.Config) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := video_case.NewDeleteVideoCaseLogic(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)
|
||||||
|
|
||||||
|
video_caseModel := model.NewVideoCaseModel(conn)
|
||||||
|
|
||||||
|
l := video_case.NewDeleteVideoCaseLogic(r.Context(), cfg, video_caseModel)
|
||||||
resp, err := l.DeleteVideoCase(&req)
|
resp, err := l.DeleteVideoCase(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
package video_case
|
package video_case
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +23,23 @@ func GetVideoCaseHandler(cfg *config.Config) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := video_case.NewGetVideoCaseLogic(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)
|
||||||
|
|
||||||
|
video_caseModel := model.NewVideoCaseModel(conn)
|
||||||
|
|
||||||
|
l := video_case.NewGetVideoCaseLogic(r.Context(), cfg, video_caseModel)
|
||||||
resp, err := l.GetVideoCase(&req)
|
resp, err := l.GetVideoCase(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
package video_case
|
package video_case
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +23,23 @@ func ListVideoCaseHandler(cfg *config.Config) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := video_case.NewListVideoCaseLogic(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)
|
||||||
|
|
||||||
|
video_caseModel := model.NewVideoCaseModel(conn)
|
||||||
|
|
||||||
|
l := video_case.NewListVideoCaseLogic(r.Context(), cfg, video_caseModel)
|
||||||
resp, err := l.ListVideoCase(&req)
|
resp, err := l.ListVideoCase(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
package video_case
|
package video_case
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/config"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +23,23 @@ func UpdateVideoCaseHandler(cfg *config.Config) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := video_case.NewUpdateVideoCaseLogic(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)
|
||||||
|
|
||||||
|
video_caseModel := model.NewVideoCaseModel(conn)
|
||||||
|
|
||||||
|
l := video_case.NewUpdateVideoCaseLogic(r.Context(), cfg, video_caseModel)
|
||||||
resp, err := l.UpdateVideoCase(&req)
|
resp, err := l.UpdateVideoCase(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package video_case
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
@@ -14,15 +15,17 @@ import (
|
|||||||
|
|
||||||
type CreateVideoCaseLogic struct {
|
type CreateVideoCaseLogic struct {
|
||||||
logx.Logger
|
logx.Logger
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
svcCtx *svc.ServiceContext
|
cfg *config.Config
|
||||||
|
model model.VideoCaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCreateVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVideoCaseLogic {
|
func NewCreateVideoCaseLogic(ctx context.Context, cfg *config.Config, model model.VideoCaseModel) *CreateVideoCaseLogic {
|
||||||
return &CreateVideoCaseLogic{
|
return &CreateVideoCaseLogic{
|
||||||
Logger: logx.WithContext(ctx),
|
Logger: logx.WithContext(ctx),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
svcCtx: svcCtx,
|
cfg: cfg,
|
||||||
|
model: model,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package video_case
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
@@ -14,15 +15,17 @@ import (
|
|||||||
|
|
||||||
type DeleteVideoCaseLogic struct {
|
type DeleteVideoCaseLogic struct {
|
||||||
logx.Logger
|
logx.Logger
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
svcCtx *svc.ServiceContext
|
cfg *config.Config
|
||||||
|
model model.VideoCaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeleteVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteVideoCaseLogic {
|
func NewDeleteVideoCaseLogic(ctx context.Context, cfg *config.Config, model model.VideoCaseModel) *DeleteVideoCaseLogic {
|
||||||
return &DeleteVideoCaseLogic{
|
return &DeleteVideoCaseLogic{
|
||||||
Logger: logx.WithContext(ctx),
|
Logger: logx.WithContext(ctx),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
svcCtx: svcCtx,
|
cfg: cfg,
|
||||||
|
model: model,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package video_case
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
@@ -14,15 +15,17 @@ import (
|
|||||||
|
|
||||||
type GetVideoCaseLogic struct {
|
type GetVideoCaseLogic struct {
|
||||||
logx.Logger
|
logx.Logger
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
svcCtx *svc.ServiceContext
|
cfg *config.Config
|
||||||
|
model model.VideoCaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGetVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVideoCaseLogic {
|
func NewGetVideoCaseLogic(ctx context.Context, cfg *config.Config, model model.VideoCaseModel) *GetVideoCaseLogic {
|
||||||
return &GetVideoCaseLogic{
|
return &GetVideoCaseLogic{
|
||||||
Logger: logx.WithContext(ctx),
|
Logger: logx.WithContext(ctx),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
svcCtx: svcCtx,
|
cfg: cfg,
|
||||||
|
model: model,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package video_case
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
@@ -14,15 +15,17 @@ import (
|
|||||||
|
|
||||||
type ListVideoCaseLogic struct {
|
type ListVideoCaseLogic struct {
|
||||||
logx.Logger
|
logx.Logger
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
svcCtx *svc.ServiceContext
|
cfg *config.Config
|
||||||
|
model model.VideoCaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewListVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVideoCaseLogic {
|
func NewListVideoCaseLogic(ctx context.Context, cfg *config.Config, model model.VideoCaseModel) *ListVideoCaseLogic {
|
||||||
return &ListVideoCaseLogic{
|
return &ListVideoCaseLogic{
|
||||||
Logger: logx.WithContext(ctx),
|
Logger: logx.WithContext(ctx),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
svcCtx: svcCtx,
|
cfg: cfg,
|
||||||
|
model: model,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ package video_case
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/model"
|
||||||
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
@@ -14,15 +15,17 @@ import (
|
|||||||
|
|
||||||
type UpdateVideoCaseLogic struct {
|
type UpdateVideoCaseLogic struct {
|
||||||
logx.Logger
|
logx.Logger
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
svcCtx *svc.ServiceContext
|
cfg *config.Config
|
||||||
|
model model.VideoCaseModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUpdateVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateVideoCaseLogic {
|
func NewUpdateVideoCaseLogic(ctx context.Context, cfg *config.Config, model model.VideoCaseModel) *UpdateVideoCaseLogic {
|
||||||
return &UpdateVideoCaseLogic{
|
return &UpdateVideoCaseLogic{
|
||||||
Logger: logx.WithContext(ctx),
|
Logger: logx.WithContext(ctx),
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
svcCtx: svcCtx,
|
cfg: cfg,
|
||||||
|
model: model,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user