zhangqian
2024-01-08 f1842bf9b5bb69b5078a215c02cb16b7e33f893a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package router
 
import (
    v1 "aps_crm/api/v1"
    "aps_crm/conf"
    _ "aps_crm/docs"
    "aps_crm/middleware"
    "fmt"
    "github.com/gin-contrib/cors"
    "github.com/gin-gonic/gin"
    swaggerFiles "github.com/swaggo/files"
    ginSwagger "github.com/swaggo/gin-swagger"
    "net/http"
)
 
type Group struct {
    CurrencyRouter
    QuotationStatusRouter
    RepositoryRouter
    SalesReturnStatusRouter
    AccountIdRouter
    IsInvoiceRouter
    RefundMethodRouter
    ServiceContractTypeRouter
    ServiceContractStatusRouter
    OrderTypeRouter
    ReportSourceRouter
    IsVisitRouter
    SolveRateRouter
    TimelyRateRouter
    //BaseRouter
    //UserRouter
    JwtRouter
    CountryRouter
    ProvinceRouter
    CityRouter
    RegionRouter
    ContactRouter
    ClientRouter
    ClientStatusRouter
    ClientTypeRouter
    ClientOriginRouter
    ClientLevelRouter
    IndustryRouter
    EnterpriseNatureRouter
    RegisteredCapitalRouter
    EnterpriseScaleRouter
    SalesLeadsRouter
    SalesSourcesRouter
    FollowRecordRouter
    SaleChanceRouter
    SaleStageRouter
    SaleTypeRouter
    RegularCustomersRouter
    PossibilityRouter
    StatusRouter
    QuotationRouter
    MasterOrderRouter
    SubOrderRouter
    SalesDetailsRouter
    SalesReturnRouter
    SalesRefundRouter
    ContractRouter
    PlanRouter
    ServiceContractRouter
    OrderManageRouter
    ServiceFollowupRouter
    CustomerServiceSheetRouter
    ServiceFeeManageRouter
    AuthorityRouter
    MenuRouter
    DataRouter
    DepartmentRouter
    SatisfactionRouter
    AssignRouter
    CollectionProjectionRouter
    ContactInformationRouter
}
 
func InitRouter() *gin.Engine {
    gin.SetMode(gin.ReleaseMode)
 
    Router := gin.Default()
    Router.Use(gin.Recovery())
    if conf.Conf.System.Env == "develop" {
        Router.Use(gin.Logger())
    }
    Router.Use(cors.Default())
    Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
 
    //获取所有路由 //todo
    Router.GET("getRouters", func(c *gin.Context) {
        routers := Router.Routes()
        for _, v := range routers {
            fmt.Printf("\"%v\" : 1,\n", v.Path)
        }
    })
 
    routerGroup := new(Group)
    PublicGroup := Router.Group("api")
 
    {
        // 健康监测
        PublicGroup.GET("/health", func(c *gin.Context) {
            c.JSON(http.StatusOK, "ok")
        })
    }
    //{
    //    routerGroup.InitBaseRouter(PublicGroup)  // 注册基础功能路由 不做鉴权
    //    routerGroup.InitImageRouter(PublicGroup) // 图像功能路由
    //}
 
    PrivateGroup := Router.Group("api")
    //PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
    PrivateGroup.Use(middleware.JWTAuth2())
    //PrivateGroup.Use(middleware.CasbinHandler())
    {
        routerGroup.InitJwtRouter(PrivateGroup) // jwt相关路由
        //routerGroup.InitUserRouter(PrivateGroup)                 // 注册用户路由
        routerGroup.InitCountryRouter(PrivateGroup)              // 注册country路由
        routerGroup.InitProvinceRouter(PrivateGroup)             // 注册province路由
        routerGroup.InitCityRouter(PrivateGroup)                 // 注册city路由
        routerGroup.InitRegionRouter(PrivateGroup)               // 注册region路由
        routerGroup.InitContactRouter(PrivateGroup)              // 注册contact路由
        routerGroup.InitClientRouter(PrivateGroup)               // 注册client路由
        routerGroup.InitClientStatusRouter(PrivateGroup)         // 注册clientStatus路由
        routerGroup.InitClientTypeRouter(PrivateGroup)           // 注册clientType路由
        routerGroup.InitClientOriginRouter(PrivateGroup)         // 注册clientOrigin路由
        routerGroup.InitClientLevelRouter(PrivateGroup)          // 注册clientLevel路由
        routerGroup.InitIndustryRouter(PrivateGroup)             // 注册industry路由
        routerGroup.InitEnterpriseNatureRouter(PrivateGroup)     // 注册enterpriseNature路由
        routerGroup.InitRegisteredCapitalRouter(PrivateGroup)    // 注册registeredCapital路由
        routerGroup.InitEnterpriseScaleRouter(PrivateGroup)      // 注册enterpriseScale路由
        routerGroup.InitSalesLeadsRouter(PrivateGroup)           // 注册salesLeads路由
        routerGroup.InitSalesSourcesRouter(PrivateGroup)         // 注册salesSources路由
        routerGroup.InitFollowRecordRouter(PrivateGroup)         // 注册followRecord路由
        routerGroup.InitSaleChanceRouter(PrivateGroup)           // 注册saleChance路由
        routerGroup.InitSaleStageRouter(PrivateGroup)            // 注册saleStage路由
        routerGroup.InitSaleTypeRouter(PrivateGroup)             // 注册saleType路由
        routerGroup.InitRegularCustomersRouter(PrivateGroup)     // 注册regularCustomers路由
        routerGroup.InitPossibilityRouter(PrivateGroup)          // 注册possibility路由
        routerGroup.InitStatusRouter(PrivateGroup)               // 注册status路由
        routerGroup.InitQuotationRouter(PrivateGroup)            // 注册quotation路由
        routerGroup.InitMasterOrderRouter(PrivateGroup)          // 注册masterOrder路由
        routerGroup.InitSubOrderRouter(PrivateGroup)             // 注册subOrder路由
        routerGroup.InitSalesDetailsRouter(PrivateGroup)         // 注册salesDetails路由
        routerGroup.InitSalesReturnRouter(PrivateGroup)          // 注册salesReturn路由
        routerGroup.InitSalesRefundRouter(PrivateGroup)          // 注册salesRefund路由
        routerGroup.InitContractRouter(PrivateGroup)             // 注册contract路由
        routerGroup.InitPlanRouter(PrivateGroup)                 // 注册plan路由
        routerGroup.InitServiceContractRouter(PrivateGroup)      // 注册serviceContract路由
        routerGroup.InitOrderManageRouter(PrivateGroup)          // 注册orderManage路由
        routerGroup.InitServiceFollowupRouter(PrivateGroup)      // 注册serviceFollowup路由
        routerGroup.InitCustomerServiceSheetRouter(PrivateGroup) // 注册customerServiceSheet路由
        routerGroup.InitServiceFeeManageRouter(PrivateGroup)     // 注册serviceFeeManage路由
        routerGroup.InitAuthorityRouter(PrivateGroup)            // 注册authority路由
        routerGroup.InitMenuRouter(PrivateGroup)                 // 注册menu路由
        routerGroup.InitDataRouter(PrivateGroup)                 // 注册data路由
        routerGroup.InitDepartmentRouter(PrivateGroup)           // 注册department路由
        routerGroup.InitSatisfactionRouter(PrivateGroup)         // 注册satisfaction路由
        routerGroup.InitTimelyRateRouter(PrivateGroup)
        routerGroup.InitSolveRateRouter(PrivateGroup)
        routerGroup.InitIsVisitRouter(PrivateGroup)
        routerGroup.InitReportSourceRouter(PrivateGroup)
        routerGroup.InitOrderTypeRouter(PrivateGroup)
        routerGroup.InitServiceContractStatusRouter(PrivateGroup)
        routerGroup.InitServiceContractTypeRouter(PrivateGroup)
        routerGroup.InitRefundMethodRouter(PrivateGroup)
        routerGroup.InitIsInvoiceRouter(PrivateGroup)
        routerGroup.InitAccountIdRouter(PrivateGroup)
        routerGroup.InitSalesReturnStatusRouter(PrivateGroup)
        routerGroup.InitRepositoryRouter(PrivateGroup)
        routerGroup.InitQuotationStatusRouter(PrivateGroup)
        routerGroup.InitCurrencyRouter(PrivateGroup)
        routerGroup.InitAssignRouter(PrivateGroup)
        InitServiceOrderRouter(PrivateGroup)
        InitFaqRouter(PrivateGroup)
        InitPriorityLevelRouter(PrivateGroup)
        InitServiceTypeRouter(PrivateGroup)
        InitSeverityRouter(PrivateGroup)
        InitTimeSpentRouter(PrivateGroup)
        InitFaultTypeRouter(PrivateGroup)
        InitServiceCollectionPlanRouter(PrivateGroup)
        InitReceiptRouter(PrivateGroup)
        InitBankAccountRouter(PrivateGroup)
        InitPaymentTypeRouter(PrivateGroup)
        InitRefundTypeRouter(PrivateGroup)
        InitFileRouter(PrivateGroup)
        InitInvoiceRouter(PrivateGroup)
        InitInvoiceStatusRouter(PrivateGroup)
        InitInvoiceTypeRouter(PrivateGroup)
        InitCourierCompanyRouter(PrivateGroup)
        InitProductRouter(PrivateGroup)
        routerGroup.InitCollectionProjectionRouter(PrivateGroup)
        routerGroup.InitContactInformationRouter(PrivateGroup)
    }
    codeGroup := PrivateGroup.Group("code")
    codeApi := v1.CodeApi{}
    {
        codeGroup.GET("getCodeList", codeApi.GetCodeList)  //获取编码列表
        codeGroup.POST("getAutoCode", codeApi.GetAutoCode) //获取编码列表
    }
 
    //系统设置
    systemSetGroup := PrivateGroup.Group("system")
    systemSetApi := v1.SystemSetApi{}
    {
        systemSetGroup.GET("getSystemSet", systemSetApi.GetSystemSet)
        systemSetGroup.POST("saveSystemSet", systemSetApi.SaveSystemSet)
        systemSetGroup.GET("useSystemSet/:modeType", systemSetApi.UseSystemSet)
    }
 
    return Router
}