routes.go 5.9 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"
	"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},
			[]rest.Route{
				{
					Method:  http.MethodPost,
					Path:    "/auth/user_info",
					Handler: auth.SystemAuthUserInfoHandler(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.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:    "/system/app/:id",
					Handler: app.SystemAppGetHandler(serverCtx),
				},
				{
					Method:  http.MethodPost,
					Path:    "/system/app/search",
					Handler: app.SystemAppSearchHandler(serverCtx),
				},
				{
					Method:  http.MethodGet,
					Path:    "/system/app/set_config",
					Handler: app.SystemAppSetConfigHandler(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"),
	)
}