|
- package router
-
- import (
- "applet/app/cfg"
- "applet/app/hdl"
- "applet/app/hdl/advertising"
- "applet/app/hdl/article"
- "applet/app/hdl/comm"
- "applet/app/hdl/financial_center"
- "applet/app/hdl/im"
- "applet/app/hdl/institutional_management/egg_energy"
- "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/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.Use(mw.Auth) // 以下接口需要JWT验证
- rComm(r.Group("/comm"))
- rIm(r.Group("/im"))
- r.Use(mw.CheckPermission) // 检测权限
- rInstitutionalManagement(r.Group("/institutionalManagement"))
- rMarketingApplications(r.Group("/marketingApplications"))
- rMemberCenter(r.Group("/memberCenter"))
- rSettCenter(r.Group("/settCenter"))
- rFinancialCenter(r.Group("/financialCenter"))
- rAdvertising(r.Group("/advertising"))
- rNotice(r.Group("/notice"))
- rArticle(r.Group("/article"))
- }
-
- func rSettCenter(r *gin.RouterGroup) { //设置中心
- rOss := r.Group("/oss") //oss设置
- {
- rOssAliYun := rOss.Group("/aliYun") //阿里云
- {
- rOssAliYun.GET("/getBasic", aliyun.GetBasic)
- rOssAliYun.POST("/setBasic", aliyun.SetBasic)
- }
- }
- }
- func rAdvertising(r *gin.RouterGroup) {
- r.GET("/getBasic", advertising.GetBasic)
- }
- func rNotice(r *gin.RouterGroup) {
- rJpush := r.Group("/jPush") //极光
- {
- rJpush.POST("/list", notice.List)
- rJpush.POST("/save", notice.Save)
- rJpush.POST("/del", notice.Del)
- rJpush.POST("/push/list", notice.PushList)
- rJpush.POST("/push/save", notice.PushSave)
- }
- rAliyunSms := r.Group("/aliyunSms") //阿里云短信
- {
- rAliyunSms.POST("/file/phone", notice.AliyunSmsFilePhone)
- rAliyunSms.GET("/base", notice.AliyunSmsBase)
- rAliyunSms.POST("/save", notice.AliyunSmsSave)
- 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 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.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)
- }
- rUserDailyActivityAnalysis := rPublicPlatoon.Group("/userDailyActivityAnalysis")
- {
- rUserDailyActivityAnalysis.POST("/index", public_platoon.UserDailyActivityAnalysis)
- }
- }
-
- rEggEnergy := r.Group("/eggEnergy") //蛋蛋能量
- {
- rEggEnergy.GET("/getVirtualCoinList", egg_energy.GetVirtualCoinList)
- 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)
- 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)
- }
- }
- }
-
- 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.GET("/userData", member_center.UserManagementGetOneBasic)
- rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo)
- 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.POST("/addLevelTask", member_center.AddLevelTask)
- rLevelManagement.POST("/updateLevelTask", member_center.UpdateLevelTask)
- rLevelManagement.DELETE("/deleteLevelTask", member_center.DeleteLevelTask)
- }
- }
-
- 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)
- }
-
- func rFinancialCenter(r *gin.RouterGroup) {
- rWithdraw := r.Group("/withdraw")
- {
- rWithdraw.GET("/setting", financial_center.GetWithdrawSetting)
- rWithdraw.POST("/updateWithdrawSetting", financial_center.UpdateWithdrawSetting)
- rWithdraw.GET("/applyList", financial_center.GetWithdrawApplyList)
- }
- }
-
- func rComm(r *gin.RouterGroup) {
- r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表
- r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
- }
|