routes.go 8.0 KB
// Code generated by goctl. DO NOT EDIT.
package handler

import (
	"net/http"

	app "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/app"
	auth "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/auth"
	company "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/company"
	department "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/department"
	employee "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/employee"
	role "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/role"
	user "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/user"
	"gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/svc"

	"github.com/zeromicro/go-zero/rest"
)

func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodPost,
					Path:    "/auth/company_sign_up",
					Handler: auth.SystemAuthRegisterHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/auth/login",
					Handler: auth.SystemAuthLoginHandler(serverCtx),
				},
			}...,
		),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest, serverCtx.LoginStatusCheck},
			[]rest.Route{
				{
					Method:  http.MethodPost,
					Path:    "/auth/user_info",
					Handler: auth.SystemAuthUserInfoHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/auth/edit_user_info",
					Handler: auth.SystemAuthEditUserInfoHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/auth/change_password",
					Handler: auth.SystemAuthChangePasswordHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/auth/reset_password",
					Handler: auth.SystemAuthResetPasswordHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/auth/switch_company",
					Handler: auth.SystemAuthSwitchCompanyHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodPost,
					Path:    "/user/company_users",
					Handler: user.UserCompanyUsersHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/system/company_info",
					Handler: company.SystemCompanyInfoHandler(serverCtx),
				},
				{
					Method:  http.MethodPut,
					Path:    "/system/company_info",
					Handler: company.SystemCompanyInfoUpdateHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/system/department/:id",
					Handler: department.SystemDepartmentGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/department",
					Handler: department.SystemDepartmentSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/system/department/:id",
					Handler: department.SystemDepartmentDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodPut,
					Path:    "/system/department/:id",
					Handler: department.SystemDepartmentUpdateHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/department/search",
					Handler: department.SystemDepartmentSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/system/department/batch-del",
					Handler: department.SystemDepartmentBatchDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/system/department/import",
					Handler: department.SystemDepartmentImportHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/system/department/export",
					Handler: department.SystemDepartmentExportHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/company-departments",
					Handler: department.SystemCompanyDepartmentsHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/role/:id",
					Handler: role.SystemRoleGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/role",
					Handler: role.SystemRoleSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/role/:id",
					Handler: role.SystemRoleDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodPut,
					Path:    "/role/:id",
					Handler: role.SystemRoleUpdateHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/role/search",
					Handler: role.SystemRoleSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/menu/list",
					Handler: role.SystemMenuListHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1/system"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/system/app/:id",
					Handler: app.SystemAppGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/app/search",
					Handler: app.SystemAppSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/app/set_config",
					Handler: app.SystemAppSetConfigHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/app/list",
					Handler: app.SystemAppListHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)

	server.AddRoutes(
		rest.WithMiddlewares(
			[]rest.Middleware{serverCtx.LogRequest},
			[]rest.Route{
				{
					Method:  http.MethodGet,
					Path:    "/system/employee/:id",
					Handler: employee.SystemEmployeeGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/employee",
					Handler: employee.SystemEmployeeSaveHandler(serverCtx),
				},
				{
					Method:  http.MethodDelete,
					Path:    "/system/employee/:id",
					Handler: employee.SystemEmployeeDeleteHandler(serverCtx),
				},
				{
					Method:  http.MethodPut,
					Path:    "/system/employee/:id",
					Handler: employee.SystemEmployeeUpdateHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/employee/search",
					Handler: employee.SystemEmployeeSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/employee/set-account-status",
					Handler: employee.SystemEmployeeSetAccountStatusHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/employee/change-departments",
					Handler: employee.SystemEmployeeChangeDepartmentsHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/employee/import",
					Handler: employee.SystemEmployeeImportHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/employee/export",
					Handler: employee.SystemEmployeeExportHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/department-employees",
					Handler: employee.SystemDepartmentEmployeesHandler(serverCtx),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)
}