github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/internal/server/core/module/index.go (about)

     1  package module
     2  
     3  import (
     4  	"github.com/kataras/iris/v12"
     5  )
     6  
     7  // InitDBFunc 数据化初始化接口
     8  type InitDBFunc interface {
     9  	Init() (err error)
    10  }
    11  
    12  // WebModule web 模块结构
    13  // - RelativePath 关联路径
    14  // - Handler 模块 Handler
    15  // - Modules 子模块
    16  type WebModule struct {
    17  	RelativePath string
    18  	Handler      func(p iris.Party)
    19  	Modules      []WebModule
    20  }
    21  
    22  // NewModule 添加新的模块
    23  func NewModule(relativePath string, handler func(index iris.Party), modules ...WebModule) WebModule {
    24  	return WebModule{
    25  		RelativePath: relativePath,
    26  		Handler:      handler,
    27  		Modules:      modules,
    28  	}
    29  }
    30  
    31  // GetModules 获取模块列表
    32  func (wm *WebModule) GetModules() []WebModule {
    33  	return wm.Modules
    34  }