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

var (
	LessonCategory = cLessonCategory{}
)

type cLessonCategory struct{}

// List 查看课程分类列表
func (c *cLessonCategory) List(ctx context.Context, req *lessoncategory.ListReq) (res *lessoncategory.ListRes, err error) {
	list, totalCount, err := service.SysLessonCategory().List(ctx, &req.LessonCategoryListInp)
	if err != nil {
		return
	}

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

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

// Export 导出课程分类列表
func (c *cLessonCategory) Export(ctx context.Context, req *lessoncategory.ExportReq) (res *lessoncategory.ExportRes, err error) {
	err = service.SysLessonCategory().Export(ctx, &req.LessonCategoryListInp)
	return
}

// Edit 更新课程分类
func (c *cLessonCategory) Edit(ctx context.Context, req *lessoncategory.EditReq) (res *lessoncategory.EditRes, err error) {
	err = service.SysLessonCategory().Edit(ctx, &req.LessonCategoryEditInp)
	return
}

// View 获取指定课程分类信息
func (c *cLessonCategory) View(ctx context.Context, req *lessoncategory.ViewReq) (res *lessoncategory.ViewRes, err error) {
	data, err := service.SysLessonCategory().View(ctx, &req.LessonCategoryViewInp)
	if err != nil {
		return
	}

	res = new(lessoncategory.ViewRes)
	res.LessonCategoryViewModel = data
	return
}

// Delete 删除课程分类
func (c *cLessonCategory) Delete(ctx context.Context, req *lessoncategory.DeleteReq) (res *lessoncategory.DeleteRes, err error) {
	err = service.SysLessonCategory().Delete(ctx, &req.LessonCategoryDeleteInp)
	return
}