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

import (
	"net/http"

	auth "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/system/api/internal/handler/auth"
	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),
				},
			}...,
		),
		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),
				},
			}...,
		),
		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),
				},
			}...,
		),
		rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
		rest.WithPrefix("/v1"),
	)
}