aiDoc/examples/backend/enter-go-example.md
enter.go 用来聚合某一层的模块入口,降低循环引用风险,让其他层通过统一入口访问能力。
GroupApp 访问当前层能力package service
import (
"github.com/flipped-aurora/gin-vue-admin/server/service/example"
"github.com/flipped-aurora/gin-vue-admin/server/service/system"
)
var ServiceGroupApp = new(ServiceGroup)
type ServiceGroup struct {
SystemServiceGroup system.ServiceGroup
ExampleServiceGroup example.ServiceGroup
}
package system
import api "github.com/flipped-aurora/gin-vue-admin/server/api/v1"
type RouterGroup struct {
UserRouter
OrderRouter
}
var (
baseApi = api.ApiGroupApp.SystemApiGroup.BaseApi
orderApi = api.ApiGroupApp.SystemApiGroup.OrderApi
)
enter.go 增加聚合字段enter.go,跨层直接互相 importGroup 结构体server/api/v1/enter.goserver/service/enter.goserver/router/system/enter.go