75 lines
2.6 KiB
Go
75 lines
2.6 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"easygoadmin/api/v1"
|
|
"easygoadmin/internal/service"
|
|
)
|
|
|
|
// ============================== 案例演示控制器 ==============================
|
|
|
|
// CExample 案例演示控制器
|
|
// 薄层控制器,仅负责参数透传,业务逻辑由 service.Example() 处理
|
|
type CExample struct{}
|
|
|
|
// Page 案例演示分页
|
|
// 按查询条件分页返回案例演示列表
|
|
func (c *CExample) Page(ctx context.Context, req *v1.ExamplePageReq) (res *v1.ExamplePageRes, err error) {
|
|
return service.Example().Page(ctx, req)
|
|
}
|
|
|
|
// List 案例演示平铺列表
|
|
// data 直接为数组,树形结构由前端 buildTree 构建
|
|
func (c *CExample) List(ctx context.Context, req *v1.ExampleListReq) (res v1.ExampleListRes, err error) {
|
|
return service.Example().List(ctx, req)
|
|
}
|
|
|
|
// Detail 案例演示详情
|
|
// 按主键ID查询详情
|
|
func (c *CExample) Detail(ctx context.Context, req *v1.ExampleDetailReq) (res *v1.ExampleDetailRes, err error) {
|
|
return service.Example().Detail(ctx, req)
|
|
}
|
|
|
|
// Add 新增案例演示
|
|
// 新增成功后返回新记录ID
|
|
func (c *CExample) Add(ctx context.Context, req *v1.ExampleAddReq) (res *v1.ExampleIdRes, err error) {
|
|
return service.Example().Add(ctx, req)
|
|
}
|
|
|
|
// Update 修改案例演示
|
|
// 按主键ID更新记录
|
|
func (c *CExample) Update(ctx context.Context, req *v1.ExampleUpdateReq) (res *v1.ExampleUpdateRes, err error) {
|
|
return service.Example().Update(ctx, req)
|
|
}
|
|
|
|
// Status 案例演示状态
|
|
// 设置记录的状态字段
|
|
func (c *CExample) Status(ctx context.Context, req *v1.ExampleStatusReq) (res *v1.ExampleStatusRes, err error) {
|
|
return service.Example().Status(ctx, req)
|
|
}
|
|
|
|
// Delete 删除案例演示
|
|
// 按主键ID删除单条记录
|
|
func (c *CExample) Delete(ctx context.Context, req *v1.ExampleDeleteReq) (res *v1.ExampleDeleteRes, err error) {
|
|
return service.Example().Delete(ctx, req)
|
|
}
|
|
|
|
// BatchDelete 批量删除案例演示
|
|
// 按主键ID列表批量删除记录
|
|
func (c *CExample) BatchDelete(ctx context.Context, req *v1.ExampleBatchDeleteReq) (res *v1.ExampleBatchDeleteRes, err error) {
|
|
return service.Example().BatchDelete(ctx, req)
|
|
}
|
|
|
|
// Import 导入案例演示
|
|
// 接收上传的 xls/xlsx 文件并批量导入数据
|
|
func (c *CExample) Import(ctx context.Context, req *v1.ExampleImportReq) (res *v1.ExampleImportRes, err error) {
|
|
return service.Example().Import(ctx, req)
|
|
}
|
|
|
|
// Export 导出案例演示
|
|
// 按查询条件导出数据并返回文件访问地址
|
|
func (c *CExample) Export(ctx context.Context, req *v1.ExampleExportReq) (res *v1.ExampleExportRes, err error) {
|
|
return service.Example().Export(ctx, req)
|
|
}
|