// 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/lessonsection"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	LessonSection = cLessonSection{}
)

type cLessonSection struct{}

// List 查看课程章节列表
func (c *cLessonSection) List(ctx context.Context, req *lessonsection.ListReq) (res *lessonsection.ListRes, err error) {
	list, totalCount, err := service.SysLessonSection().List(ctx, &req.LessonSectionListInp)
	if err != nil {
		return
	}

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

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

// Export 导出课程章节列表
func (c *cLessonSection) Export(ctx context.Context, req *lessonsection.ExportReq) (res *lessonsection.ExportRes, err error) {
	err = service.SysLessonSection().Export(ctx, &req.LessonSectionListInp)
	return
}

// Edit 更新课程章节
func (c *cLessonSection) Edit(ctx context.Context, req *lessonsection.EditReq) (res *lessonsection.EditRes, err error) {
	err = service.SysLessonSection().Edit(ctx, &req.LessonSectionEditInp)
	return
}

// View 获取指定课程章节信息
func (c *cLessonSection) View(ctx context.Context, req *lessonsection.ViewReq) (res *lessonsection.ViewRes, err error) {
	data, err := service.SysLessonSection().View(ctx, &req.LessonSectionViewInp)
	if err != nil {
		return
	}

	res = new(lessonsection.ViewRes)
	res.LessonSectionViewModel = data
	return
}

// Delete 删除课程章节
func (c *cLessonSection) Delete(ctx context.Context, req *lessonsection.DeleteReq) (res *lessonsection.DeleteRes, err error) {
	err = service.SysLessonSection().Delete(ctx, &req.LessonSectionDeleteInp)
	return
}