| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- package routers
- import (
- "mtp2_if/config"
- "mtp2_if/controllers/cfg"
- "mtp2_if/controllers/common"
- "mtp2_if/controllers/cptrade"
- "mtp2_if/controllers/delivery"
- "mtp2_if/controllers/ermcp"
- "mtp2_if/controllers/erms2"
- "mtp2_if/controllers/erms3"
- "mtp2_if/controllers/hsby"
- "mtp2_if/controllers/market"
- "mtp2_if/controllers/order"
- "mtp2_if/controllers/quote"
- "mtp2_if/controllers/search"
- "mtp2_if/controllers/szdz"
- "mtp2_if/controllers/taaccount"
- "mtp2_if/controllers/trade"
- "mtp2_if/controllers/user"
- "mtp2_if/controllers/wr"
- "mtp2_if/controllers/wrtrade"
- "mtp2_if/logger"
- "mtp2_if/token"
- "net/http"
- "time"
- "github.com/gin-gonic/gin"
- // Swagger生成的文档
- _ "mtp2_if/docs"
- ginSwagger "github.com/swaggo/gin-swagger"
- "github.com/swaggo/gin-swagger/swaggerFiles"
- )
- // InitRouter 初始化路由器的方法
- func InitRouter() *gin.Engine {
- r := gin.New()
- // 设置日志中间件
- r.Use(ginLoggerMiddleware())
- // 设置奔溃中间件
- r.Use(ginRecoveryMiddleware())
- // 跨域
- r.Use(CORSMiddleware())
- // Swagger
- if config.SerCfg.GetDebugMode() {
- r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
- }
- // 终端配置
- r.GET("/cfg", cfg.QueryCfg)
- // 主业务路由分组
- apiR := r.Group("/api")
- // apiR.Use(token.Auth())
- // ************************ 账户信息 ************************
- userR := apiR.Group("User")
- userR.Use()
- {
- // 获取登录ID
- userR.GET("/GetLoginID", user.GetLoginID)
- // 获取用户邀请码请求参数
- userR.GET("/QueryUserReferNum", user.QueryUserReferNum)
- // 获取用户信息请求参数
- userR.Use(token.Auth()).GET("/QueryUserInfo", user.QueryUserInfo)
- // 获取用户实名认证状态
- userR.Use(token.Auth()).GET("/GetUserAuthStatus", user.GetUserAuthStatus)
- // 获取用户商品收藏信息
- userR.Use(token.Auth()).GET("/QueryUserFavoriteGoodses", user.QueryUserFavoriteGoodses)
- // 添加用户商品收藏信息
- userR.Use(token.Auth()).POST("/AddUserFavoriteGoods", user.AddUserFavoriteGoods)
- // 移除用户商品收藏信息
- userR.Use(token.Auth()).POST("/RemoveUserFavoriteGoods", user.RemoveUserFavoriteGoods)
- // 获取用户留言板信息
- userR.Use(token.Auth()).GET("/QueryMessageBoard", user.QueryMessageBoard)
- // 添加用户留言板信息
- userR.Use(token.Auth()).POST("/AddMessageBoard", user.AddMessageBoard)
- // 获取用户账号信息
- userR.Use(token.Auth()).GET("/GetUserAccount", user.GetUserAccount)
- }
- // ************************ 资金账户 ************************
- taAccountR := apiR.Group("TaAccount")
- taAccountR.Use(token.Auth())
- {
- // 资金流水查询(当前)
- taAccountR.GET("/QueryAmountLog", taaccount.QueryAmountLog)
- // 资金流水查询(历史)
- taAccountR.GET("/QueryHisAmountLog", taaccount.QueryHisAmountLog)
- }
- // ************************ 通用服务 ************************
- commonR := apiR.Group("Common")
- commonR.Use()
- {
- // 查询交易端菜单
- commonR.GET("/QueryTraderMenu", common.QueryTraderMenu)
- // 查询交易端列表头信息
- commonR.GET("/QueryTableDefine", common.QueryTableDefine)
- // 查询省市信息(不包括区)
- commonR.GET("/QueryProvincesAndCities", common.QueryProvincesAndCities)
- // 查询轮播图配置信息
- commonR.GET("/QueryImageConfigs", common.QueryImageConfigs)
- // 获取所有枚举信息
- commonR.GET("/GetAllEnums", common.GetAllEnums)
- // 获取服务器时间
- commonR.GET("/GetServerTime", common.GetServerTime)
- // 通知公告系统消息查询
- commonR.Use(token.Auth()).GET("/QueryNotice", common.QueryNotice)
- // 通知公告设置已读请求
- commonR.Use(token.Auth()).POST("/NoticeReaded", common.NoticeReaded)
- }
- // ************************ 通用市场 ************************
- marketR := apiR.Group("Market")
- marketR.Use(token.Auth())
- {
- // 查询市场运行信息
- marketR.GET("/QueryMarketRun", market.QueryMarketRun)
- }
- // ************************ 通用单据 ************************
- orderR := apiR.Group("Order")
- orderR.Use(token.Auth())
- {
- // 持仓汇总查询(合约市场)
- orderR.GET("/QueryTradePosition", order.QueryTradePosition)
- // 委托单查询请求(合约市场)
- orderR.GET("/QueryTradeOrderDetail", order.QueryTradeOrderDetail)
- // 历史委托单查询请求(合约市场)
- orderR.GET("/QueryHisTradeOrderDetail", order.QueryHisTradeOrderDetail)
- // 成交单查询(合约市场)
- orderR.GET("/QueryTradeDetail", order.QueryTradeDetail)
- // 历史成交单查询(合约市场)
- orderR.GET("/QueryHisTradeDetail", order.QueryHisTradeDetail)
- }
- // ************************ 通用交易 ************************
- tradeR := apiR.Group("Trade")
- tradeR.Use(token.Auth())
- {
- // 点选挂牌委托单据查询(保证金摘牌大厅)
- tradeR.GET("/QueryRecieptOrder", trade.QueryRecieptOrder)
- }
- // ************************ 行情服务 ************************
- quoteR := apiR.Group("Quote")
- quoteR.Use(token.Auth())
- {
- // 查询行情历史数据
- quoteR.GET("/QueryHistoryDatas", quote.QueryHistoryDatas)
- }
- // ************************ 检索服务 ************************
- searchR := apiR.Group("Search")
- searchR.Use()
- {
- // 检索商品信息
- searchR.GET("/SearchGoodses", search.Goodses)
- }
- // ************************ 仓单贸易 ************************
- wrTradeR := apiR.Group("WRTrade")
- wrTradeR.Use(token.Auth())
- {
- wrTradeR.GET("/GetAllDeliveryGoods", wrtrade.GetAllDeliveryGoods)
- }
- // ************************ 产能预售 ************************
- cpTradeR := apiR.Group("CPTrade")
- cpTradeR.Use(token.Auth())
- {
- // 查询产能预售申请表
- cpTradeR.GET("/QueryPreasleApply", cptrade.QueryPreasleApply)
- // 查询远期订单信息
- cpTradeR.GET("/QueryUserGoodsData", cptrade.QueryUserGoodsData)
- // 查询远期订单注销申请信息
- cpTradeR.GET("/QueryPositionCancel", cptrade.QueryPositionCancel)
- // 查询产能预售商品扩展信息
- cpTradeR.GET("/QueryPresaleGoodsEx", cptrade.QueryPresaleGoodsEx)
- // 查询产能预售我的出价信息
- cpTradeR.GET("/QueryCPTradeMyBidInfos", cptrade.QueryCPTradeMyBidInfos)
- // 查询我的预售信息
- cpTradeR.GET("/QueryMyCPTradeGoods", cptrade.QueryMyCPTradeGoods)
- // 查询产能预售委托单信息
- cpTradeR.GET("/QueryCPTradeOrderDetail", cptrade.QueryCPTradeOrderDetail)
- }
- // ************************ 仓单服务 ************************
- wrR := apiR.Group("WR")
- wrR.Use()
- {
- // 获取现货分类信息
- wrR.GET("/GetWRCategoryInfo", wr.GetWRCategoryInfo)
- }
- // ************************ 交割服务 ************************
- deliveryR := apiR.Group("Delivery")
- deliveryR.Use(token.Auth())
- {
- // 查询商品交割关系表
- deliveryR.GET("/QueryDeliveryRelation", delivery.QueryDeliveryRelation)
- }
- // ************************ 风险管理 ************************
- erms2R := apiR.Group("Erms2")
- erms2R.Use(token.Auth())
- {
- // 查询内部成交单信息
- erms2R.GET("/QueryInnerTradeDetail", erms2.QueryInnerTradeDetail)
- // 查询期现套利策略表信息(指定资金账户、未结束的)
- erms2R.GET("/QueryArbitrageStrategy", erms2.QueryArbitrageStrategy)
- // 查询现货合同表信息(指定策略ID、未结束的)
- erms2R.GET("/QuerySpotContract", erms2.QuerySpotContract)
- }
- // ************************ 风险管理v3 ************************
- erms3R := apiR.Group("Erms3")
- erms3R.Use(token.Auth())
- {
- // 新增现货合同申请
- erms3R.POST("/AddSpotContractApply", erms3.AddSpotContractApply)
- // 查询合同申请表单数据
- erms3R.GET("/QuerySpotContractAppleForm", erms3.QuerySpotContractAppleForm)
- // 查询合同详细信息.
- erms3R.GET("/QuerySpotContractDetail", erms3.QuerySpotContractDetail)
- // 查询待审核合同
- erms3R.GET("/QueryPendingAuditContract", erms3.QueryPendingAuditContract)
- // 新增客户申请
- erms3R.POST("/AddUserInfoApply", erms3.AddUserInfoApply)
- // 客户申请信息查询
- erms3R.GET("/QueryUserInfoApplies", erms3.QueryUserInfoApplies)
- // 待审核业务查询
- erms3R.GET("/QueryPendingBusiness", erms3.QueryPendingBusiness)
- // 业务信息查询
- erms3R.GET("/QueryBusinessInfo", erms3.QueryBusinessInfo)
- // 客户信息查询
- erms3R.GET("/QueryUserInfos", erms3.QueryUserInfos)
- // 新增期现套利业务申请
- erms3R.POST("/AddErms2ASApply", erms3.AddErms2ASApply)
- // 新增现货贸易业务申请
- erms3R.POST("/AddErms2SpotTradeApply", erms3.AddErms2SpotTradeApply)
- }
- // ************************ 定制【尚志大宗】 ************************
- szdzR := apiR.Group("SZDZ")
- szdzR.Use(token.Auth())
- {
- // 点选挂牌委托单据查询(摘牌大厅)
- szdzR.GET("/QueryRecieptOrder", szdz.QueryRecieptOrder)
- // 商品提货单查询
- szdzR.GET("/QueryGoodsPickup", szdz.QueryGoodsPickup)
- // 交易系统转换流水查询
- szdzR.GET("/QueryConvertLog", szdz.QueryConvertLog)
- // 搜索白名单
- szdzR.GET("/SearchWhite", szdz.SearchWhite)
- // 查询交易系统转换设置
- szdzR.GET("/QueryConvertConfig", szdz.QueryConvertConfig)
- // 持仓汇总查询(尚志大宗)
- szdzR.GET("/QuerySZDZTradePosition", szdz.QuerySZDZTradePosition)
- }
- // ************************ 定制【海商报业】 ************************
- hsbyR := apiR.Group("HSBY")
- hsbyR.Use(token.AuthByHsby())
- {
- // 查询热门商品列表(二级市场,挂牌点选)
- hsbyR.GET("/QueryHsbyTopGoodses", hsby.QueryHsbyTopGoodses)
- // 查询二级市场(挂牌点选)商品信息详情
- hsbyR.GET("/QueryHsbyListingGoodsDetail", hsby.QueryHsbyListingGoodsDetail)
- // 查询二级市场(挂牌点选)商品对应的挂牌委托单信息
- hsbyR.GET("/QueryHsbyGoodsOrderDetails", hsby.QueryHsbyGoodsOrderDetails)
- // 查询“我的订单”信息
- hsbyR.GET("/QueryHsbyMyBuyOrderDetails", hsby.QueryHsbyMyBuyOrderDetails)
- // 查询“我的商品”信息
- hsbyR.GET("/QueryHsbyMyGoods", hsby.QueryHsbyMyGoods)
- // 查询新品上市商品列表(一级市场预售)
- hsbyR.GET("/QueryHsbyPreGoodses", hsby.QueryHsbyPreGoodses)
- // 查询一级市场(预售)商品信息详情
- hsbyR.GET("/QueryHsbyPreGoodsDetail", hsby.QueryHsbyPreGoodsDetail)
- // 查询"我的闲置"单据信息
- hsbyR.GET("/QueryHsbySellMyDetails", hsby.QueryHsbySellMyDetails)
- // 查询我的包裹信息
- hsbyR.GET("/QueryHsbyMyPackages", hsby.QueryHsbyMyPackages)
- // 设置我的包裹已收货状态
- hsbyR.POST("/SetHsbyMyPackagesStatus", hsby.SetHsbyMyPackagesStatus)
- // 查询省市信息(不包括区)
- hsbyR.GET("/QueryProvincesAndCities", hsby.QueryProvincesAndCities)
- // 查询"我的订单 - 已完成"单据信息
- hsbyR.GET("/QueryHsbyBuyMyTradeDetail", hsby.QueryHsbyBuyMyTradeDetail)
- // 获取我的订单与包裹数量
- hsbyR.GET("/GetHsbyMyCount", hsby.GetHsbyMyCount)
- // 获取我的订单中待付款信息
- hsbyR.GET("/QueryMyPayOrders", hsby.QueryMyPayOrders)
- // 获取我的闲置中收款信息查询
- hsbyR.GET("/QueryMyCollectionOrders", hsby.QueryMyCollectionOrders)
- // 查询海商报业相关市场信息
- hsbyR.GET("/QueryHsbyMarkets", hsby.QueryHsbyMarkets)
- // 查询特卖商品列表(三级商城)
- hsbyR.GET("/QueryHsbyMarketGoodses", hsby.QueryHsbyMarketGoodses)
- // 查询三级市场(商城)商品信息详情
- hsbyR.GET("/QueryHsbyMarketGoodsDetail", hsby.QueryHsbyMarketGoodsDetail)
- // 我的优惠卷查询
- hsbyR.GET("/QueryMyCoupons", hsby.QueryMyCoupons)
- // 我的优惠卷持仓查询
- hsbyR.GET("/QueryMyCouponHolds", hsby.QueryMyCouponHolds)
- // 已使用优惠卷查询
- hsbyR.GET("/QueryMyUsedCoupon", hsby.QueryMyUsedCoupon)
- }
- // ***************************** 企业风险管理(app)***************************
- ermcpR := apiR.Group("Ermcp")
- ermcpR.Use(token.Auth())
- {
- // 查询待点价、履约和全部合同
- ermcpR.GET("/QueryUserInfo", ermcp.QueryUserInfo)
- ermcpR.GET("/QuerySpotContract", ermcp.QuerySpotContract)
- ermcpR.GET("/QueryContract", ermcp.QueryContract)
- ermcpR.GET("/QueryHedgePlan", ermcp.QueryHedgePlan)
- ermcpR.GET("/QueryBusinessDj", ermcp.QueryBusinessDj)
- ermcpR.GET("/QueryBusinessJs", ermcp.QueryBusinessJs)
- ermcpR.GET("/QueryBusinessKx", ermcp.QueryBusinessKx)
- ermcpR.GET("/QueryBusinessFp", ermcp.QueryBusinessFp)
- }
- return r
- }
- func ginLoggerMiddleware() gin.HandlerFunc {
- return func(c *gin.Context) {
- start := time.Now()
- c.Next()
- end := time.Now()
- latency := end.Sub(start)
- path := c.Request.URL.RequestURI()
- clientip := c.ClientIP()
- method := c.Request.Method
- statuscode := c.Writer.Status()
- logger.GetLogger().Debugf("|%3d|%13v|%15s|%s %s",
- statuscode,
- latency,
- clientip,
- method,
- path)
- }
- }
- func ginRecoveryMiddleware() gin.HandlerFunc {
- return gin.RecoveryWithWriter(logger.GetLogWriter())
- }
- // CORSMiddleware cors跨域.
- func CORSMiddleware() gin.HandlerFunc {
- return func(c *gin.Context) {
- c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
- c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
- c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With, X-session-Token")
- c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
- c.Writer.Header().Set("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type, X-session-Token")
- if c.Request.Method == "OPTIONS" {
- c.AbortWithStatus(http.StatusNoContent)
- return
- }
- c.Next()
- }
- }
|