cmd

package
v0.0.0-...-f0066fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Main = gcmd.Command{
		Name:  "main",
		Usage: "main",
		Brief: "start http server",
		Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
			s := g.Server()
			apiBasePath := g.Cfg().MustGet(ctx, "server.api_base_path").String()
			if apiBasePath == "" {
				g.Log().Fatal(ctx, "环境配置不能为空")
			}

			s.Group(apiBasePath, func(group *ghttp.RouterGroup) {

				uploadPath := g.Cfg().MustGet(ctx, "upload.path").String()
				if uploadPath == "" {
					g.Log().Fatal(ctx, "文件上传配置路径不能为空")
				}
				s.AddStaticPath("/api/upload", uploadPath)

				group.Middleware(
					service.Middleware().Ctx,
					service.Middleware().CORS,
					service.Middleware().ResponseHandler,
				)

				group.Bind(
					controller.Login.Login,
					controller.Login.Logout,
					controller.Login.MSALLoginSso,
				)

				group.Middleware(service.Middleware().TokenAuth)

				group.Bind(
					controller.Login.GetInfo,
					controller.Login.GetRouters,
				)

				group.Group("/system", func(group *ghttp.RouterGroup) {
					group.Bind(
						controller.SysUser,
						controller.SysRole,
						controller.SysMenu,
						controller.SysDictType,
						controller.SysDictData,
						controller.SysDept,
						controller.SysConfig,
					)
				})
				group.Group("/monitor", func(group *ghttp.RouterGroup) {
					group.Bind(
						controller.SysLoginLog,
						controller.SysOperLog,
						controller.SysUserOnline,
						controller.SysJob,
					)
				})
				group.Group("/tool", func(group *ghttp.RouterGroup) {
					group.Bind(
						controller.SysGenTable,
					)
				})
			})
			s.Run()
			return nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL