// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.17.8
package sys

import (
	"context"
	"hotgo/api/admin/lesson"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	Lesson = cLesson{}
)

type cLesson struct{}

// List 查看课程管理列表
func (c *cLesson) List(ctx context.Context, req *lesson.ListReq) (res *lesson.ListRes, err error) {
	list, totalCount, err := service.SysLesson().List(ctx, &req.LessonListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.LessonListModel{}
	}

	res = new(lesson.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出课程管理列表
func (c *cLesson) Export(ctx context.Context, req *lesson.ExportReq) (res *lesson.ExportRes, err error) {
	err = service.SysLesson().Export(ctx, &req.LessonListInp)
	return
}

// Edit 更新课程管理
func (c *cLesson) Edit(ctx context.Context, req *lesson.EditReq) (res *lesson.EditRes, err error) {
	err = service.SysLesson().Edit(ctx, &req.LessonEditInp)
	return
}

// View 获取指定课程管理信息
func (c *cLesson) View(ctx context.Context, req *lesson.ViewReq) (res *lesson.ViewRes, err error) {
	data, err := service.SysLesson().View(ctx, &req.LessonViewInp)
	if err != nil {
		return
	}

	res = new(lesson.ViewRes)
	res.LessonViewModel = data
	return
}

// Delete 删除课程管理
func (c *cLesson) Delete(ctx context.Context, req *lesson.DeleteReq) (res *lesson.DeleteRes, err error) {
	err = service.SysLesson().Delete(ctx, &req.LessonDeleteInp)
	return
}