commit
e21bc3a51b
59
server/api/admin/lessonsection/lessonsection.go
Normal file
59
server/api/admin/lessonsection/lessonsection.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Package lessonsection
|
||||||
|
// @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 lessonsection
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/model/input/form"
|
||||||
|
"hotgo/internal/model/input/sysin"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListReq 查询课程章节列表
|
||||||
|
type ListReq struct {
|
||||||
|
g.Meta `path:"/lessonSection/list" method:"get" tags:"课程章节" summary:"获取课程章节列表"`
|
||||||
|
sysin.LessonSectionListInp
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListRes struct {
|
||||||
|
form.PageRes
|
||||||
|
List []*sysin.LessonSectionListModel `json:"list" dc:"数据列表"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportReq 导出课程章节列表
|
||||||
|
type ExportReq struct {
|
||||||
|
g.Meta `path:"/lessonSection/export" method:"get" tags:"课程章节" summary:"导出课程章节列表"`
|
||||||
|
sysin.LessonSectionListInp
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExportRes struct{}
|
||||||
|
|
||||||
|
// ViewReq 获取课程章节指定信息
|
||||||
|
type ViewReq struct {
|
||||||
|
g.Meta `path:"/lessonSection/view" method:"get" tags:"课程章节" summary:"获取课程章节指定信息"`
|
||||||
|
sysin.LessonSectionViewInp
|
||||||
|
}
|
||||||
|
|
||||||
|
type ViewRes struct {
|
||||||
|
*sysin.LessonSectionViewModel
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditReq 修改/新增课程章节
|
||||||
|
type EditReq struct {
|
||||||
|
g.Meta `path:"/lessonSection/edit" method:"post" tags:"课程章节" summary:"修改/新增课程章节"`
|
||||||
|
sysin.LessonSectionEditInp
|
||||||
|
}
|
||||||
|
|
||||||
|
type EditRes struct{}
|
||||||
|
|
||||||
|
// DeleteReq 删除课程章节
|
||||||
|
type DeleteReq struct {
|
||||||
|
g.Meta `path:"/lessonSection/delete" method:"post" tags:"课程章节" summary:"删除课程章节"`
|
||||||
|
sysin.LessonSectionDeleteInp
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteRes struct{}
|
18
server/api/api/lesson/lesson.go
Normal file
18
server/api/api/lesson/lesson.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package lesson
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"hotgo/api/api/lesson/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ILessonV1 interface {
|
||||||
|
LessonList(ctx context.Context, req *v1.LessonListReq) (res *v1.LessonListRes, err error)
|
||||||
|
LessonDetail(ctx context.Context, req *v1.LessonDetailReq) (res *v1.LessonDetailRes, err error)
|
||||||
|
LessonSectionList(ctx context.Context, req *v1.LessonSectionListReq) (res *v1.LessonSectionListRes, err error)
|
||||||
|
LessonSectionDetail(ctx context.Context, req *v1.LessonSectionDetailReq) (res *v1.LessonSectionDetailRes, err error)
|
||||||
|
}
|
52
server/api/api/lesson/v1/lesson.go
Normal file
52
server/api/api/lesson/v1/lesson.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 获取课程列表请求
|
||||||
|
type LessonListReq struct {
|
||||||
|
g.Meta `path:"/lesson/list" method:"get" tags:"课程" summary:"获取课程列表"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取课程列表响应
|
||||||
|
type LessonListRes struct {
|
||||||
|
List []*entity.Lesson `json:"list" dc:"课程列表"`
|
||||||
|
Total int `json:"total" dc:"总数"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看课程详情请求
|
||||||
|
type LessonDetailReq struct {
|
||||||
|
g.Meta `path:"/lesson/detail" method:"get" tags:"课程" summary:"查看课程详情"`
|
||||||
|
Id int64 `json:"id" v:"required#课程ID必填" dc:"课程ID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看课程详情响应
|
||||||
|
type LessonDetailRes struct {
|
||||||
|
*entity.Lesson `dc:"课程"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取课程章节列表请求
|
||||||
|
type LessonSectionListReq struct {
|
||||||
|
g.Meta `path:"/lesson/section/list" method:"get" tags:"课程章节" summary:"获取课程章节列表"`
|
||||||
|
LessonId int64 `json:"lessonId" v:"required#课程ID必填" dc:"课程ID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取课程章节列表响应
|
||||||
|
type LessonSectionListRes struct {
|
||||||
|
List []*entity.LessonSection `json:"list" dc:"课程章节列表"`
|
||||||
|
Total int `json:"total" dc:"总数"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取课程章节详情请求
|
||||||
|
type LessonSectionDetailReq struct {
|
||||||
|
g.Meta `path:"/lesson/section/detail" method:"get" tags:"课程章节" summary:"获取课程章节详情"`
|
||||||
|
Id int64 `json:"id" v:"required#课程章节ID必填" dc:"课程章节ID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取课程章节详情响应
|
||||||
|
type LessonSectionDetailRes struct {
|
||||||
|
*entity.LessonSection `dc:"课程章节"`
|
||||||
|
}
|
67
server/internal/controller/admin/sys/lesson_section.go
Normal file
67
server/internal/controller/admin/sys/lesson_section.go
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// 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
|
||||||
|
}
|
5
server/internal/controller/api/lesson/lesson.go
Normal file
5
server/internal/controller/api/lesson/lesson.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package lesson
|
15
server/internal/controller/api/lesson/lesson_new.go
Normal file
15
server/internal/controller/api/lesson/lesson_new.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package lesson
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/api/api/lesson"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ControllerV1 struct{}
|
||||||
|
|
||||||
|
func NewV1() lesson.ILessonV1 {
|
||||||
|
return &ControllerV1{}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package lesson
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
|
||||||
|
v1 "hotgo/api/api/lesson/v1"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) LessonDetail(ctx context.Context, req *v1.LessonDetailReq) (res *v1.LessonDetailRes, err error) {
|
||||||
|
lesson := new(entity.Lesson)
|
||||||
|
err = dao.Lesson.Ctx(ctx).Where("id = ?", req.Id).Scan(lesson)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeDbOperationError, "数据库错误")
|
||||||
|
}
|
||||||
|
if lesson.Id == 0 {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeNotFound, "课程不存在")
|
||||||
|
}
|
||||||
|
res = &v1.LessonDetailRes{
|
||||||
|
Lesson: lesson,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package lesson
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1 "hotgo/api/api/lesson/v1"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) LessonList(ctx context.Context, req *v1.LessonListReq) (res *v1.LessonListRes, err error) {
|
||||||
|
// 查询课程列表
|
||||||
|
var list []*entity.Lesson
|
||||||
|
err = dao.Lesson.Ctx(ctx).Scan(&list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeDbOperationError, "数据库错误")
|
||||||
|
}
|
||||||
|
// 统计总数
|
||||||
|
total, err := dao.Lesson.Ctx(ctx).Count()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeDbOperationError, "统计总数失败")
|
||||||
|
}
|
||||||
|
res = &v1.LessonListRes{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package lesson
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
|
||||||
|
v1 "hotgo/api/api/lesson/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) LessonSectionDetail(ctx context.Context, req *v1.LessonSectionDetailReq) (res *v1.LessonSectionDetailRes, err error) {
|
||||||
|
section := new(entity.LessonSection)
|
||||||
|
err = dao.LessonSection.Ctx(ctx).Where("id = ?", req.Id).Scan(section)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeDbOperationError, "数据库错误")
|
||||||
|
}
|
||||||
|
if section.Id == 0 {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeNotFound, "课程章节不存在")
|
||||||
|
}
|
||||||
|
res = &v1.LessonSectionDetailRes{
|
||||||
|
LessonSection: section,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package lesson
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
|
||||||
|
v1 "hotgo/api/api/lesson/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) LessonSectionList(ctx context.Context, req *v1.LessonSectionListReq) (res *v1.LessonSectionListRes, err error) {
|
||||||
|
var list []*entity.LessonSection
|
||||||
|
err = dao.LessonSection.Ctx(ctx).Where("lesson_id = ?", req.LessonId).Scan(&list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeDbOperationError, "数据库错误")
|
||||||
|
}
|
||||||
|
total, err := dao.LessonSection.Ctx(ctx).Where("lesson_id = ?", req.LessonId).Count()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.NewCode(gcode.CodeDbOperationError, "统计总数失败")
|
||||||
|
}
|
||||||
|
res = &v1.LessonSectionListRes{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
101
server/internal/dao/internal/lesson_section.go
Executable file
101
server/internal/dao/internal/lesson_section.go
Executable file
@ -0,0 +1,101 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LessonSectionDao is the data access object for the table hg_lesson_section.
|
||||||
|
type LessonSectionDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns LessonSectionColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// LessonSectionColumns defines and stores column names for the table hg_lesson_section.
|
||||||
|
type LessonSectionColumns struct {
|
||||||
|
Id string // id
|
||||||
|
LessonId string // 课程id
|
||||||
|
VideoUrl string // 视频url
|
||||||
|
Name string // 章节名
|
||||||
|
SortOrder string // 排序号
|
||||||
|
ParentId string // 父章节id
|
||||||
|
Level string // 章节层级;1=章,2=节
|
||||||
|
Revision string // 乐观锁
|
||||||
|
CreatedBy string // 创建人
|
||||||
|
CreatedTime string // 创建时间
|
||||||
|
UpdatedBy string // 更新人
|
||||||
|
UpdatedTime string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// lessonSectionColumns holds the columns for the table hg_lesson_section.
|
||||||
|
var lessonSectionColumns = LessonSectionColumns{
|
||||||
|
Id: "id",
|
||||||
|
LessonId: "lesson_id",
|
||||||
|
VideoUrl: "video_url",
|
||||||
|
Name: "name",
|
||||||
|
SortOrder: "sort_order",
|
||||||
|
ParentId: "parent_id",
|
||||||
|
Level: "level",
|
||||||
|
Revision: "revision",
|
||||||
|
CreatedBy: "created_by",
|
||||||
|
CreatedTime: "created_time",
|
||||||
|
UpdatedBy: "updated_by",
|
||||||
|
UpdatedTime: "updated_time",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLessonSectionDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewLessonSectionDao(handlers ...gdb.ModelHandler) *LessonSectionDao {
|
||||||
|
return &LessonSectionDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_lesson_section",
|
||||||
|
columns: lessonSectionColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *LessonSectionDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *LessonSectionDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *LessonSectionDao) Columns() LessonSectionColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *LessonSectionDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *LessonSectionDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *LessonSectionDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
22
server/internal/dao/lesson_section.go
Executable file
22
server/internal/dao/lesson_section.go
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// lessonSectionDao is the data access object for the table hg_lesson_section.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type lessonSectionDao struct {
|
||||||
|
*internal.LessonSectionDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// LessonSection is a globally accessible object for table hg_lesson_section operations.
|
||||||
|
LessonSection = lessonSectionDao{internal.NewLessonSectionDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
@ -12,6 +12,7 @@ import (
|
|||||||
"hotgo/internal/dao"
|
"hotgo/internal/dao"
|
||||||
"hotgo/internal/library/contexts"
|
"hotgo/internal/library/contexts"
|
||||||
"hotgo/internal/library/hgorm/handler"
|
"hotgo/internal/library/hgorm/handler"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
"hotgo/internal/model/input/form"
|
"hotgo/internal/model/input/form"
|
||||||
"hotgo/internal/model/input/sysin"
|
"hotgo/internal/model/input/sysin"
|
||||||
"hotgo/internal/service"
|
"hotgo/internal/service"
|
||||||
@ -23,6 +24,9 @@ import (
|
|||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
"github.com/gogf/gf/v2/os/gctx"
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
"github.com/gogf/gf/v2/util/gconv"
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
|
|
||||||
|
"hotgo/internal/library/dict"
|
||||||
|
"hotgo/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sSysLesson struct{}
|
type sSysLesson struct{}
|
||||||
@ -33,6 +37,7 @@ func NewSysLesson() *sSysLesson {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
service.RegisterSysLesson(NewSysLesson())
|
service.RegisterSysLesson(NewSysLesson())
|
||||||
|
dict.RegisterFunc("lessonOption", "课程管理选项", service.SysLesson().Option)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Model 课程管理ORM模型
|
// Model 课程管理ORM模型
|
||||||
@ -141,4 +146,20 @@ func (s *sSysLesson) View(ctx context.Context, in *sysin.LessonViewInp) (res *sy
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Option 获取课程管理选项
|
||||||
|
func (s *sSysLesson) Option(ctx context.Context) (opts []*model.Option, err error) {
|
||||||
|
var models []*entity.Lesson
|
||||||
|
if err = s.Model(ctx).Fields(dao.Lesson.Columns().Id, dao.Lesson.Columns().Name).
|
||||||
|
OrderDesc(dao.Lesson.Columns().Id).Scan(&models); err != nil {
|
||||||
|
err = gerror.Wrap(err, "获取课程管理选项失败!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
opts = make([]*model.Option, len(models))
|
||||||
|
for k, v := range models {
|
||||||
|
opts[k] = dict.GenHashOption(v.Id, gconv.String(v.Name))
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
143
server/internal/logic/sys/lesson_section.go
Normal file
143
server/internal/logic/sys/lesson_section.go
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
// 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"
|
||||||
|
"fmt"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"hotgo/internal/library/contexts"
|
||||||
|
"hotgo/internal/library/hgorm/handler"
|
||||||
|
"hotgo/internal/library/hgorm/hook"
|
||||||
|
"hotgo/internal/model/input/form"
|
||||||
|
"hotgo/internal/model/input/sysin"
|
||||||
|
"hotgo/internal/service"
|
||||||
|
"hotgo/utility/convert"
|
||||||
|
"hotgo/utility/excel"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type sSysLessonSection struct{}
|
||||||
|
|
||||||
|
func NewSysLessonSection() *sSysLessonSection {
|
||||||
|
return &sSysLessonSection{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
service.RegisterSysLessonSection(NewSysLessonSection())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model 课程章节ORM模型
|
||||||
|
func (s *sSysLessonSection) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
|
||||||
|
return handler.Model(dao.LessonSection.Ctx(ctx), option...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List 获取课程章节列表
|
||||||
|
func (s *sSysLessonSection) List(ctx context.Context, in *sysin.LessonSectionListInp) (list []*sysin.LessonSectionListModel, totalCount int, err error) {
|
||||||
|
mod := s.Model(ctx)
|
||||||
|
|
||||||
|
// 字段过滤
|
||||||
|
mod = mod.Fields(sysin.LessonSectionListModel{})
|
||||||
|
|
||||||
|
// 查询id
|
||||||
|
if in.Id > 0 {
|
||||||
|
mod = mod.Where(dao.LessonSection.Columns().Id, in.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
mod = mod.Page(in.Page, in.PerPage)
|
||||||
|
|
||||||
|
// 排序
|
||||||
|
mod = mod.OrderDesc(dao.LessonSection.Columns().Id)
|
||||||
|
|
||||||
|
// 操作人摘要信息
|
||||||
|
mod = mod.Hook(hook.MemberSummary)
|
||||||
|
|
||||||
|
// 查询数据
|
||||||
|
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
|
||||||
|
err = gerror.Wrap(err, "获取课程章节列表失败,请稍后重试!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export 导出课程章节
|
||||||
|
func (s *sSysLessonSection) Export(ctx context.Context, in *sysin.LessonSectionListInp) (err error) {
|
||||||
|
list, totalCount, err := s.List(ctx, in)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
|
||||||
|
tags, err := convert.GetEntityDescTags(sysin.LessonSectionExportModel{})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
fileName = "导出课程章节-" + gctx.CtxId(ctx)
|
||||||
|
sheetName = fmt.Sprintf("索引条件共%v行,共%v页,当前导出是第%v页,本页共%v行", totalCount, form.CalPageCount(totalCount, in.PerPage), in.Page, len(list))
|
||||||
|
exports []sysin.LessonSectionExportModel
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = gconv.Scan(list, &exports); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit 修改/新增课程章节
|
||||||
|
func (s *sSysLessonSection) Edit(ctx context.Context, in *sysin.LessonSectionEditInp) (err error) {
|
||||||
|
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
if in.Id > 0 {
|
||||||
|
in.UpdatedBy = contexts.GetUserId(ctx)
|
||||||
|
if _, err = s.Model(ctx).
|
||||||
|
Fields(sysin.LessonSectionUpdateFields{}).
|
||||||
|
WherePri(in.Id).Data(in).Update(); err != nil {
|
||||||
|
err = gerror.Wrap(err, "修改课程章节失败,请稍后重试!")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
in.CreatedBy = contexts.GetUserId(ctx)
|
||||||
|
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).
|
||||||
|
Fields(sysin.LessonSectionInsertFields{}).
|
||||||
|
Data(in).OmitEmptyData().Insert(); err != nil {
|
||||||
|
err = gerror.Wrap(err, "新增课程章节失败,请稍后重试!")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete 删除课程章节
|
||||||
|
func (s *sSysLessonSection) Delete(ctx context.Context, in *sysin.LessonSectionDeleteInp) (err error) {
|
||||||
|
|
||||||
|
if _, err = s.Model(ctx).WherePri(in.Id).Unscoped().Delete(); err != nil {
|
||||||
|
err = gerror.Wrap(err, "删除课程章节失败,请稍后重试!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// View 获取课程章节指定信息
|
||||||
|
func (s *sSysLessonSection) View(ctx context.Context, in *sysin.LessonSectionViewInp) (res *sysin.LessonSectionViewModel, err error) {
|
||||||
|
if err = s.Model(ctx).WherePri(in.Id).Hook(hook.MemberSummary).Scan(&res); err != nil {
|
||||||
|
err = gerror.Wrap(err, "获取课程章节信息,请稍后重试!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
27
server/internal/model/do/lesson_section.go
Executable file
27
server/internal/model/do/lesson_section.go
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package do
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LessonSection is the golang structure of table hg_lesson_section for DAO operations like Where/Data.
|
||||||
|
type LessonSection struct {
|
||||||
|
g.Meta `orm:"table:hg_lesson_section, do:true"`
|
||||||
|
Id interface{} // id
|
||||||
|
LessonId interface{} // 课程id
|
||||||
|
VideoUrl interface{} // 视频url
|
||||||
|
Name interface{} // 章节名
|
||||||
|
SortOrder interface{} // 排序号
|
||||||
|
ParentId interface{} // 父章节id
|
||||||
|
Level interface{} // 章节层级;1=章,2=节
|
||||||
|
Revision interface{} // 乐观锁
|
||||||
|
CreatedBy interface{} // 创建人
|
||||||
|
CreatedTime *gtime.Time // 创建时间
|
||||||
|
UpdatedBy interface{} // 更新人
|
||||||
|
UpdatedTime *gtime.Time // 更新时间
|
||||||
|
}
|
@ -24,7 +24,7 @@ type Lesson struct {
|
|||||||
Arrangement string `json:"arrangement" orm:"arrangement" description:"学时安排"`
|
Arrangement string `json:"arrangement" orm:"arrangement" description:"学时安排"`
|
||||||
StartTime *gtime.Time `json:"startTime" orm:"start_time" description:"开课时间"`
|
StartTime *gtime.Time `json:"startTime" orm:"start_time" description:"开课时间"`
|
||||||
EndTime *gtime.Time `json:"endTime" orm:"end_time" description:"结课时间"`
|
EndTime *gtime.Time `json:"endTime" orm:"end_time" description:"结课时间"`
|
||||||
Revision int64 `json:"revision" orm:"revision" description:"乐观锁"`
|
Revision int `json:"revision" orm:"revision" description:"乐观锁"`
|
||||||
Question string `json:"question" orm:"question" description:"常见问题"`
|
Question string `json:"question" orm:"question" description:"常见问题"`
|
||||||
CreatedBy int64 `json:"createdBy" orm:"created_by" description:"创建人"`
|
CreatedBy int64 `json:"createdBy" orm:"created_by" description:"创建人"`
|
||||||
CreatedTime *gtime.Time `json:"createdTime" orm:"created_time" description:"创建时间"`
|
CreatedTime *gtime.Time `json:"createdTime" orm:"created_time" description:"创建时间"`
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
type LessonCategory struct {
|
type LessonCategory struct {
|
||||||
Id int64 `json:"id" orm:"id" description:"id"`
|
Id int64 `json:"id" orm:"id" description:"id"`
|
||||||
Name string `json:"name" orm:"name" description:"分类名"`
|
Name string `json:"name" orm:"name" description:"分类名"`
|
||||||
SortOrder int64 `json:"sortOrder" orm:"sort_order" description:"排序"`
|
SortOrder int `json:"sortOrder" orm:"sort_order" description:"排序"`
|
||||||
Revision int64 `json:"revision" orm:"revision" description:"乐观锁"`
|
Revision int `json:"revision" orm:"revision" description:"乐观锁"`
|
||||||
CreatedBy int64 `json:"createdBy" orm:"created_by" description:"创建人"`
|
CreatedBy int64 `json:"createdBy" orm:"created_by" description:"创建人"`
|
||||||
CreatedTime *gtime.Time `json:"createdTime" orm:"created_time" description:"创建时间"`
|
CreatedTime *gtime.Time `json:"createdTime" orm:"created_time" description:"创建时间"`
|
||||||
UpdatedBy int64 `json:"updatedBy" orm:"updated_by" description:"更新人"`
|
UpdatedBy int64 `json:"updatedBy" orm:"updated_by" description:"更新人"`
|
||||||
|
25
server/internal/model/entity/lesson_section.go
Executable file
25
server/internal/model/entity/lesson_section.go
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LessonSection is the golang structure for table lesson_section.
|
||||||
|
type LessonSection struct {
|
||||||
|
Id int64 `json:"id" orm:"id" description:"id"`
|
||||||
|
LessonId int64 `json:"lessonId" orm:"lesson_id" description:"课程id"`
|
||||||
|
VideoUrl string `json:"videoUrl" orm:"video_url" description:"视频url"`
|
||||||
|
Name string `json:"name" orm:"name" description:"章节名"`
|
||||||
|
SortOrder int `json:"sortOrder" orm:"sort_order" description:"排序号"`
|
||||||
|
ParentId int `json:"parentId" orm:"parent_id" description:"父章节id"`
|
||||||
|
Level int `json:"level" orm:"level" description:"章节层级;1=章,2=节"`
|
||||||
|
Revision int `json:"revision" orm:"revision" description:"乐观锁"`
|
||||||
|
CreatedBy int64 `json:"createdBy" orm:"created_by" description:"创建人"`
|
||||||
|
CreatedTime *gtime.Time `json:"createdTime" orm:"created_time" description:"创建时间"`
|
||||||
|
UpdatedBy int64 `json:"updatedBy" orm:"updated_by" description:"更新人"`
|
||||||
|
UpdatedTime *gtime.Time `json:"updatedTime" orm:"updated_time" description:"更新时间"`
|
||||||
|
}
|
@ -19,15 +19,15 @@ type Users struct {
|
|||||||
Password string `json:"password" orm:"password" description:"密码"`
|
Password string `json:"password" orm:"password" description:"密码"`
|
||||||
Salt string `json:"salt" orm:"salt" description:"密码盐"`
|
Salt string `json:"salt" orm:"salt" description:"密码盐"`
|
||||||
Realname string `json:"realname" orm:"realname" description:"真实姓名"`
|
Realname string `json:"realname" orm:"realname" description:"真实姓名"`
|
||||||
Gender int64 `json:"gender" orm:"gender" description:"性别"`
|
Gender int `json:"gender" orm:"gender" description:"性别"`
|
||||||
Birthday string `json:"birthday" orm:"birthday" description:"生日"`
|
Birthday string `json:"birthday" orm:"birthday" description:"生日"`
|
||||||
School string `json:"school" orm:"school" description:"学校"`
|
School string `json:"school" orm:"school" description:"学校"`
|
||||||
Grade string `json:"grade" orm:"grade" description:"学历"`
|
Grade string `json:"grade" orm:"grade" description:"学历"`
|
||||||
Major string `json:"major" orm:"major" description:"专业"`
|
Major string `json:"major" orm:"major" description:"专业"`
|
||||||
Status int64 `json:"status" orm:"status" description:"用户状态"`
|
Status int `json:"status" orm:"status" description:"用户状态"`
|
||||||
VerificationToken string `json:"verificationToken" orm:"verification_token" description:"邮箱验证令牌"`
|
VerificationToken string `json:"verificationToken" orm:"verification_token" description:"邮箱验证令牌"`
|
||||||
EmailVerified int64 `json:"emailVerified" orm:"email_verified" description:"邮箱验证状态"`
|
EmailVerified int `json:"emailVerified" orm:"email_verified" description:"邮箱验证状态"`
|
||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"注册时间"`
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"注册时间"`
|
||||||
LastLogin *gtime.Time `json:"lastLogin" orm:"last_login" description:"最后登录时间"`
|
LastLogin *gtime.Time `json:"lastLogin" orm:"last_login" description:"最后登录时间"`
|
||||||
LoginCount int64 `json:"loginCount" orm:"login_count" description:"累计登录次数"`
|
LoginCount int `json:"loginCount" orm:"login_count" description:"累计登录次数"`
|
||||||
}
|
}
|
||||||
|
111
server/internal/model/input/sysin/lesson_section.go
Normal file
111
server/internal/model/input/sysin/lesson_section.go
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// Package sysin
|
||||||
|
// @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 sysin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"hotgo/internal/library/hgorm/hook"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
"hotgo/internal/model/input/form"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LessonSectionUpdateFields 修改课程章节字段过滤
|
||||||
|
type LessonSectionUpdateFields struct {
|
||||||
|
LessonId int64 `json:"lessonId" dc:"课程id"`
|
||||||
|
VideoUrl string `json:"videoUrl" dc:"视频url"`
|
||||||
|
Name string `json:"name" dc:"章节名"`
|
||||||
|
SortOrder int `json:"sortOrder" dc:"排序号"`
|
||||||
|
ParentId int `json:"parentId" dc:"父章节id"`
|
||||||
|
Level int `json:"level" dc:"章节层级"`
|
||||||
|
UpdatedBy int64 `json:"updatedBy" dc:"更新人"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LessonSectionInsertFields 新增课程章节字段过滤
|
||||||
|
type LessonSectionInsertFields struct {
|
||||||
|
LessonId int64 `json:"lessonId" dc:"课程id"`
|
||||||
|
VideoUrl string `json:"videoUrl" dc:"视频url"`
|
||||||
|
Name string `json:"name" dc:"章节名"`
|
||||||
|
SortOrder int `json:"sortOrder" dc:"排序号"`
|
||||||
|
ParentId int `json:"parentId" dc:"父章节id"`
|
||||||
|
Level int `json:"level" dc:"章节层级"`
|
||||||
|
CreatedBy int64 `json:"createdBy" dc:"创建人"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LessonSectionEditInp 修改/新增课程章节
|
||||||
|
type LessonSectionEditInp struct {
|
||||||
|
entity.LessonSection
|
||||||
|
}
|
||||||
|
|
||||||
|
func (in *LessonSectionEditInp) Filter(ctx context.Context) (err error) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type LessonSectionEditModel struct{}
|
||||||
|
|
||||||
|
// LessonSectionDeleteInp 删除课程章节
|
||||||
|
type LessonSectionDeleteInp struct {
|
||||||
|
Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (in *LessonSectionDeleteInp) Filter(ctx context.Context) (err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type LessonSectionDeleteModel struct{}
|
||||||
|
|
||||||
|
// LessonSectionViewInp 获取指定课程章节信息
|
||||||
|
type LessonSectionViewInp struct {
|
||||||
|
Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (in *LessonSectionViewInp) Filter(ctx context.Context) (err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type LessonSectionViewModel struct {
|
||||||
|
entity.LessonSection
|
||||||
|
CreatedBySumma *hook.MemberSumma `json:"createdBySumma" dc:"创建人摘要信息"`
|
||||||
|
UpdatedBySumma *hook.MemberSumma `json:"updatedBySumma" dc:"更新人摘要信息"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LessonSectionListInp 获取课程章节列表
|
||||||
|
type LessonSectionListInp struct {
|
||||||
|
form.PageReq
|
||||||
|
Id int64 `json:"id" dc:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (in *LessonSectionListInp) Filter(ctx context.Context) (err error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
type LessonSectionListModel struct {
|
||||||
|
Id int64 `json:"id" dc:"id"`
|
||||||
|
LessonId int64 `json:"lessonId" dc:"课程id"`
|
||||||
|
VideoUrl string `json:"videoUrl" dc:"视频url"`
|
||||||
|
Name string `json:"name" dc:"章节名"`
|
||||||
|
SortOrder int `json:"sortOrder" dc:"排序号"`
|
||||||
|
ParentId int `json:"parentId" dc:"父章节id"`
|
||||||
|
Level int `json:"level" dc:"章节层级"`
|
||||||
|
CreatedBy int64 `json:"createdBy" dc:"创建人"`
|
||||||
|
CreatedBySumma *hook.MemberSumma `json:"createdBySumma" dc:"创建人摘要信息"`
|
||||||
|
UpdatedBy int64 `json:"updatedBy" dc:"更新人"`
|
||||||
|
UpdatedBySumma *hook.MemberSumma `json:"updatedBySumma" dc:"更新人摘要信息"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LessonSectionExportModel 导出课程章节
|
||||||
|
type LessonSectionExportModel struct {
|
||||||
|
Id int64 `json:"id" dc:"id"`
|
||||||
|
LessonId int64 `json:"lessonId" dc:"课程id"`
|
||||||
|
VideoUrl string `json:"videoUrl" dc:"视频url"`
|
||||||
|
Name string `json:"name" dc:"章节名"`
|
||||||
|
SortOrder int `json:"sortOrder" dc:"排序号"`
|
||||||
|
ParentId int `json:"parentId" dc:"父章节id"`
|
||||||
|
Level int `json:"level" dc:"章节层级"`
|
||||||
|
CreatedBy int64 `json:"createdBy" dc:"创建人"`
|
||||||
|
UpdatedBy int64 `json:"updatedBy" dc:"更新人"`
|
||||||
|
}
|
@ -8,6 +8,7 @@ package router
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"hotgo/internal/consts"
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/controller/api/lesson"
|
||||||
"hotgo/internal/controller/api/member"
|
"hotgo/internal/controller/api/member"
|
||||||
"hotgo/internal/controller/api/pay"
|
"hotgo/internal/controller/api/pay"
|
||||||
"hotgo/internal/controller/api/users"
|
"hotgo/internal/controller/api/users"
|
||||||
@ -31,7 +32,8 @@ func Api(ctx context.Context, group *ghttp.RouterGroup) {
|
|||||||
|
|
||||||
group.Group(simple.RouterPrefix(ctx, consts.AppApi), func(group *ghttp.RouterGroup) {
|
group.Group(simple.RouterPrefix(ctx, consts.AppApi), func(group *ghttp.RouterGroup) {
|
||||||
group.Bind(
|
group.Bind(
|
||||||
users.NewV1(), // 前台用户
|
users.NewV1(), // 前台用户
|
||||||
|
lesson.NewV1(), // 课程
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
13
server/internal/router/genrouter/lesson_section.go
Normal file
13
server/internal/router/genrouter/lesson_section.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Package genrouter
|
||||||
|
// @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 genrouter
|
||||||
|
|
||||||
|
import "hotgo/internal/controller/admin/sys"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
LoginRequiredRouter = append(LoginRequiredRouter, sys.LessonSection) // 课程章节
|
||||||
|
}
|
@ -260,6 +260,8 @@ type (
|
|||||||
Delete(ctx context.Context, in *sysin.LessonDeleteInp) (err error)
|
Delete(ctx context.Context, in *sysin.LessonDeleteInp) (err error)
|
||||||
// View 获取课程管理指定信息
|
// View 获取课程管理指定信息
|
||||||
View(ctx context.Context, in *sysin.LessonViewInp) (res *sysin.LessonViewModel, err error)
|
View(ctx context.Context, in *sysin.LessonViewInp) (res *sysin.LessonViewModel, err error)
|
||||||
|
// Option 获取课程管理选项
|
||||||
|
Option(ctx context.Context) (opts []*model.Option, err error)
|
||||||
}
|
}
|
||||||
ISysLessonCategory interface {
|
ISysLessonCategory interface {
|
||||||
// Model 课程分类ORM模型
|
// Model 课程分类ORM模型
|
||||||
@ -277,6 +279,20 @@ type (
|
|||||||
// Option 获取课程分类选项
|
// Option 获取课程分类选项
|
||||||
Option(ctx context.Context) (opts []*model.Option, err error)
|
Option(ctx context.Context) (opts []*model.Option, err error)
|
||||||
}
|
}
|
||||||
|
ISysLessonSection interface {
|
||||||
|
// Model 课程章节ORM模型
|
||||||
|
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||||
|
// List 获取课程章节列表
|
||||||
|
List(ctx context.Context, in *sysin.LessonSectionListInp) (list []*sysin.LessonSectionListModel, totalCount int, err error)
|
||||||
|
// Export 导出课程章节
|
||||||
|
Export(ctx context.Context, in *sysin.LessonSectionListInp) (err error)
|
||||||
|
// Edit 修改/新增课程章节
|
||||||
|
Edit(ctx context.Context, in *sysin.LessonSectionEditInp) (err error)
|
||||||
|
// Delete 删除课程章节
|
||||||
|
Delete(ctx context.Context, in *sysin.LessonSectionDeleteInp) (err error)
|
||||||
|
// View 获取课程章节指定信息
|
||||||
|
View(ctx context.Context, in *sysin.LessonSectionViewInp) (res *sysin.LessonSectionViewModel, err error)
|
||||||
|
}
|
||||||
ISysLog interface {
|
ISysLog interface {
|
||||||
// Model 请求日志Orm模型
|
// Model 请求日志Orm模型
|
||||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||||
@ -466,6 +482,7 @@ var (
|
|||||||
localSysGenCodes ISysGenCodes
|
localSysGenCodes ISysGenCodes
|
||||||
localSysLesson ISysLesson
|
localSysLesson ISysLesson
|
||||||
localSysLessonCategory ISysLessonCategory
|
localSysLessonCategory ISysLessonCategory
|
||||||
|
localSysLessonSection ISysLessonSection
|
||||||
localSysLog ISysLog
|
localSysLog ISysLog
|
||||||
localSysLoginLog ISysLoginLog
|
localSysLoginLog ISysLoginLog
|
||||||
localSysNormalTreeDemo ISysNormalTreeDemo
|
localSysNormalTreeDemo ISysNormalTreeDemo
|
||||||
@ -632,6 +649,17 @@ func RegisterSysLessonCategory(i ISysLessonCategory) {
|
|||||||
localSysLessonCategory = i
|
localSysLessonCategory = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SysLessonSection() ISysLessonSection {
|
||||||
|
if localSysLessonSection == nil {
|
||||||
|
panic("implement not found for interface ISysLessonSection, forgot register?")
|
||||||
|
}
|
||||||
|
return localSysLessonSection
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterSysLessonSection(i ISysLessonSection) {
|
||||||
|
localSysLessonSection = i
|
||||||
|
}
|
||||||
|
|
||||||
func SysLog() ISysLog {
|
func SysLog() ISysLog {
|
||||||
if localSysLog == nil {
|
if localSysLog == nil {
|
||||||
panic("implement not found for interface ISysLog, forgot register?")
|
panic("implement not found for interface ISysLog, forgot register?")
|
||||||
|
62
server/storage/data/generate/lesson_section_menu.sql
Normal file
62
server/storage/data/generate/lesson_section_menu.sql
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
-- hotgo自动生成菜单权限SQL 通常情况下只在首次生成代码时自动执行一次
|
||||||
|
-- 如需再次执行请先手动删除生成的菜单权限和SQL文件:/Users/guochen/Documents/projects/g031/hotgo/server/storage/data/generate/lesson_section_menu.sql
|
||||||
|
-- Version: 2.17.8
|
||||||
|
-- Date: 2025-07-25 16:32:05
|
||||||
|
-- Link https://github.com/bufanyun/hotgo
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
SET AUTOCOMMIT = 0;
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 数据库: `hotgo`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 插入表中的数据 `hg_admin_menu`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
SET @now := now();
|
||||||
|
|
||||||
|
|
||||||
|
-- 菜单目录
|
||||||
|
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) VALUES (NULL, '0', '课程章节', 'lessonSection', '/lessonSection', 'MenuOutlined', '1', '/lessonSection/index', '', '', 'LAYOUT', '1', '', '0', '0', '', '0', '0', '0', '1', '', '0', '', '1', @now, @now);
|
||||||
|
|
||||||
|
|
||||||
|
SET @dirId = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
|
||||||
|
-- 菜单页面
|
||||||
|
-- 列表
|
||||||
|
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) VALUES (NULL, @dirId, '课程章节列表', 'lessonSectionIndex', 'index', '', '2', '', '/lessonSection/list', '', '/lessonSection/index', '1', 'lessonSection', '0', '0', '', '0', '1', '0', '2', CONCAT('tr_', @dirId,' '), '10', '', '1', @now, @now);
|
||||||
|
|
||||||
|
|
||||||
|
SET @listId = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
-- 详情
|
||||||
|
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) VALUES (NULL, @listId, '课程章节详情', 'lessonSectionView', '', '', '3', '', '/lessonSection/view', '', '', '1', '', '0', '0', '', '0', '1', '0', '3', CONCAT('tr_', @dirId, ' tr_', @listId,' '), '10', '', '1', @now, @now);
|
||||||
|
|
||||||
|
|
||||||
|
-- 菜单按钮
|
||||||
|
|
||||||
|
-- 编辑
|
||||||
|
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) VALUES (NULL, @listId, '编辑/新增课程章节', 'lessonSectionEdit', '', '', '3', '', '/lessonSection/edit', '', '', '1', '', '0', '0', '', '0', '1', '0', '3', CONCAT('tr_', @dirId, ' tr_', @listId,' '), '20', '', '1', @now, @now);
|
||||||
|
|
||||||
|
|
||||||
|
SET @editId = LAST_INSERT_ID();
|
||||||
|
|
||||||
|
|
||||||
|
-- 删除
|
||||||
|
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) VALUES (NULL, @listId, '删除课程章节', 'lessonSectionDelete', '', '', '3', '', '/lessonSection/delete', '', '', '1', '', '0', '0', '', '0', '0', '0', '3', CONCAT('tr_', @dirId, ' tr_', @listId,' '), '40', '', '1', @now, @now);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 导出
|
||||||
|
INSERT INTO `hg_admin_menu` (`id`, `pid`, `title`, `name`, `path`, `icon`, `type`, `redirect`, `permissions`, `permission_name`, `component`, `always_show`, `active_menu`, `is_root`, `is_frame`, `frame_src`, `keep_alive`, `hidden`, `affix`, `level`, `tree`, `sort`, `remark`, `status`, `created_at`, `updated_at`) VALUES (NULL, @listId, '导出课程章节', 'lessonSectionExport', '', '', '3', '', '/lessonSection/export', '', '', '1', '', '0', '0', '', '0', '0', '0', '3', CONCAT('tr_', @dirId, ' tr_', @listId,' '), '70', '', '1', @now, @now);
|
||||||
|
|
||||||
|
|
||||||
|
COMMIT;
|
42
web/src/api/lessonSection/index.ts
Normal file
42
web/src/api/lessonSection/index.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { http, jumpExport } from '@/utils/http/axios';
|
||||||
|
|
||||||
|
// 获取课程章节列表
|
||||||
|
export function List(params) {
|
||||||
|
return http.request({
|
||||||
|
url: '/lessonSection/list',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除/批量删除课程章节
|
||||||
|
export function Delete(params) {
|
||||||
|
return http.request({
|
||||||
|
url: '/lessonSection/delete',
|
||||||
|
method: 'POST',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加/编辑课程章节
|
||||||
|
export function Edit(params) {
|
||||||
|
return http.request({
|
||||||
|
url: '/lessonSection/edit',
|
||||||
|
method: 'POST',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取课程章节指定详情
|
||||||
|
export function View(params) {
|
||||||
|
return http.request({
|
||||||
|
url: '/lessonSection/view',
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出课程章节
|
||||||
|
export function Export(params) {
|
||||||
|
jumpExport('/lessonSection/export', params);
|
||||||
|
}
|
148
web/src/views/lessonSection/edit.vue
Normal file
148
web/src/views/lessonSection/edit.vue
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<n-modal
|
||||||
|
v-model:show="showModal"
|
||||||
|
:mask-closable="false"
|
||||||
|
:show-icon="false"
|
||||||
|
preset="dialog"
|
||||||
|
transform-origin="center"
|
||||||
|
:title="formValue.id > 0 ? '编辑课程章节 #' + formValue.id : '添加课程章节'"
|
||||||
|
:style="{
|
||||||
|
width: dialogWidth,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<n-scrollbar style="max-height: 87vh" class="pr-5">
|
||||||
|
<n-spin :show="loading" description="请稍候...">
|
||||||
|
<n-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formValue"
|
||||||
|
:label-placement="settingStore.isMobile ? 'top' : 'left'"
|
||||||
|
:label-width="100"
|
||||||
|
class="py-4"
|
||||||
|
>
|
||||||
|
<n-grid cols="1 s:1 m:1 l:1 xl:1 2xl:1" responsive="screen">
|
||||||
|
<n-gi span="1">
|
||||||
|
<n-form-item label="课程id" path="lessonId">
|
||||||
|
<n-select v-model:value="formValue.lessonId" :options="dict.getOptionUnRef('lessonOption')" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="1">
|
||||||
|
<n-form-item label="视频url" path="videoUrl">
|
||||||
|
<n-input placeholder="请输入视频url" v-model:value="formValue.videoUrl" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="1">
|
||||||
|
<n-form-item label="章节名" path="name">
|
||||||
|
<n-input placeholder="请输入章节名" v-model:value="formValue.name" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="1">
|
||||||
|
<n-form-item label="排序号" path="sortOrder">
|
||||||
|
<n-input-number placeholder="请输入排序号" v-model:value="formValue.sortOrder" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="1">
|
||||||
|
<n-form-item label="父章节id" path="parentId">
|
||||||
|
<n-input-number placeholder="请输入父章节id" v-model:value="formValue.parentId" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi span="1">
|
||||||
|
<n-form-item label="章节层级" path="level">
|
||||||
|
<n-input-number placeholder="请输入章节层级" v-model:value="formValue.level" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
</n-form>
|
||||||
|
</n-spin>
|
||||||
|
</n-scrollbar>
|
||||||
|
<template #action>
|
||||||
|
<n-space>
|
||||||
|
<n-button @click="closeForm">
|
||||||
|
取消
|
||||||
|
</n-button>
|
||||||
|
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">
|
||||||
|
确定
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import { useDictStore } from '@/store/modules/dict';
|
||||||
|
import { Edit, View } from '@/api/lessonSection';
|
||||||
|
import { State, newState } from './model';
|
||||||
|
import { useProjectSettingStore } from '@/store/modules/projectSetting';
|
||||||
|
import { useMessage } from 'naive-ui';
|
||||||
|
import { adaModalWidth } from '@/utils/hotgo';
|
||||||
|
|
||||||
|
const emit = defineEmits(['reloadTable']);
|
||||||
|
const message = useMessage();
|
||||||
|
const settingStore = useProjectSettingStore();
|
||||||
|
const dict = useDictStore();
|
||||||
|
const loading = ref(false);
|
||||||
|
const showModal = ref(false);
|
||||||
|
const formValue = ref<State>(newState(null));
|
||||||
|
const formRef = ref<any>({});
|
||||||
|
const formBtnLoading = ref(false);
|
||||||
|
const dialogWidth = computed(() => {
|
||||||
|
return adaModalWidth(840);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
function confirmForm(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
formRef.value.validate((errors) => {
|
||||||
|
if (!errors) {
|
||||||
|
formBtnLoading.value = true;
|
||||||
|
Edit(formValue.value)
|
||||||
|
.then((_res) => {
|
||||||
|
message.success('操作成功');
|
||||||
|
closeForm();
|
||||||
|
emit('reloadTable');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
formBtnLoading.value = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
message.error('请填写完整信息');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭表单
|
||||||
|
function closeForm() {
|
||||||
|
showModal.value = false;
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开模态框
|
||||||
|
function openModal(state: State) {
|
||||||
|
showModal.value = true;
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
if (!state || state.id < 1) {
|
||||||
|
formValue.value = newState(state);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
loading.value = true;
|
||||||
|
View({ id: state.id })
|
||||||
|
.then((res) => {
|
||||||
|
formValue.value = res;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openModal,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less"></style>
|
199
web/src/views/lessonSection/index.vue
Normal file
199
web/src/views/lessonSection/index.vue
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="n-layout-page-header">
|
||||||
|
<n-card :bordered="false" title="课程章节">
|
||||||
|
<!-- 这是由系统生成的CURD表格,你可以将此行注释改为表格的描述 -->
|
||||||
|
</n-card>
|
||||||
|
</div>
|
||||||
|
<n-card :bordered="false" class="proCard">
|
||||||
|
<BasicForm ref="searchFormRef" @register="register" @submit="reloadTable" @reset="reloadTable" @keyup.enter="reloadTable">
|
||||||
|
<template #statusSlot="{ model, field }">
|
||||||
|
<n-input v-model:value="model[field]" />
|
||||||
|
</template>
|
||||||
|
</BasicForm>
|
||||||
|
<BasicTable ref="actionRef" openChecked :columns="columns" :request="loadDataTable" :row-key="(row) => row.id" :actionColumn="actionColumn" :scroll-x="scrollX" :resizeHeightOffset="-10000" :checked-row-keys="checkedIds" @update:checked-row-keys="handleOnCheckedRow">
|
||||||
|
<template #tableTitle>
|
||||||
|
<n-button type="primary" @click="addTable" class="min-left-space" v-if="hasPermission(['/lessonSection/edit'])">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<PlusOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
添加
|
||||||
|
</n-button>
|
||||||
|
<n-button type="error" @click="handleBatchDelete" class="min-left-space" v-if="hasPermission(['/lessonSection/delete'])">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<DeleteOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
批量删除
|
||||||
|
</n-button>
|
||||||
|
<n-button type="primary" @click="handleExport" class="min-left-space" v-if="hasPermission(['/lessonSection/export'])">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<ExportOutlined />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
导出
|
||||||
|
</n-button>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
</n-card>
|
||||||
|
<Edit ref="editRef" @reloadTable="reloadTable" />
|
||||||
|
<View ref="viewRef" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { h, reactive, ref, computed, onMounted } from 'vue';
|
||||||
|
import { useDialog, useMessage } from 'naive-ui';
|
||||||
|
import { BasicTable, TableAction } from '@/components/Table';
|
||||||
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
|
import { usePermission } from '@/hooks/web/usePermission';
|
||||||
|
import { useDictStore } from '@/store/modules/dict';
|
||||||
|
import { List, Export, Delete } from '@/api/lessonSection';
|
||||||
|
import { PlusOutlined, ExportOutlined, DeleteOutlined } from '@vicons/antd';
|
||||||
|
import { columns, schemas, loadOptions } from './model';
|
||||||
|
import { adaTableScrollX } from '@/utils/hotgo';
|
||||||
|
import Edit from './edit.vue';
|
||||||
|
import View from './view.vue';
|
||||||
|
|
||||||
|
const dict = useDictStore();
|
||||||
|
const dialog = useDialog();
|
||||||
|
const message = useMessage();
|
||||||
|
const { hasPermission } = usePermission();
|
||||||
|
const actionRef = ref();
|
||||||
|
const searchFormRef = ref<any>({});
|
||||||
|
const editRef = ref();
|
||||||
|
const viewRef = ref();
|
||||||
|
const checkedIds = ref([]);
|
||||||
|
|
||||||
|
const actionColumn = reactive({
|
||||||
|
width: 216,
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
render(record: State) {
|
||||||
|
return h(TableAction as any, {
|
||||||
|
style: 'button',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
auth: ['/lessonSection/edit'],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
onClick: handleDelete.bind(null, record),
|
||||||
|
auth: ['/lessonSection/delete'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dropDownActions: [
|
||||||
|
{
|
||||||
|
label: '查看详情',
|
||||||
|
key: 'view',
|
||||||
|
auth: ['/lessonSection/view'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
select: (key) => {
|
||||||
|
if (key === 'view') {
|
||||||
|
return handleView(record);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const scrollX = computed(() => {
|
||||||
|
return adaTableScrollX(columns, actionColumn.width);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [register, {}] = useForm({
|
||||||
|
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
||||||
|
labelWidth: 80,
|
||||||
|
schemas,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 加载表格数据
|
||||||
|
const loadDataTable = async (res) => {
|
||||||
|
return await List({ ...searchFormRef.value?.formModel, ...res });
|
||||||
|
};
|
||||||
|
|
||||||
|
// 更新选中的行
|
||||||
|
function handleOnCheckedRow(rowKeys) {
|
||||||
|
checkedIds.value = rowKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新加载表格数据
|
||||||
|
function reloadTable() {
|
||||||
|
actionRef.value?.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加数据
|
||||||
|
function addTable() {
|
||||||
|
editRef.value.openModal(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑数据
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
editRef.value.openModal(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看详情
|
||||||
|
function handleView(record: Recordable) {
|
||||||
|
viewRef.value.openModal(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单个删除
|
||||||
|
function handleDelete(record: Recordable) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '警告',
|
||||||
|
content: '你确定要删除?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: () => {
|
||||||
|
Delete(record).then((_res) => {
|
||||||
|
message.success('删除成功');
|
||||||
|
reloadTable();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
if (checkedIds.value.length < 1){
|
||||||
|
message.error('请至少选择一项要删除的数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.warning({
|
||||||
|
title: '警告',
|
||||||
|
content: '你确定要批量删除?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: () => {
|
||||||
|
Delete({ id: checkedIds.value }).then((_res) => {
|
||||||
|
checkedIds.value = [];
|
||||||
|
message.success('删除成功');
|
||||||
|
reloadTable();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
function handleExport() {
|
||||||
|
message.loading('正在导出列表...', { duration: 1200 });
|
||||||
|
Export(searchFormRef.value?.formModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadOptions();
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
129
web/src/views/lessonSection/model.ts
Normal file
129
web/src/views/lessonSection/model.ts
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
import { h, ref } from 'vue';
|
||||||
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
import { FormSchema } from '@/components/Form';
|
||||||
|
import { renderOptionTag, renderPopoverMemberSumma, MemberSumma } from '@/utils';
|
||||||
|
import { useDictStore } from '@/store/modules/dict';
|
||||||
|
|
||||||
|
const dict = useDictStore();
|
||||||
|
|
||||||
|
export class State {
|
||||||
|
public id = 0; // id
|
||||||
|
public lessonId = null; // 课程id
|
||||||
|
public videoUrl = ''; // 视频url
|
||||||
|
public name = ''; // 章节名
|
||||||
|
public sortOrder = 0; // 排序号
|
||||||
|
public parentId = 0; // 父章节id
|
||||||
|
public level = 0; // 章节层级
|
||||||
|
public revision = 0; // 乐观锁
|
||||||
|
public createdBy = 0; // 创建人
|
||||||
|
public createdBySumma?: null | MemberSumma = null; // 创建人摘要信息
|
||||||
|
public createdTime = ''; // 创建时间
|
||||||
|
public updatedBy = 0; // 更新人
|
||||||
|
public updatedBySumma?: null | MemberSumma = null; // 更新人摘要信息
|
||||||
|
public updatedTime = ''; // 更新时间
|
||||||
|
|
||||||
|
constructor(state?: Partial<State>) {
|
||||||
|
if (state) {
|
||||||
|
Object.assign(this, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function newState(state: State | Record<string, any> | null): State {
|
||||||
|
if (state !== null) {
|
||||||
|
if (state instanceof State) {
|
||||||
|
return cloneDeep(state);
|
||||||
|
}
|
||||||
|
return new State(state);
|
||||||
|
}
|
||||||
|
return new State();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
|
||||||
|
// 表格搜索表单
|
||||||
|
export const schemas = ref<FormSchema[]>([
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
component: 'NInputNumber',
|
||||||
|
label: 'id',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入id',
|
||||||
|
onUpdateValue: (e: any) => {
|
||||||
|
console.log(e);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
export const columns = [
|
||||||
|
{
|
||||||
|
title: 'id',
|
||||||
|
key: 'id',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '课程id',
|
||||||
|
key: 'lessonId',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
render(row: State) {
|
||||||
|
return renderOptionTag('lessonOption', row.lessonId);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '视频url',
|
||||||
|
key: 'videoUrl',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '章节名',
|
||||||
|
key: 'name',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序号',
|
||||||
|
key: 'sortOrder',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '父章节id',
|
||||||
|
key: 'parentId',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '章节层级',
|
||||||
|
key: 'level',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建人',
|
||||||
|
key: 'createdBy',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
render(row: State) {
|
||||||
|
return renderPopoverMemberSumma(row.createdBySumma);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新人',
|
||||||
|
key: 'updatedBy',
|
||||||
|
align: 'left',
|
||||||
|
width: -1,
|
||||||
|
render(row: State) {
|
||||||
|
return renderPopoverMemberSumma(row.updatedBySumma);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 加载字典数据选项
|
||||||
|
export function loadOptions() {
|
||||||
|
dict.loadOptions(['lessonOption']);
|
||||||
|
}
|
96
web/src/views/lessonSection/view.vue
Normal file
96
web/src/views/lessonSection/view.vue
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<n-drawer v-model:show="showModal" :width="dialogWidth">
|
||||||
|
<n-drawer-content title="课程章节详情" closable>
|
||||||
|
<n-spin :show="loading" description="请稍候...">
|
||||||
|
<n-descriptions label-placement="left" class="py-2" :column="1">
|
||||||
|
<n-descriptions-item label="课程id">
|
||||||
|
<n-tag :type="dict.getType('lessonOption', formValue.lessonId)" size="small" class="min-left-space">
|
||||||
|
{{ dict.getLabel('lessonOption', formValue.lessonId) }}
|
||||||
|
</n-tag>
|
||||||
|
</n-descriptions-item>
|
||||||
|
<n-descriptions-item>
|
||||||
|
<template #label>
|
||||||
|
视频url
|
||||||
|
</template>
|
||||||
|
{{ formValue.videoUrl }}
|
||||||
|
</n-descriptions-item>
|
||||||
|
<n-descriptions-item>
|
||||||
|
<template #label>
|
||||||
|
章节名
|
||||||
|
</template>
|
||||||
|
{{ formValue.name }}
|
||||||
|
</n-descriptions-item>
|
||||||
|
<n-descriptions-item>
|
||||||
|
<template #label>
|
||||||
|
排序号
|
||||||
|
</template>
|
||||||
|
{{ formValue.sortOrder }}
|
||||||
|
</n-descriptions-item>
|
||||||
|
<n-descriptions-item>
|
||||||
|
<template #label>
|
||||||
|
父章节id
|
||||||
|
</template>
|
||||||
|
{{ formValue.parentId }}
|
||||||
|
</n-descriptions-item>
|
||||||
|
<n-descriptions-item>
|
||||||
|
<template #label>
|
||||||
|
章节层级
|
||||||
|
</template>
|
||||||
|
{{ formValue.level }}
|
||||||
|
</n-descriptions-item>
|
||||||
|
</n-descriptions>
|
||||||
|
</n-spin>
|
||||||
|
</n-drawer-content>
|
||||||
|
</n-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { useMessage } from 'naive-ui';
|
||||||
|
import { View } from '@/api/lessonSection';
|
||||||
|
import { State, newState } from './model';
|
||||||
|
import { adaModalWidth } from '@/utils/hotgo';
|
||||||
|
import { getFileExt } from '@/utils/urlUtils';
|
||||||
|
import { useDictStore } from '@/store/modules/dict';
|
||||||
|
|
||||||
|
const message = useMessage();
|
||||||
|
const dict = useDictStore();
|
||||||
|
const loading = ref(false);
|
||||||
|
const showModal = ref(false);
|
||||||
|
const formValue = ref(newState(null));
|
||||||
|
const dialogWidth = computed(() => {
|
||||||
|
return adaModalWidth(580);
|
||||||
|
});
|
||||||
|
const fileAvatarCSS = computed(() => {
|
||||||
|
return {
|
||||||
|
'--n-merged-size': `var(--n-avatar-size-override, 80px)`,
|
||||||
|
'--n-font-size': `18px`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// 下载
|
||||||
|
function download(url: string) {
|
||||||
|
window.open(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开模态框
|
||||||
|
function openModal(state: State) {
|
||||||
|
showModal.value = true;
|
||||||
|
loading.value = true;
|
||||||
|
View({ id: state.id })
|
||||||
|
.then((res) => {
|
||||||
|
formValue.value = res;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openModal,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
Loading…
x
Reference in New Issue
Block a user