diff --git a/src/infra/bind_api.go b/src/infra/bind_api.go new file mode 100644 index 0000000..e809c3b --- /dev/null +++ b/src/infra/bind_api.go @@ -0,0 +1,50 @@ +package infra + +import ( + "d2-admin-service/src/modules/system/rest" + "github.com/gin-gonic/gin" +) + +// InnerRouters 服务内部路由 +var InnerRouters = map[string]gin.HandlerFunc{} + +func init() { + // 用户 + userApi := rest.UserController{} + InnerRouters["pageUser"] = userApi.PageUser + InnerRouters["createUser"] = userApi.CreateUser + InnerRouters["deleteUser"] = userApi.DeleteUser + InnerRouters["modifyUserEmail"] = userApi.ModifyUserEmail + InnerRouters["modifyUserPassword"] = userApi.ModifyUserPassword + InnerRouters["modifyUserPhone"] = userApi.ModifyUserPhone + + // 角色 + roleApi := rest.RoleController{} + InnerRouters["pageRole"] = roleApi.PageRole + InnerRouters["createRole"] = roleApi.CreateRole + InnerRouters["deleteRole"] = roleApi.DeleteRole + InnerRouters["modifyRoleName"] = roleApi.ModifyRoleName + + // 菜单 + menuApi := rest.MenuController{} + InnerRouters["menus"] = menuApi.TreeMenu + InnerRouters["createMenu"] = menuApi.CreateMenu + InnerRouters["deleteMenu"] = menuApi.DeleteMenu + InnerRouters["modifyMenu"] = menuApi.ModifyMenu + + // api + api := rest.ApiController{} + InnerRouters["pageApi"] = api.PageApi + InnerRouters["registerApi"] = api.RegisterApi + InnerRouters["unsubscribeApi"] = api.UnSubscribeApi + InnerRouters["modifyApi"] = api.ModifyApi + + // 关联关系 + authApi := rest.AuthController{} + InnerRouters["bindUserRole"] = authApi.BindUserRole + InnerRouters["bindRoleMenu"] = authApi.BindRoleMenu + InnerRouters["bindApiMenu"] = authApi.BindApiMenu + + // 系统 + InnerRouters["kickOut"] = authApi.KickOut +} diff --git a/src/modules/system/dao/router.go b/src/modules/system/dao/router.go new file mode 100644 index 0000000..2c88757 --- /dev/null +++ b/src/modules/system/dao/router.go @@ -0,0 +1,16 @@ +package dao + +import ( + "d2-admin-service/src/infra/database" + "d2-admin-service/src/modules/system/domain" +) + +type RouterDao struct { +} + +func (RouterDao) GetAllRouter() []domain.Router { + var routers []domain.Router + // select * from system_router where router_status = 1 + database.DB.Model(domain.Router{RouterStatus: 1}).Find(&routers) + return routers +} diff --git a/src/modules/system/rest/api.go b/src/modules/system/rest/api.go new file mode 100644 index 0000000..fc17b50 --- /dev/null +++ b/src/modules/system/rest/api.go @@ -0,0 +1,11 @@ +package rest + +import "github.com/gin-gonic/gin" + +type ApiController struct { +} + +func (ApiController) PageApi(c *gin.Context) {} +func (ApiController) RegisterApi(c *gin.Context) {} +func (ApiController) UnSubscribeApi(c *gin.Context) {} +func (ApiController) ModifyApi(c *gin.Context) {} diff --git a/src/modules/system/rest/menu.go b/src/modules/system/rest/menu.go new file mode 100644 index 0000000..85974ff --- /dev/null +++ b/src/modules/system/rest/menu.go @@ -0,0 +1,11 @@ +package rest + +import "github.com/gin-gonic/gin" + +type MenuController struct { +} + +func (MenuController) TreeMenu(c *gin.Context) {} +func (MenuController) CreateMenu(c *gin.Context) {} +func (MenuController) DeleteMenu(c *gin.Context) {} +func (MenuController) ModifyMenu(c *gin.Context) {} diff --git a/src/modules/system/rest/role.go b/src/modules/system/rest/role.go new file mode 100644 index 0000000..d10d784 --- /dev/null +++ b/src/modules/system/rest/role.go @@ -0,0 +1,11 @@ +package rest + +import "github.com/gin-gonic/gin" + +type RoleController struct { +} + +func (RoleController) PageRole(c *gin.Context) {} +func (RoleController) CreateRole(c *gin.Context) {} +func (RoleController) DeleteRole(c *gin.Context) {} +func (RoleController) ModifyRoleName(c *gin.Context) {} diff --git a/src/modules/system/rest/router.go b/src/modules/system/rest/router.go new file mode 100644 index 0000000..58053b5 --- /dev/null +++ b/src/modules/system/rest/router.go @@ -0,0 +1,4 @@ +package rest + +type RouterController struct { +}