package router import ( "applet/app/cfg" "applet/app/hdl" "applet/app/hdl/advertising" "applet/app/hdl/article" "applet/app/hdl/cloud_bundle" "applet/app/hdl/comm" "applet/app/hdl/content_reward" "applet/app/hdl/financial_center" "applet/app/hdl/friend_circle" "applet/app/hdl/im" "applet/app/hdl/institutional_management/egg_energy" "applet/app/hdl/institutional_management/egg_point_coefficient" "applet/app/hdl/institutional_management/module_setting" "applet/app/hdl/institutional_management/public_platoon" "applet/app/hdl/marketing_applications/new_user_red_package" "applet/app/hdl/member_center" "applet/app/hdl/notice" "applet/app/hdl/setCenter/oss/aliyun" "applet/app/hdl/setCenter/thirdParty" "applet/app/hdl/setCenter/web" "applet/app/hdl/user_feedback" "applet/app/hdl/user_real_name" "applet/app/hdl/website" "applet/app/mw" _ "applet/docs" "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" ) // 初始化路由 func Init() *gin.Engine { // debug, release, test 项目阶段 mode := "release" if cfg.Debug { mode = "debug" } gin.SetMode(mode) //创建一个新的启动器 r := gin.New() r.GET("/api/swagger/*any", func(c *gin.Context) { // r.Use(mw.SwagAuth()) ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c) }) // 是否打印访问日志, 在非正式环境都打印 if mode != "release" { r.Use(gin.Logger()) } r.Use(gin.Recovery()) r.GET("/favicon.ico", func(c *gin.Context) { c.Status(204) }) r.NoRoute(func(c *gin.Context) { c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}}) }) r.NoMethod(func(c *gin.Context) { c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}}) }) r.Use(mw.Cors) route(r.Group("/api")) return r } func route(r *gin.RouterGroup) { r.GET("/test", hdl.Demo) r.POST("/login", hdl.Login) { //打包机调用,不需要校验 r.GET("/cloudBundle/base", cloud_bundle.Base) //打包基本信息 r.POST("/cloudBundle/update/state", cloud_bundle.UpdateState) //打包更新状态 r.POST("/cloudBundle/upload", cloud_bundle.Upload) //打包 上传apk r.GET("/getSTSVoucher", comm.GetSTSVoucher) // 获取 STS 凭证 //这里是官网的接口 rWebsite := r.Group("/website") //官网信息 { rWebsite.GET("/info", website.WebsiteInfo) // 官网 rWebsite.GET("/getModuleSetting", website.GetModuleSetting) // 获取页面样式 rWebsite.POST("/certificate", website.Certificate) // 查询证书 } } r.Use(mw.Auth) // 以下接口需要JWT验证 rComm(r.Group("/comm")) r.GET("/config", hdl.Config) rIm(r.Group("/im")) r.Use(mw.CheckPermission) // 检测权限 rRole(r.Group("/role")) rInstitutionalManagement(r.Group("/institutionalManagement")) rMarketingApplications(r.Group("/marketingApplications")) rMemberCenter(r.Group("/memberCenter")) rHomePage(r.Group("/homePage")) rSettCenter(r.Group("/settCenter")) rFinancialCenter(r.Group("/financialCenter")) rAdvertising(r.Group("/advertising")) rNotice(r.Group("/notice")) rArticle(r.Group("/article")) rUserFeedback(r.Group("/userFeedback")) rCloudBundle(r.Group("/cloudBundle")) //云打包 rUserRealName(r.Group("/userRealName")) //实名认证 rFriendCircleSettings(r.Group("/friendCircleSettings")) // 朋友圈设置 rAdminLog(r.Group("/adminLog")) // 操作日志 } func rSettCenter(r *gin.RouterGroup) { //设置中心 rOss := r.Group("/oss") //oss设置 { rOssAliYun := rOss.Group("/aliYun") //阿里云 { rOssAliYun.GET("/getBasic", aliyun.GetBasic) rOssAliYun.POST("/setBasic", aliyun.SetBasic) } } rWeb := r.Group("/web") //网站信息 { rWeb.GET("/getBasic", web.GetBasic) rWeb.POST("/setBasic", web.SetBasic) rWeb.GET("/getDownDomainBasic", web.GetDownDomainBasic) rWeb.POST("/setDownDomainBasic", web.SetDownDomainBasic) rWeb.GET("/getRegisterDomainBasic", web.GetRegisterDomainBasic) rWeb.POST("/setRegisterDomainBasic", web.SetRegisterDomainBasic) } rKuaizhan := r.Group("/kuaizhan") //快站信息 { rKuaizhan.GET("/getBasic", thirdParty.GetBasic) rKuaizhan.POST("/setBasic", thirdParty.SetBasic) } } func rHomePage(r *gin.RouterGroup) { r.GET("/totalData", hdl.GetTotalData) r.GET("/activeData", hdl.GetActiveData) r.GET("/growData", hdl.GetGrowData) } func rAdvertising(r *gin.RouterGroup) { r.GET("/getBasic", advertising.GetBasic) r.POST("/setBasic", advertising.SetBasic) r.GET("/getPlayletBasic", advertising.GetPlayletBasic) r.POST("/setPlayletBasic", advertising.SetPlayletBasic) r.POST("/list", advertising.List) r.POST("/save", advertising.Save) r.POST("/del", advertising.Del) r.GET("/getLimit", advertising.GetLimit) r.POST("/setLimit", advertising.SetLimit) r.POST("/function/list", advertising.FunctionList) r.POST("/function/save", advertising.FunctionSave) r.POST("/function/del", advertising.FunctionDel) r.POST("/visit/list", advertising.VisitList) } func rNotice(r *gin.RouterGroup) { rBase := r.Group("/base") //极光 { rBase.POST("/list", notice.List) rBase.POST("/save", notice.Save) rBase.POST("/del", notice.Del) } rJpush := r.Group("/jPush") //极光 { rJpush.POST("/push/list", notice.PushList) rJpush.POST("/getUserList", notice.JPushGetUserList) rJpush.GET("/getTagList", notice.JPushGetTagList) rJpush.GET("/getLevelList", notice.JPushGetLevelList) rJpush.POST("/push/save", notice.PushSave) } rAliyunSms := r.Group("/aliyunSms") //阿里云短信 { rAliyunSms.POST("/file/phone", notice.AliyunSmsFilePhone) rAliyunSms.POST("/getUserList", notice.AliyunSmsGetUserList) rAliyunSms.GET("/getTagList", notice.AliyunSmsTagList) rAliyunSms.GET("/getLevelList", notice.AliyunSmsGetLevelList) rAliyunSms.GET("/sale/base", notice.AliyunSmsSaleBase) rAliyunSms.POST("/sale/save", notice.AliyunSmsSaleSave) rAliyunSms.POST("/push/list", notice.AliyunSmsPushList) rAliyunSms.POST("/push/save", notice.AliyunSmsPushSave) } } func rArticle(r *gin.RouterGroup) { //文章 rCate := r.Group("/cate") // { rCate.POST("/list", article.CateList) rCate.POST("/save", article.CateSave) rCate.POST("/del", article.CateDel) } rContent := r.Group("/content") // { rContent.POST("/list", article.List) rContent.POST("/save", article.Save) rContent.POST("/del", article.Del) } } func rUserFeedback(r *gin.RouterGroup) { //用户反馈 rCate := r.Group("/cate") // { rCate.POST("/list", user_feedback.CateList) rCate.POST("/save", user_feedback.CateSave) rCate.POST("/del", user_feedback.CateDel) } rContent := r.Group("/content") // { rContent.POST("/list", user_feedback.List) rContent.POST("/record/list", user_feedback.RecordList) rContent.POST("/say", user_feedback.Say) rContent.POST("/change/state", user_feedback.ChangeState) rContent.POST("/del", user_feedback.Del) } } func rCloudBundle(r *gin.RouterGroup) { //云打包 r.POST("/list", cloud_bundle.List) r.POST("/build", cloud_bundle.Build) r.POST("/del", cloud_bundle.Del) r.POST("/audit/set", cloud_bundle.AuditSet) r.POST("/audit/clear", cloud_bundle.AuditClear) r.GET("/img/base", cloud_bundle.ImgBase) r.POST("/img/base/save", cloud_bundle.ImgBaseSave) r.GET("/version/base", cloud_bundle.VersionBase) r.POST("/version/base/save", cloud_bundle.VersionBaseSave) } func rUserRealName(r *gin.RouterGroup) { //实名认证 r.POST("/list", user_real_name.List) r.POST("/save", user_real_name.Save) r.GET("/base", user_real_name.Base) r.POST("/base/save", user_real_name.BaseSave) } func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理 rPublicPlatoon := r.Group("/publicPlatoon") //公排设置 { rPublicPlatoon.GET("/getBasic", public_platoon.GetPublicPlatoonBasic) rPublicPlatoon.PUT("/updateBasic", public_platoon.UpdatePublicPlatoonBasic) rPublicPlatoon.GET("/relationshipMap", public_platoon.GetRelationshipMap) rPublicPlatoon.GET("/findUserRelationshipMap", public_platoon.FindUserRelationshipMap) rPublicPlatoon.GET("/findSubUserRelationshipMap", public_platoon.FindSubUserRelationshipMap) rPublicPlatoon.POST("/exchangeUserPosition", public_platoon.ExchangeUserPosition) rPublicPlatoon.GET("/nineDimensionalSpace", public_platoon.NineDimensionalSpace) rPublicPlatoon.POST("/selectMember", public_platoon.SelectMember) rPublicPlatoonUserFreePunish := rPublicPlatoon.Group("/publicPlatoonUserFreePunish") { rPublicPlatoonUserFreePunish.POST("/index", public_platoon.GetFreePublishUser) rPublicPlatoonUserFreePunish.POST("/save", public_platoon.AddFreePublishUser) rPublicPlatoonUserFreePunish.DELETE("/delete", public_platoon.DeleteFreePublishUser) } rCommunityDividends := rPublicPlatoon.Group("/communityDividends") { rCommunityDividends.POST("/communityDividendsList", public_platoon.ListCommunityDividends) rCommunityDividends.POST("/communityDividendsAdd", public_platoon.AddCommunityDividends) rCommunityDividends.POST("/communityDividendsWithUserList", public_platoon.ListCommunityDividendsWithUser) rCommunityDividends.POST("/communityDividendsWithUserAdd", public_platoon.AddCommunityDividendsWithUser) rCommunityDividends.DELETE("/communityDividendsWithUserDel/:id", public_platoon.DelCommunityDividendsWithUser) } rUserDailyActivityAnalysis := rPublicPlatoon.Group("/userDailyActivityAnalysis") { rUserDailyActivityAnalysis.POST("/index", public_platoon.UserDailyActivityAnalysis) } } rEggEnergy := r.Group("/eggEnergy") //蛋蛋能量 { rEggEnergy.GET("/getVirtualCoinList", egg_energy.GetVirtualCoinList) rEggEnergy.POST("/batchAddVirtualCoins", egg_energy.BatchAddVirtualCoins) rEggEnergy.POST("/updateVirtualCoin", egg_energy.UpdateVirtualCoin) rEggEnergy.DELETE("/deleteVirtualCoin/:id", egg_energy.DeleteVirtualCoin) rEggEnergy.GET("/getBasic", egg_energy.GetEggEnergyBasic) rEggEnergy.POST("/updateBasic", egg_energy.UpdateEggEnergyBasic) rEggEnergy.GET("/getVipSetting", egg_energy.GetEggEnergyVipSetting) rEggEnergy.POST("/addVipSetting", egg_energy.AddEggEnergyVipSetting) rEggEnergy.POST("/updateVipSetting", egg_energy.UpdateEggEnergyVipSetting) rEggEnergy.GET("/coreData", egg_energy.GetEggEnergyCoreData) rEggEnergy.POST("/coreData", egg_energy.UpdateEggEnergyCoreData) rEggEnergyUserCoin := rEggEnergy.Group("/userCoin") { rEggEnergyUserCoin.POST("/eggEnergyUserCoinList", egg_energy.GetEggEnergyUserCoinList) rEggEnergyUserCoin.POST("/eggEnergyUserCoinFlowList", egg_energy.GetEggEnergyUserCoinFlowList) rEggEnergyUserCoin.POST("/eggPointsUserCoinList", egg_energy.GetEggPointsUserCoinList) rEggEnergyUserCoin.POST("/getEggPointsUserCoinFlowList", egg_energy.GetEggPointsUserCoinFlowList) } rEggEnergyAvailableEnergy := rEggEnergy.Group("/availableEnergy") { rEggEnergyAvailableEnergy.POST("/list", egg_energy.DynamicDataFlowList) } rEggGlobalData := rEggEnergy.Group("/globalData") { rEggGlobalData.GET("/coreDataList", egg_energy.GetEggCoreDataList) rEggGlobalData.GET("/pointsCenterPriceCurve", egg_energy.GetPriceCurve) rEggGlobalData.POST("/fundDataList", egg_energy.GetFundDataList) rEggGlobalData.POST("/fundDataRecordList", egg_energy.GetFundDataRecordList) rEggGlobalData.POST("/fundDataAdd", egg_energy.AddFundData) } rPlatformRevenue := rEggEnergy.Group("/platformRevenue") { rPlatformRevenue.POST("/getVideoReward", egg_energy.GetVideoReward) rPlatformRevenue.POST("/setVideoReward", egg_energy.SetVideoReward) rPlatformRevenue.POST("/platformRevenueList", egg_energy.ListPlatformRevenue) rPlatformRevenue.POST("/platformRevenueAdd", egg_energy.AddPlatformRevenue) } rEggPoint := rEggEnergy.Group("/eggPoint") { rEggPoint.POST("/userEggIndex", egg_energy.UserEggIndex) rEggPoint.POST("/statisticsUserEggIndex", egg_energy.StatisticsUserEggIndex) rEggPoint.POST("/userEggFlow", egg_energy.UserEggFlow) rEggPoint.POST("/manualScore", egg_energy.ManualScore) } rContributionValue := rEggEnergy.Group("/contributionValue") { rContributionValue.GET("/basic", egg_energy.GetContributionValueBasicSetting) rContributionValue.POST("/updateBasic", egg_energy.UpdateContributionValueBasicSetting) } } rModuleSetting := r.Group("/moduleSetting") { rModuleSetting.GET("/getModuleSetting", module_setting.ModuleSettingGet) rModuleSetting.POST("/getArticle", article.List) rModuleSetting.POST("/updateModuleSetting", module_setting.ModuleSettingUpdate) } rContentReward := r.Group("/contentReward") // 内容奖励 { rVideo := rContentReward.Group("/video") { rVideo.GET("/base", content_reward.VideoBase) // rVideo.POST("/save", content_reward.VideoBaseSave) // } rPlaylet := rContentReward.Group("/playlet") { rPlaylet.GET("/base", content_reward.PlayletBase) // rPlaylet.POST("/save", content_reward.PlayletBaseSave) // } } rEggPointCoefficient := r.Group("/eggPointCoefficient") // 蛋蛋分区间系数管理 { rEggPointCoefficient.GET("/index", egg_point_coefficient.EggPointCoefficientGet) // 查询 rEggPointCoefficient.POST("/add", egg_point_coefficient.EggPointCoefficientBatchAdd) // 新增 rEggPointCoefficient.POST("/update", egg_point_coefficient.EggPointCoefficientUpdate) // 更新 rEggPointCoefficient.DELETE("/del", egg_point_coefficient.EggPointCoefficientDel) // 删除 } } func rMarketingApplications(r *gin.RouterGroup) { //营销应用 rNewUserRedPackage := r.Group("/newUserRedPackage") //新人红包 { rNewUserRedPackage.GET("/getBasic", new_user_red_package.NewUserRedPackageGetBasic) rNewUserRedPackage.PUT("/updateBasic", new_user_red_package.NewUserRedPackageUpdateBasic) rNewUserRedPackage.POST("/recordList", new_user_red_package.NewUserRedPackageRecordList) rNewUserRedPackage.POST("/recordFlowList", new_user_red_package.NewUserRedPackageRecordFlowList) } } func rMemberCenter(r *gin.RouterGroup) { // 会员中心 rUserManagement := r.Group("/userManagement") { rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList) rUserManagement.POST("/addUser", member_center.UserManagementAddUser) rUserManagement.POST("/setCustomInviteCode", member_center.UserManagementSetCustomInviteCode) rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic) rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo) rUserManagement.POST("/userRecycle", member_center.UserManagementUserRecycle) rUserManagement.POST("/userRecycleCancel", member_center.UserManagementUserRecycleCancel) rUserManagement.POST("/userRecycleList", member_center.UserManagementGetUserRecycleList) rUserManagement.POST("/userDelete", member_center.UserManagementUserDelete) rUserManagement.GET("/getFans", member_center.UserManagementGetFans) rUserManagement.GET("/balanceDetail", member_center.UserManagementGetBalanceDetail) rUserManagement.GET("/getVirtualCoinDetail", member_center.UserManagementGetVirtualCoinDetail) } rTagManagement := r.Group("/tagManagement") { rTagManagement.GET("/getTagList", member_center.GetTagList) rTagManagement.POST("/addTag", member_center.AddTag) rTagManagement.POST("/updateTag", member_center.UpdateTag) rTagManagement.DELETE("/deleteTag", member_center.DeleteTag) } rLevelManagement := r.Group("/levelManagement") { rLevelManagement.GET("/getLevelList", member_center.GetLevelList) rLevelManagement.GET("/getOneLevel", member_center.GetOneLevel) rLevelManagement.POST("/updateLevel", member_center.UpdateLevel) rLevelManagement.POST("/addLevel", member_center.AddLevel) rLevelManagement.DELETE("/deleteLevel", member_center.DeleteLevel) rLevelManagement.DELETE("/deleteLevelTask", member_center.DeleteLevelTask) } rCertificate := r.Group("/certificate") { rCertificate.POST("/list", member_center.CertificateList) rCertificate.POST("/save", member_center.CertificateSave) rCertificate.POST("/del", member_center.CertificateDel) } } func rIm(r *gin.RouterGroup) { r.GET("/getBasic", im.GetBasic) r.POST("/setBasic", im.SetBasic) r.POST("/pageEmoticon", im.PageEmoticon) r.POST("/addEmoticon", im.AddEmoticon) r.POST("/setEmoticonState", im.SetEmoticonState) r.POST("/updateEmoticon", im.UpdateEmoticon) r.POST("/deleteEmoticon", im.DeleteEmoticon) r.POST("/pageCustomerService", im.PageCustomerService) r.POST("/addCustomerService", im.AddCustomerService) r.POST("/setCustomerServiceState", im.SetCustomerServiceState) r.POST("/updateCustomerServiceMemo", im.UpdateCustomerServiceMemo) r.GET("/redPackageRecordsDetail", im.RedPackageRecordsDetail) r.POST("/pageSendRedPackageOrd", im.PageSendRedPackageOrd) r.POST("/groupList", im.GroupList) r.POST("/groupUserList", im.GroupUserList) r.POST("/batchSendGroupMessage", im.BatchSendGroupMessage) r.POST("/batchSendUserMessage", im.BatchSendUserMessage) } func rFinancialCenter(r *gin.RouterGroup) { rWithdraw := r.Group("/withdraw") { rWithdraw.GET("/setting", financial_center.GetWithdrawSetting) rWithdraw.POST("/updateWithdrawSetting", financial_center.UpdateWithdrawSetting) rWithdraw.POST("/applyList", financial_center.GetWithdrawApplyList) rWithdraw.POST("/audit", financial_center.WithdrawApplyAudit) } } func rFriendCircleSettings(r *gin.RouterGroup) { rBasic := r.Group("/basic") { rBasic.GET("/index", friend_circle.GetFriendCircleBasicSettings) // 获取动态基础设置 rBasic.POST("/save", friend_circle.UpdateFriendCircleBasicSettings) // 更新动态设置 } rBlackList := r.Group("/blackList") { rBlackList.GET("/index", friend_circle.GetBlackList) // 获取黑名单 rBlackList.POST("/add", friend_circle.AddBlackList) // 添加黑名单 rBlackList.DELETE("/del", friend_circle.DeleteBlackList) // 删除黑名单 } rDynamic := r.Group("/dynamic") { rDynamic.POST("/index", friend_circle.GetDynamic) // 获取动态列表 rDynamic.POST("/update", friend_circle.UpdateDynamic) // 更新动态 rDynamic.DELETE("/del", friend_circle.DeleteDynamic) // 删除动态 rDynamic.POST("/release", friend_circle.ReleaseDynamic) // 发布动态 } } func rRole(r *gin.RouterGroup) { r.GET("/roleList", hdl.RoleList) // 角色列表 r.POST("/addRole", hdl.AddRole) // 角色添加 r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) // 角色绑定权限组 r.POST("/updateRoleState", hdl.UpdateRoleState) // 修改角色状态 r.POST("/updateRole", hdl.UpdateRole) // 修改角色状态 r.DELETE("/deleteRole/:id", hdl.DeleteRole) // 删除角色 r.GET("/permissionGroupList", hdl.PermissionGroupList) // 权限组列表 r.POST("/adminList", hdl.AdminList) // 管理员列表 r.POST("/updateAdminState", hdl.UpdateAdminState) // 修改管理员状态 r.POST("/updateAdmin", hdl.UpdateAdmin) // 修改管理员信息 r.POST("/addAdmin", hdl.AddAdmin) // 新增管理员 r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员 r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息 r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色 } func rAdminLog(r *gin.RouterGroup) { r.POST("/list", hdl.AdminLog) // } func rComm(r *gin.RouterGroup) { r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表 r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL r.GET("/getSTSVoucher", comm.GetSTSVoucher) // 获取 STS 凭证 r.GET("/adminInfo", comm.GetAdminInfo) }