package router import ( api1 "SciencesServer/app/api/admin/api" api3 "SciencesServer/app/api/enterprise/api" api2 "SciencesServer/app/api/website/api" "SciencesServer/app/basic/api" "SciencesServer/app/session" "SciencesServer/config" "github.com/gin-gonic/gin" ) // registerAPI 注册API func registerAPI(app *gin.Engine) { apiPrefix := "/api" g := app.Group(apiPrefix) v1 := g.Group("/v1") esV1 := v1.Group("/es") { _api := new(api2.ES) esV1.POST("/create", _api.Create) esV1.POST("/search", _api.Search) } // Index 首页信息管理 indexV1 := v1.Group("/index") { _api := new(api2.Index) indexV1.GET("", _api.Instance) indexV1.GET("/distribution/expert", _api.DistributionExpert) indexV1.GET("/distribution/laboratory", _api.DistributionLaboratory) indexV1.GET("/distribution/demand", _api.DistributionDemand) indexV1.GET("/distribution/patent", _api.DistributionPatent) indexV1.GET("/distribution/achievement", _api.DistributionAchievement) indexV1.GET("/distribution/company", _api.DistributionCompany) } // Search 搜索管理 searchV1 := v1.Group("/search") { _api := new(api2.Search) searchV1.POST("", _api.Launch) } // Config 首页信息管理 configV1 := v1.Group("/config") { _api := new(api2.Config) configV1.GET("", _api.Index) _api2 := new(api.Config) configV1.POST("/area", _api2.Area) } // User 用户信息管理 userV1 := v1.Group("/user") { _api := new(api2.User) userV1.POST("/collect/launch", _api.Collect) } // Activity 活动信息管理 activityV1 := v1.Group("/activity").Use(NeedLogin(config.RedisKeyForAccountEnterprise, session.NewEnterprise(), AddSkipperURL([]string{ apiPrefix + "/v1/activity", apiPrefix + "/v1/activity/detail", apiPrefix + "/v1/account", }...))) { _api := new(api2.Activity) activityV1.POST("", _api.Instance) activityV1.POST("/detail", _api.Detail) activityV1.POST("/join", _api.Join) } // Sys 平台信息故哪里 sysV1 := v1.Group("/sys") { _api := new(api2.Sys) sysV1.GET("/platform", _api.Platform) sysV1.GET("/banner", _api.Banner) sysV1.GET("/navigation", _api.Navigation) sysV1.GET("/agreement", _api.Agreement) sysV1.GET("/agreement/detail", _api.AgreementDetail) sysV1.GET("/about", _api.About) sysV1.GET("/about/navigation", _api.AboutNavigation) sysV1.GET("/industry", _api.Industry) } // Docking 对接信息管理 dockingV1 := v1.Group("/docking") { _api := new(api2.Docking) dockingV1.POST("/launch", _api.Launch) } // Message 数据信息管理 messageV1 := v1.Group("/message") { _api := new(api2.Message) messageV1.POST("/launch", _api.Launch) } // Service 服务信息管理 serviceV1 := v1.Group("/service") { _api := new(api2.Service) serviceV1.POST("/solution_case", _api.SolutionCase) serviceV1.POST("/solution_case/list", _api.SolutionCaseList) serviceV1.POST("/solution_case/detail", _api.SolutionCaseDetail) serviceV1.POST("/innovate", _api.Innovate) serviceV1.GET("/innovate/kind", _api.InnovateKind) serviceV1.POST("/innovate/detail", _api.InnovateDetail) } // Manage 服务管理 manageV1 := v1.Group("/manage") { _api := new(api2.Manage) manageV1.POST("/search", _api.Search) manageV1.POST("/company", _api.Company) manageV1.POST("/company/product", _api.CompanyProduct) manageV1.POST("/expert", _api.Expert) manageV1.POST("/expert/achievement", _api.ExpertAchievement) manageV1.POST("/expert/project", _api.ExpertProject) manageV1.POST("/expert/patent", _api.ExpertPatent) manageV1.POST("/expert/paper", _api.ExpertPaper) manageV1.POST("/expert/cooperate", _api.ExpertCooperate) manageV1.POST("/expert/cooperate/detail", _api.ExpertCooperateDetail) manageV1.POST("/laboratory", _api.Laboratory) manageV1.POST("/laboratory/achievement", _api.LaboratoryAchievement) manageV1.POST("/laboratory/project", _api.LaboratoryProject) manageV1.POST("/laboratory/patent", _api.LaboratoryPatent) manageV1.POST("/laboratory/paper", _api.LaboratoryPaper) manageV1.POST("/laboratory/cooperate", _api.LaboratoryCooperate) manageV1.POST("/laboratory/cooperate/detail", _api.LaboratoryCooperateDetail) manageV1.POST("/laboratory/equipment", _api.LaboratoryEquipment) } //Technology 技术信息管理 technologyV1 := v1.Group("/technology") { _api := new(api2.Technology) technologyV1.POST("/patent", _api.Patent) technologyV1.POST("/patent/detail", _api.PatentDetail) technologyV1.POST("/demand", _api.Demand) technologyV1.POST("/demand/detail", _api.DemandDetail) technologyV1.POST("/achievement", _api.Achievement) technologyV1.POST("/achievement/detail", _api.AchievementDetail) technologyV1.POST("/product", _api.Product) technologyV1.POST("/product/detail", _api.ProductDetail) } // Payment 支付管理 paymentV1 := v1.Group("/payment") { _api := new(api2.Payment) paymentV1.POST("/launch", _api.Launch) paymentV1.POST("/callback", _api.Callback) } } // registerAdminAPI 注册API func registerAdminAPI(app *gin.Engine) { apiPrefix := "/admin" g := app.Group(apiPrefix) v1 := g.Group("/v1") // 登录验证 v1.Use(NeedLogin(config.RedisKeyForAccountAdmin, session.NewAdmin(), AddSkipperURL([]string{ apiPrefix + "/v1/captcha", apiPrefix + "/v1/account/login", apiPrefix + "/v1/account/logout", }...))) // 权限验证 v1.Use(NeedPermission(AddSkipperURL([]string{ apiPrefix + "/v1/captcha", apiPrefix + "/v1/account/login", apiPrefix + "/v1/account/logout", }...))) { _api := new(api.Websocket) app.GET("/ws", _api.Ws(config.RedisKeyForAccountAdmin, session.NewAdmin())) app.GET("/ws/publish", _api.Publish) } // Captcha 验证码 v1.GET("/captcha", new(api1.Captcha).Captcha) // Upload 上传管理 v1.POST("/upload", new(api.Upload).Upload) // Account 账户管理 account := v1.Group("/account") { _api := new(api1.Account) account.POST("/login", _api.Login) account.POST("/logout", _api.Logout) } // Config 配置管理 _config := v1.Group("/config") { _api := new(api.Config) _config.GET("/area", _api.Area) _config.GET("/identity", _api.Identity) _config.GET("/industry", _api.Industry) _api2 := new(api1.Config) _config.POST("", _api2.Index) _config.POST("/add", _api2.Add) _config.POST("/edit", _api2.Edit) } // Sys 系统管理 sys := v1.Group("/sys") { _api := new(api1.Sys) // 导航信息 sys.POST("/banner", _api.Banner) sys.POST("/banner/local", _api.BannerLocal) sys.POST("/banner/add", _api.BannerForm) sys.POST("/banner/edit", _api.BannerForm) sys.POST("/banner/delete", _api.BannerDelete) sys.GET("/industry", _api.Industry) sys.POST("/industry/add", _api.IndustryForm) sys.POST("/industry/edit", _api.IndustryForm) sys.POST("/industry/delete", _api.IndustryDelete) sys.POST("/navigation", _api.Navigation) sys.POST("/navigation/add", _api.NavigationForm) sys.POST("/navigation/edit", _api.NavigationForm) sys.POST("/navigation/delete", _api.NavigationDelete) sys.POST("/agreement", _api.Agreement) sys.POST("/agreement/detail", _api.AgreementDetail) sys.POST("/agreement/add", _api.AgreementForm) sys.POST("/agreement/edit", _api.AgreementForm) sys.POST("/agreement/delete", _api.AgreementDelete) sys.POST("/about", _api.About) sys.POST("/about/detail", _api.AboutDetail) sys.POST("/about/add", _api.AboutForm) sys.POST("/about/edit", _api.AboutForm) sys.POST("/about/delete", _api.AboutDelete) } // User 用户管理 user := v1.Group("/user") { _api := new(api1.User) user.GET("/info", _api.Info) user.GET("/menu", _api.Menu) user.POST("/list", _api.List) user.POST("/add", _api.Add) user.POST("/edit", _api.Edit) user.POST("/delete", _api.Delete) user.POST("/password", _api.Password) user.POST("/password/edit", _api.PasswordEdit) } // Tenant 租户管理 tenant := v1.Group("/tenant") { _api := new(api1.Tenant) tenant.POST("", _api.Instance) tenant.GET("/select", _api.Select) tenant.POST("/add", _api.Form) tenant.POST("/edit", _api.Form) tenant.POST("/delete", _api.Delete) tenant.POST("/member", _api.Member) tenant.POST("/member/bind", _api.MemberBind) tenant.POST("/menu", _api.Menu) tenant.POST("/menu/bind", _api.MenuBind) tenant.POST("/auth", _api.Auth) tenant.POST("/auth/bind", _api.AuthBind) } // Menu 菜单管理 menu := v1.Group("/menu") { _api := new(api1.Menu) menu.GET("/list", _api.List) menu.POST("/add", _api.Add) menu.POST("/edit", _api.Edit) menu.POST("/status", _api.Status) menu.POST("/delete", _api.Delete) } // Auth 权限管理 auth := v1.Group("/auth") { _api := new(api1.Auth) auth.GET("", _api.Index) } // Department 部门管理 department := v1.Group("/department") { _api := new(api1.Department) department.GET("", _api.Index) department.GET("/select", _api.Select) department.POST("/add", _api.Add) department.POST("/edit", _api.Edit) department.POST("/delete", _api.Delete) } // Role 角色管理 role := v1.Group("/role") { _api := new(api1.Role) role.POST("", _api.Index) role.POST("/select", _api.Select) role.POST("/add", _api.Add) role.POST("/edit", _api.Edit) role.POST("/status", _api.Status) role.POST("/delete", _api.Delete) role.POST("/menu", _api.Menu) role.POST("/menu/bind", _api.MenuBind) role.POST("/auth", _api.Auth) role.POST("/auth/bind", _api.AuthBind) } // Manage 项目管理 manage := v1.Group("/manage") { _api := new(api1.Manage) manage.POST("/company", _api.Company) manage.POST("/company/add", _api.CompanyForm) manage.POST("/company/edit", _api.CompanyForm) manage.POST("/company/detail", _api.CompanyDetail) manage.POST("/company/examine", _api.CompanyExamine) manage.POST("/expert", _api.Expert) manage.POST("/expert/add", _api.ExpertForm) manage.POST("/expert/edit", _api.ExpertForm) manage.POST("/expert/detail", _api.ExpertDetail) manage.POST("/expert/examine", _api.ExpertExamine) manage.POST("/expert/patent", _api.ExpertPatent) manage.POST("/expert/patent/bind", _api.ExpertPatentBind(true)) manage.POST("/expert/patent/unbind", _api.ExpertPatentBind(false)) manage.POST("/research", _api.Research) manage.POST("/research/select", _api.ResearchSelect) manage.POST("/research/add", _api.ResearchForm) manage.POST("/research/edit", _api.ResearchForm) manage.POST("/research/detail", _api.ResearchDetail) manage.POST("/research/examine", _api.ResearchExamine) manage.POST("/laboratory", _api.Laboratory) manage.POST("/laboratory/select", _api.LaboratorySelect) manage.POST("/laboratory/add", _api.LaboratoryForm) manage.POST("/laboratory/edit", _api.LaboratoryForm) manage.POST("/laboratory/detail", _api.LaboratoryDetail) manage.POST("/laboratory/examine", _api.LaboratoryExamine) manage.POST("/agent", _api.Agent) manage.POST("/agent/select", _api.AgentSelect) manage.POST("/agent/detail", _api.AgentDetail) manage.POST("/agent/examine", _api.AgentExamine) manage.POST("/enterprise", _api.Enterprise) manage.POST("/enterprise/delete", _api.EnterpriseDelete) } // Service 服务管理 service := v1.Group("/service") { _api := new(api1.Service) service.POST("/innovate", _api.Innovate) service.POST("/innovate/detail", _api.InnovateDetail) service.POST("/innovate/add", _api.InnovateForm) service.POST("/innovate/edit", _api.InnovateForm) service.POST("/innovate/delete", _api.InnovateDelete) service.POST("/innovate/kind", _api.InnovateKind) service.GET("/innovate/kind/select", _api.InnovateKindSelect) service.POST("/innovate/kind/add", _api.InnovateKindForm) service.POST("/innovate/kind/edit", _api.InnovateKindForm) service.POST("/innovate/kind/delete", _api.InnovateKindDelete) service.POST("/solution_case", _api.SolutionCase) service.POST("/solution_case/detail", _api.SolutionCaseDetail) service.POST("/solution_case/add", _api.SolutionCaseForm) service.POST("/solution_case/edit", _api.SolutionCaseForm) service.POST("/solution_case/delete", _api.SolutionCaseDelete) service.POST("/solution_case/kind", _api.SolutionCaseKind) service.GET("/solution_case/kind/select", _api.SolutionCaseKindSelect) service.POST("/solution_case/kind/add", _api.SolutionCaseKindForm) service.POST("/solution_case/kind/edit", _api.SolutionCaseKindForm) service.POST("/solution_case/kind/delete", _api.SolutionCaseKindDelete) service.POST("/message", _api.Message) service.POST("/message/handle", _api.MessageHandle) service.POST("/message/delete", _api.MessageDelete) service.POST("/demand", _api.Demand) service.POST("/demand/delete", _api.DemandDelete) } // Technology 科技管理 technology := v1.Group("/technology") { _api := new(api1.Technology) technology.POST("/patent", _api.Patent) technology.POST("/patent/detail", _api.PatentDetail) technology.POST("/patent/add", _api.PatentForm) technology.POST("/patent/edit", _api.PatentForm) technology.POST("/patent/bind", _api.PatentBind) technology.POST("/patent/delete", _api.PatentDelete) technology.GET("/patent/ipc", _api.PatentIPC) technology.POST("/patent/ipc/add", _api.PatentIPCForm) technology.POST("/patent/ipc/edit", _api.PatentIPCForm) technology.POST("/patent/ipc/delete", _api.PatentIPCDelete) technology.POST("/paper", _api.Paper) technology.POST("/paper/detail", _api.PaperDetail) technology.POST("/paper/delete", _api.PaperDelete) technology.POST("/product", _api.Product) technology.POST("/product/examine", _api.ProductExamine) technology.POST("/product/detail", _api.ProductDetail) technology.POST("/product/shelf", _api.ProductShelf) technology.POST("/product/delete", _api.ProductDelete) technology.POST("/achievement", _api.Achievement) technology.POST("/achievement/examine", _api.AchievementExamine) technology.POST("/achievement/detail", _api.AchievementDetail) technology.POST("/achievement/shelf", _api.AchievementShelf) technology.POST("/achievement/delete", _api.AchievementDelete) technology.POST("/demand", _api.Demand) technology.POST("/demand/examine", _api.DemandExamine) technology.POST("/demand/detail", _api.DemandDetail) technology.POST("/demand/delete", _api.DemandDelete) technology.POST("/demand/assign", _api.DemandAssign) technology.POST("/project", _api.Project) technology.POST("/project/shelf", _api.ProjectShelf) technology.POST("/project/delete", _api.ProjectDelete) } // Activity 活动管理 activity := v1.Group("/activity") { _api := new(api1.Activity) activity.POST("", _api.Instance) activity.POST("/detail", _api.Detail) activity.POST("/add", _api.Form) activity.POST("/edit", _api.Form) activity.POST("/delete", _api.Delete) activity.POST("/joins", _api.Joins) activity.POST("/apply", _api.Apply) activity.POST("/apply/detail", _api.ApplyDetail) activity.POST("/apply/handle", _api.ApplyHandle) activity.POST("/apply/delete", _api.ApplyDelete) } // Order 订单管理 order := v1.Group("/order") { _api := new(api1.Order) order.POST("", _api.Instance) order.POST("/detail", _api.Detail) } // Logs 日志管理 log := v1.Group("/log") { _api := new(api1.Log) log.POST("/login", _api.Login) } } // registerEnterpriseAPI 注册企业/管家后台API func registerEnterpriseAPI(app *gin.Engine) { apiPrefix := "/api/enterprise" g := app.Group(apiPrefix) v1 := g.Group("/v1") v1.Use(NeedLogin(config.RedisKeyForAccountEnterprise, session.NewEnterprise(), AddSkipperURL([]string{ apiPrefix + "/v1/account/login", apiPrefix + "/v1/account/register", apiPrefix + "/v1/account/authorize", apiPrefix + "/v1/account/logout", apiPrefix + "/v1/account/reset/password", apiPrefix + "/v1/sms/captcha", apiPrefix + "/v1/sms/captcha/validate", apiPrefix + "/v1/payment/callback", }...))) v1.Use(NeedAuthIdentity()) // Upload 上传管理 v1.POST("/upload", new(api.Upload).Upload) // Config 配置管理 configV1 := v1.Group("/config") { _api := new(api.Config) configV1.GET("/area", _api.Area) configV1.GET("/identity", _api.Identity) configV1.GET("/industry", _api.Industry) } // SMS 短信管理 smsV1 := v1.Group("/sms") { _api := new(api.Sms) smsV1.POST("/captcha", _api.Captcha) smsV1.POST("/captcha/validate", _api.CaptchaValidate) } // Account 账号管理 accountV1 := v1.Group("/account") { _api := new(api3.Account) accountV1.POST("/login", _api.Login) accountV1.POST("/register", _api.Register) accountV1.POST("/authorize", _api.Authorize) accountV1.POST("/logout", _api.Logout) accountV1.POST("/reset/password", _api.ResetPassword) } // User 用户管理 userV1 := v1.Group("/user") { _api := new(api3.User) userV1.GET("/info", _api.Info) userV1.POST("/back", _api.Back) userV1.POST("/back/bind", _api.BackBind) userV1.POST("/back/unbind", _api.BackUnbind) userV1.POST("/bill", _api.Bill) userV1.POST("/bill/ticket", _api.BillTicket) userV1.POST("/bill/ticket/issue", _api.BillTicketIssue) userV1.POST("/consume", _api.Consume) userV1.POST("/consume/exchange", _api.ConsumeExchange) userV1.POST("/consume/delete", _api.ConsumeDelete) userV1.POST("/withdrawal", _api.Withdrawal) userV1.POST("/withdrawal/transfer", _api.WithdrawalTransfer) userV1.POST("/withdrawal/delete", _api.WithdrawalDelete) } // Home 首页管理 homeV1 := v1.Group("/home") { _api := new(api3.Home) homeV1.GET("", _api.Instance) } // Settled 入驻管理 settledV1 := v1.Group("/settled") { _api := new(api3.Settled) settledV1.GET("", _api.Index) settledV1.POST("/company", _api.Company) settledV1.POST("/company/get", _api.CompanyGet) settledV1.POST("/expert", _api.Expert) settledV1.POST("/research", _api.Research) settledV1.POST("/laboratory", _api.Laboratory) settledV1.POST("/agent", _api.Agent) } // Technology 技术管理 technologyV1 := g.Group("/technology") { _api := new(api3.Technology) technologyV1.POST("/paper", _api.Paper) technologyV1.POST("/paper/add", _api.PaperAdd) technologyV1.POST("/paper/edit", _api.PaperEdit) technologyV1.POST("/paper/delete", _api.PaperDelete) technologyV1.POST("/patent", _api.Patent) technologyV1.POST("/patent/detail", _api.PatentDetail) technologyV1.POST("/patent/add", _api.PatentAdd) technologyV1.POST("/patent/edit", _api.PatentEdit) technologyV1.POST("/patent/delete", _api.PatentDelete) technologyV1.POST("/demand", _api.Demand) technologyV1.POST("/demand/detail", _api.DemandDetail) technologyV1.POST("/demand/add", _api.DemandAdd) technologyV1.POST("/demand/edit", _api.DemandEdit) technologyV1.POST("/demand/delete", _api.DemandDelete) technologyV1.POST("/demand/service", _api.DemandService) technologyV1.POST("/demand/service/detail", _api.DemandServiceDetail) technologyV1.POST("/demand/service/handle", _api.DemandServiceHandle) technologyV1.POST("/topic", _api.Topic) technologyV1.POST("/topic/add", _api.TopicAdd) technologyV1.POST("/topic/edit", _api.TopicEdit) technologyV1.POST("/topic/delete", _api.TopicDelete) technologyV1.POST("/product", _api.Product) technologyV1.POST("/product/visit", _api.ProductVisit) technologyV1.POST("/product/add", _api.ProductAdd) technologyV1.POST("/product/edit", _api.ProductEdit) technologyV1.POST("/product/shelf", _api.ProductShelf) technologyV1.POST("/product/delete", _api.ProductDelete) technologyV1.POST("/project", _api.Project) technologyV1.POST("/project/add", _api.ProjectAdd) technologyV1.POST("/project/edit", _api.ProjectEdit) technologyV1.POST("/project/shelf", _api.ProjectShelf) technologyV1.POST("/project/delete", _api.ProjectDelete) technologyV1.POST("/achievement", _api.Achievement) technologyV1.POST("/achievement/add", _api.AchievementAdd) technologyV1.POST("/achievement/edit", _api.AchievementEdit) technologyV1.POST("/achievement/shelf", _api.AchievementShelf) technologyV1.POST("/achievement/delete", _api.AchievementDelete) } // Service 服务信息 serviceV1 := v1.Group("/service") { _api := new(api3.Service) serviceV1.POST("/demand", _api.Demand) serviceV1.POST("/demand/detail", _api.DemandDetail) serviceV1.POST("/demand/add", _api.DemandAdd) serviceV1.POST("/demand/edit", _api.DemandEdit) serviceV1.POST("/demand/delete", _api.DemandDelete) } // Manage 管理信息 manageV1 := v1.Group("/manage") { _api := new(api3.Manage) manageV1.POST("/enterprise", _api.Enterprise) manageV1.POST("/enterprise/add", _api.EnterpriseAdd) manageV1.POST("/enterprise/edit", _api.EnterpriseEdit) manageV1.POST("/enterprise/delete", _api.EnterpriseDelete) manageV1.POST("/equipment", _api.Equipment) manageV1.POST("/equipment/add", _api.EquipmentAdd) manageV1.POST("/equipment/edit", _api.EquipmentEdit) manageV1.POST("/equipment/delete", _api.EquipmentDelete) manageV1.POST("/company/detail", _api.CompanyDetail) manageV1.POST("/company/product", _api.CompanyProduct) manageV1.POST("/expert", _api.Expert) manageV1.GET("/research/select", _api.ResearchSelect) manageV1.POST("/research/laboratory", _api.ResearchLaboratory) manageV1.POST("/research/visit", _api.ResearchVisit) } // Activity 活动信息 activityV1 := v1.Group("/activity") { _api := new(api3.Activity) activityV1.POST("/apply", _api.Applys) activityV1.POST("/apply/revoke", _api.ApplyRevoke) activityV1.POST("/apply/delete", _api.ApplyDelete) activityV1.POST("/joins", _api.Joins) activityV1.POST("/join/delete", _api.JoinDelete) } }