router.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. package routers
  2. import (
  3. "mtp2_if/config"
  4. "mtp2_if/controllers/cfg"
  5. "mtp2_if/controllers/common"
  6. "mtp2_if/controllers/cptrade"
  7. "mtp2_if/controllers/delivery"
  8. "mtp2_if/controllers/ermcp"
  9. "mtp2_if/controllers/erms2"
  10. "mtp2_if/controllers/erms3"
  11. "mtp2_if/controllers/hsby"
  12. "mtp2_if/controllers/market"
  13. "mtp2_if/controllers/order"
  14. "mtp2_if/controllers/quote"
  15. "mtp2_if/controllers/search"
  16. "mtp2_if/controllers/szdz"
  17. "mtp2_if/controllers/taaccount"
  18. "mtp2_if/controllers/trade"
  19. "mtp2_if/controllers/user"
  20. "mtp2_if/controllers/wr"
  21. "mtp2_if/controllers/wrtrade"
  22. "mtp2_if/logger"
  23. "mtp2_if/token"
  24. "net/http"
  25. "time"
  26. "github.com/gin-gonic/gin"
  27. // Swagger生成的文档
  28. _ "mtp2_if/docs"
  29. ginSwagger "github.com/swaggo/gin-swagger"
  30. "github.com/swaggo/gin-swagger/swaggerFiles"
  31. )
  32. // InitRouter 初始化路由器的方法
  33. func InitRouter() *gin.Engine {
  34. r := gin.New()
  35. // 设置日志中间件
  36. r.Use(ginLoggerMiddleware())
  37. // 设置奔溃中间件
  38. r.Use(ginRecoveryMiddleware())
  39. // 跨域
  40. r.Use(CORSMiddleware())
  41. // Swagger
  42. if config.SerCfg.GetDebugMode() {
  43. r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  44. }
  45. // 终端配置
  46. r.GET("/cfg", cfg.QueryCfg)
  47. // 主业务路由分组
  48. apiR := r.Group("/api")
  49. // apiR.Use(token.Auth())
  50. // ************************ 账户信息 ************************
  51. userR := apiR.Group("User")
  52. userR.Use()
  53. {
  54. // 获取登录ID
  55. userR.GET("/GetLoginID", user.GetLoginID)
  56. // 获取用户邀请码请求参数
  57. userR.GET("/QueryUserReferNum", user.QueryUserReferNum)
  58. // 获取用户信息请求参数
  59. userR.Use(token.Auth()).GET("/QueryUserInfo", user.QueryUserInfo)
  60. // 获取用户实名认证状态
  61. userR.Use(token.Auth()).GET("/GetUserAuthStatus", user.GetUserAuthStatus)
  62. // 获取用户商品收藏信息
  63. userR.Use(token.Auth()).GET("/QueryUserFavoriteGoodses", user.QueryUserFavoriteGoodses)
  64. // 添加用户商品收藏信息
  65. userR.Use(token.Auth()).POST("/AddUserFavoriteGoods", user.AddUserFavoriteGoods)
  66. // 移除用户商品收藏信息
  67. userR.Use(token.Auth()).POST("/RemoveUserFavoriteGoods", user.RemoveUserFavoriteGoods)
  68. // 获取用户留言板信息
  69. userR.Use(token.Auth()).GET("/QueryMessageBoard", user.QueryMessageBoard)
  70. // 添加用户留言板信息
  71. userR.Use(token.Auth()).POST("/AddMessageBoard", user.AddMessageBoard)
  72. // 获取用户账号信息
  73. userR.Use(token.Auth()).GET("/GetUserAccount", user.GetUserAccount)
  74. // 更新用户状态
  75. userR.Use(token.Auth()).POST("/UpdateUserAccountStatus", user.UpdateUserAccountStatus)
  76. // 账户登录后信息查询
  77. userR.Use(token.Auth()).GET("/LoginQuery", user.LoginQuery)
  78. }
  79. // ************************ 资金账户 ************************
  80. taAccountR := apiR.Group("TaAccount")
  81. taAccountR.Use(token.Auth())
  82. {
  83. // 获取资金账户信息
  84. taAccountR.GET("/GetTaAccounts", taaccount.GetTaAccounts)
  85. // 资金流水查询(当前)
  86. taAccountR.GET("/QueryAmountLog", taaccount.QueryAmountLog)
  87. // 资金流水查询(历史)
  88. taAccountR.GET("/QueryHisAmountLog", taaccount.QueryHisAmountLog)
  89. }
  90. // ************************ 通用服务 ************************
  91. commonR := apiR.Group("Common")
  92. commonR.Use()
  93. {
  94. // 查询交易端菜单
  95. commonR.GET("/QueryTraderMenu", common.QueryTraderMenu)
  96. // 查询交易端列表头信息
  97. commonR.GET("/QueryTableDefine", common.QueryTableDefine)
  98. // 查询省市信息(不包括区)
  99. commonR.GET("/QueryProvincesAndCities", common.QueryProvincesAndCities)
  100. // 查询区域信息
  101. commonR.GET("/GetDivisions", common.GetDivisions)
  102. // 查询轮播图配置信息
  103. commonR.GET("/QueryImageConfigs", common.QueryImageConfigs)
  104. // 获取所有枚举信息
  105. commonR.GET("/GetAllEnums", common.GetAllEnums)
  106. // 获取服务器时间
  107. commonR.GET("/GetServerTime", common.GetServerTime)
  108. // 获取数据库错误信息
  109. commonR.GET("/QueryErrorInfos", common.QueryErrorInfos)
  110. // 通知公告系统消息查询
  111. commonR.Use(token.Auth()).GET("/QueryNotice", common.QueryNotice)
  112. // 通知公告设置已读请求
  113. commonR.Use(token.Auth()).POST("/NoticeReaded", common.NoticeReaded)
  114. // 获取交易端菜单
  115. commonR.Use(token.Auth()).GET("/GetClientMenus", common.GetClientMenus)
  116. }
  117. // ************************ 通用市场 ************************
  118. marketR := apiR.Group("Market")
  119. marketR.Use(token.Auth())
  120. {
  121. // 查询市场运行信息
  122. marketR.GET("/QueryMarketRun", market.QueryMarketRun)
  123. // 获取登录账号有权限的市场信息
  124. marketR.GET("/QueryMarketsByLoginID", market.QueryMarketsByLoginID)
  125. // 获取登录账号有权限的商品信息
  126. marketR.GET("/QueryGoodsesByLoginID", market.QueryGoodsesByLoginID)
  127. }
  128. // ************************ 通用单据 ************************
  129. orderR := apiR.Group("Order")
  130. orderR.Use(token.Auth())
  131. {
  132. // 持仓汇总查询(合约市场)
  133. orderR.GET("/QueryTradePosition", order.QueryTradePosition)
  134. // 委托单查询请求(合约市场)
  135. orderR.GET("/QueryTradeOrderDetail", order.QueryTradeOrderDetail)
  136. // 历史委托单查询请求(合约市场)
  137. orderR.GET("/QueryHisTradeOrderDetail", order.QueryHisTradeOrderDetail)
  138. // 成交单查询(合约市场)
  139. orderR.GET("/QueryTradeDetail", order.QueryTradeDetail)
  140. // 历史成交单查询(合约市场)
  141. orderR.GET("/QueryHisTradeDetail", order.QueryHisTradeDetail)
  142. }
  143. // ************************ 通用交易 ************************
  144. tradeR := apiR.Group("Trade")
  145. tradeR.Use(token.Auth())
  146. {
  147. // 点选挂牌委托单据查询(保证金摘牌大厅)
  148. tradeR.GET("/QueryRecieptOrder", trade.QueryRecieptOrder)
  149. }
  150. // ************************ 行情服务 ************************
  151. quoteR := apiR.Group("Quote")
  152. quoteR.Use(token.AuthByHsby())
  153. {
  154. // 查询行情历史数据
  155. quoteR.GET("/QueryHistoryDatas", quote.QueryHistoryDatas)
  156. // 查询行情Tik数据
  157. quoteR.GET("/QueryHistoryTikDatas", quote.QueryHistoryTikDatas)
  158. // 查询分时图历史数据
  159. quoteR.GET("/QueryTSData", quote.QueryTSData)
  160. // 获取商品盘面信息
  161. quoteR.GET("/QueryQuoteDay", quote.QueryQuoteDay)
  162. }
  163. // ************************ 检索服务 ************************
  164. searchR := apiR.Group("Search")
  165. searchR.Use()
  166. {
  167. // 检索商品信息
  168. searchR.GET("/SearchGoodses", search.Goodses)
  169. }
  170. // ************************ 仓单贸易 ************************
  171. wrTradeR := apiR.Group("WRTrade")
  172. wrTradeR.Use(token.Auth())
  173. {
  174. wrTradeR.GET("/GetAllDeliveryGoods", wrtrade.GetAllDeliveryGoods)
  175. }
  176. // ************************ 产能预售 ************************
  177. cpTradeR := apiR.Group("CPTrade")
  178. cpTradeR.Use(token.Auth())
  179. {
  180. // 查询产能预售申请表
  181. cpTradeR.GET("/QueryPreasleApply", cptrade.QueryPreasleApply)
  182. // 查询远期订单信息
  183. cpTradeR.GET("/QueryUserGoodsData", cptrade.QueryUserGoodsData)
  184. // 查询远期订单注销申请信息
  185. cpTradeR.GET("/QueryPositionCancel", cptrade.QueryPositionCancel)
  186. // 查询产能预售商品扩展信息
  187. cpTradeR.GET("/QueryPresaleGoodsEx", cptrade.QueryPresaleGoodsEx)
  188. // 查询产能预售我的出价信息
  189. cpTradeR.GET("/QueryCPTradeMyBidInfos", cptrade.QueryCPTradeMyBidInfos)
  190. // 查询我的预售信息
  191. cpTradeR.GET("/QueryMyCPTradeGoods", cptrade.QueryMyCPTradeGoods)
  192. // 查询产能预售委托单信息
  193. cpTradeR.GET("/QueryCPTradeOrderDetail", cptrade.QueryCPTradeOrderDetail)
  194. }
  195. // ************************ 仓单服务 ************************
  196. wrR := apiR.Group("WR")
  197. wrR.Use()
  198. {
  199. // 获取现货分类信息
  200. wrR.GET("/GetWRCategoryInfo", wr.GetWRCategoryInfo)
  201. }
  202. // ************************ 交割服务 ************************
  203. deliveryR := apiR.Group("Delivery")
  204. deliveryR.Use(token.Auth())
  205. {
  206. // 查询商品交割关系表
  207. deliveryR.GET("/QueryDeliveryRelation", delivery.QueryDeliveryRelation)
  208. }
  209. // ************************ 风险管理 ************************
  210. erms2R := apiR.Group("Erms2")
  211. erms2R.Use(token.Auth())
  212. {
  213. // 查询内部成交单信息
  214. erms2R.GET("/QueryInnerTradeDetail", erms2.QueryInnerTradeDetail)
  215. // 查询期现套利策略表信息(指定资金账户、未结束的)
  216. erms2R.GET("/QueryArbitrageStrategy", erms2.QueryArbitrageStrategy)
  217. // 查询现货合同表信息(指定策略ID、未结束的)
  218. erms2R.GET("/QuerySpotContract", erms2.QuerySpotContract)
  219. }
  220. // ************************ 风险管理v3 ************************
  221. erms3R := apiR.Group("Erms3")
  222. erms3R.Use(token.Auth())
  223. {
  224. // 新增现货合同申请
  225. erms3R.POST("/AddSpotContractApply", erms3.AddSpotContractApply)
  226. // 查询合同申请表单数据
  227. erms3R.GET("/QuerySpotContractAppleForm", erms3.QuerySpotContractAppleForm)
  228. // 查询合同详细信息.
  229. erms3R.GET("/QuerySpotContractDetail", erms3.QuerySpotContractDetail)
  230. // 查询待审核合同
  231. erms3R.GET("/QueryPendingAuditContract", erms3.QueryPendingAuditContract)
  232. // 新增客户申请
  233. erms3R.POST("/AddUserInfoApply", erms3.AddUserInfoApply)
  234. // 修改客户申请
  235. erms3R.POST("/ModifyUserInfoApply", erms3.ModifyUserInfoApply)
  236. // 客户申请信息查询
  237. erms3R.GET("/QueryUserInfoApplies", erms3.QueryUserInfoApplies)
  238. // 待审核业务查询
  239. erms3R.GET("/QueryPendingBusiness", erms3.QueryPendingBusiness)
  240. // 业务信息查询
  241. erms3R.GET("/QueryBusinessInfo", erms3.QueryBusinessInfo)
  242. // 客户信息查询
  243. erms3R.GET("/QueryUserInfos", erms3.QueryUserInfos)
  244. // 新增期现套利业务申请
  245. erms3R.POST("/AddErms2ASApply", erms3.AddErms2ASApply)
  246. // 新增现货贸易业务申请
  247. erms3R.POST("/AddErms2SpotTradeApply", erms3.AddErms2SpotTradeApply)
  248. }
  249. // ************************ 定制【尚志大宗】 ************************
  250. szdzR := apiR.Group("SZDZ")
  251. szdzR.Use(token.Auth())
  252. {
  253. // 点选挂牌委托单据查询(摘牌大厅)
  254. szdzR.GET("/QueryRecieptOrder", szdz.QueryRecieptOrder)
  255. // 商品提货单查询
  256. szdzR.GET("/QueryGoodsPickup", szdz.QueryGoodsPickup)
  257. // 交易系统转换流水查询
  258. szdzR.GET("/QueryConvertLog", szdz.QueryConvertLog)
  259. // 搜索白名单
  260. szdzR.GET("/SearchWhite", szdz.SearchWhite)
  261. // 查询交易系统转换设置
  262. szdzR.GET("/QueryConvertConfig", szdz.QueryConvertConfig)
  263. // 持仓汇总查询(尚志大宗)
  264. szdzR.GET("/QuerySZDZTradePosition", szdz.QuerySZDZTradePosition)
  265. }
  266. // ************************ 定制【海商报业】 ************************
  267. hsbyR := apiR.Group("HSBY")
  268. hsbyR.Use(token.AuthByHsby())
  269. {
  270. // 查询热门商品列表(二级市场,挂牌点选)
  271. hsbyR.GET("/QueryHsbyTopGoodses", hsby.QueryHsbyTopGoodses)
  272. // 查询二级市场(挂牌点选)商品信息详情
  273. hsbyR.GET("/QueryHsbyListingGoodsDetail", hsby.QueryHsbyListingGoodsDetail)
  274. // 查询二级市场(挂牌点选)商品对应的挂牌委托单信息
  275. hsbyR.GET("/QueryHsbyGoodsOrderDetails", hsby.QueryHsbyGoodsOrderDetails)
  276. // 查询“我的订单”信息
  277. hsbyR.GET("/QueryHsbyMyBuyOrderDetails", hsby.QueryHsbyMyBuyOrderDetails)
  278. // 查询“我的商品”信息
  279. hsbyR.GET("/QueryHsbyMyGoods", hsby.QueryHsbyMyGoods)
  280. // 查询新品上市商品列表(一级市场预售)
  281. hsbyR.GET("/QueryHsbyPreGoodses", hsby.QueryHsbyPreGoodses)
  282. // 查询一级市场(预售)商品信息详情
  283. hsbyR.GET("/QueryHsbyPreGoodsDetail", hsby.QueryHsbyPreGoodsDetail)
  284. // 查询"我的闲置"单据信息
  285. hsbyR.GET("/QueryHsbySellMyDetails", hsby.QueryHsbySellMyDetails)
  286. // 查询我的包裹信息
  287. hsbyR.GET("/QueryHsbyMyPackages", hsby.QueryHsbyMyPackages)
  288. // 设置我的包裹已收货状态
  289. hsbyR.POST("/SetHsbyMyPackagesStatus", hsby.SetHsbyMyPackagesStatus)
  290. // 查询省市信息(不包括区)
  291. hsbyR.GET("/QueryProvincesAndCities", hsby.QueryProvincesAndCities)
  292. // 查询"我的订单 - 已完成"单据信息
  293. hsbyR.GET("/QueryHsbyBuyMyTradeDetail", hsby.QueryHsbyBuyMyTradeDetail)
  294. // 获取我的订单与包裹数量
  295. hsbyR.GET("/GetHsbyMyCount", hsby.GetHsbyMyCount)
  296. // 获取我的订单中待付款信息
  297. hsbyR.GET("/QueryMyPayOrders", hsby.QueryMyPayOrders)
  298. // 获取我的闲置中收款信息查询
  299. hsbyR.GET("/QueryMyCollectionOrders", hsby.QueryMyCollectionOrders)
  300. // 查询海商报业相关市场信息
  301. hsbyR.GET("/QueryHsbyMarkets", hsby.QueryHsbyMarkets)
  302. // 查询游客特卖商品列表(三级商城)
  303. hsbyR.GET("/QueryHsbyVisitorMarketGoodses", hsby.QueryHsbyVisitorMarketGoodses)
  304. // 查询特卖商品列表(三级商城)
  305. hsbyR.GET("/QueryHsbyMarketGoodses", hsby.QueryHsbyMarketGoodses)
  306. // 查询游客三级市场(商城)商品信息详情
  307. hsbyR.GET("/QueryHsbyVisitorMarketGoodsDetail", hsby.QueryHsbyVisitorMarketGoodsDetail)
  308. // 查询三级市场(商城)商品信息详情
  309. hsbyR.GET("/QueryHsbyMarketGoodsDetail", hsby.QueryHsbyMarketGoodsDetail)
  310. // 我的优惠卷查询
  311. hsbyR.GET("/QueryMyCoupons", hsby.QueryMyCoupons)
  312. // 我的优惠卷持仓查询
  313. hsbyR.GET("/QueryMyCouponHolds", hsby.QueryMyCouponHolds)
  314. // 已使用优惠卷查询
  315. hsbyR.GET("/QueryMyUsedCoupon", hsby.QueryMyUsedCoupon)
  316. // 获取终端固定广告配置
  317. hsbyR.GET("/QueryClientFixedADConfigs", hsby.QueryClientFixedADConfigs)
  318. }
  319. // ***************************** 企业风险管理(app)***************************
  320. ermcpR := apiR.Group("Ermcp")
  321. ermcpR.Use(token.Auth())
  322. {
  323. // 查询待点价、履约和全部合同
  324. ermcpR.GET("/QueryUserInfo", ermcp.QueryUserInfo)
  325. ermcpR.GET("/QueryWrStandard", ermcp.QueryWrStandard)
  326. ermcpR.GET("/QueryWrStandardDetail", ermcp.QueryWrStandardDetail)
  327. ermcpR.GET("/QuerySpotContract", ermcp.QuerySpotContract)
  328. ermcpR.GET("/QueryContract", ermcp.QueryContract)
  329. ermcpR.GET("/QueryHedgePlan", ermcp.QueryHedgePlan)
  330. ermcpR.GET("/QueryBusinessDj", ermcp.QueryBusinessDj)
  331. ermcpR.GET("/QueryBusinessJs", ermcp.QueryBusinessJs)
  332. ermcpR.GET("/QueryBusinessJsEx", ermcp.QueryBusinessJsEx)
  333. ermcpR.GET("/QueryBusinessKx", ermcp.QueryBusinessKx)
  334. ermcpR.GET("/QueryBusinessFp", ermcp.QueryBusinessFp)
  335. ermcpR.GET("/QueryChangeLog", ermcp.QueryChangeLog)
  336. ermcpR.GET("/QueryRealtimeExposure", ermcp.QueryRealtimeExposure)
  337. ermcpR.GET("/QueryExposureDetail", ermcp.QueryExposureDetail)
  338. ermcpR.GET("/QueryExposureSpot", ermcp.QueryExposureSpot)
  339. ermcpR.GET("/QueryExposureSpotDetail", ermcp.QueryExposureSpotDetail)
  340. ermcpR.GET("/QueryHisExposure", ermcp.QueryHisExposure)
  341. ermcpR.GET("/QueryMiddleGoods", ermcp.QueryMiddleGoods)
  342. ermcpR.GET("/QueryMiddleGoodsDetail", ermcp.QueryMiddleGoodsDetail)
  343. ermcpR.GET("/QueryGGConvertConfig", ermcp.QueryGGConvertConfig)
  344. ermcpR.GET("/QueryMiddleGoodsChangeLog", ermcp.QueryMiddleGoodsChangeLog)
  345. ermcpR.GET("/QueryAvaildGoodsGroup", ermcp.QueryAvaildGoodsGroup)
  346. ermcpR.GET("/QueryRealtimeExposurePosition", ermcp.QueryRealtimeExposurePosition)
  347. ermcpR.GET("/QueryExposureHedgePosition", ermcp.QueryExposureHedgePosition)
  348. ermcpR.GET("/QryReportDayFinance", ermcp.QryReportDayFinance)
  349. ermcpR.GET("/QryReportDayFinanceKx", ermcp.QryReportDayFinanceKx)
  350. ermcpR.GET("/QryReportDayFinanceFp", ermcp.QryReportDayFinanceFp)
  351. ermcpR.GET("/QryReportMonthFinance", ermcp.QryReportMonthFinance)
  352. ermcpR.GET("/QryReportDayExposure", ermcp.QryReportDayExposure)
  353. ermcpR.GET("/QryReportDaySpot", ermcp.QryReportDaySpot)
  354. ermcpR.GET("/QryReportDaySpotDetail", ermcp.QryReportDaySpotDetail)
  355. ermcpR.GET("/QryReportMonthSpot", ermcp.QryReportMonthSpot)
  356. ermcpR.GET("/QryReportMonthSpotDetail", ermcp.QryReportMonthSpotDetail)
  357. ermcpR.GET("/QryReportAreaSpotPL", ermcp.QryReportAreaSpotPL)
  358. ermcpR.GET("/QueryExposureHedgePositionDetail", ermcp.QueryExposureHedgePositionDetail)
  359. ermcpR.GET("/QueryPendingAuditInfo", ermcp.QueryPendingAuditInfo)
  360. ermcpR.GET("/QueryWarehouseInfo", ermcp.QueryWarehouseInfo)
  361. ermcpR.GET("/QueryAreaStockApply", ermcp.QueryAreaStockApply)
  362. ermcpR.GET("/QueryAreaStockApplySum", ermcp.QueryAreaStockApplySum)
  363. ermcpR.GET("/QueryAreaStock", ermcp.QueryAreaStock)
  364. ermcpR.GET("/QueryAreaStockReport", ermcp.QueryAreaStockReport)
  365. ermcpR.GET("/QueryAreaStockReportDetail", ermcp.QueryAreaStockReportDetail)
  366. ermcpR.GET("/QueryGoodsBrand", ermcp.QueryGoodsBrand)
  367. ermcpR.GET("/QueryGoodsModel", ermcp.QueryGoodsModel)
  368. ermcpR.GET("/QueryAccMgrLoginUser", ermcp.QueryAccMgrLoginUser)
  369. ermcpR.GET("/QueryAccMgrTaaccount", ermcp.QueryAccMgrTaaccount)
  370. ermcpR.GET("/QueryAccMgrMainAccountInfo", ermcp.QueryAccMgrMainAccountInfo)
  371. ermcpR.GET("/QueryAccMgrRole", ermcp.QueryAccMgrRole)
  372. ermcpR.GET("/QueryAccMgrRoleMenu", ermcp.QueryAccMgrRoleMenu)
  373. ermcpR.GET("/QueryAccMgrBizGroupSet", ermcp.QueryAccMgrBizGroupSet)
  374. ermcpR.GET("/QueryAccMgrTaAccountInfo", ermcp.QueryAccMgrTaAccountInfo)
  375. ermcpR.GET("/QuerySpotGoodsPrice", ermcp.QuerySpotGoodsPrice)
  376. ermcpR.GET("/QuerySpotGoodsPriceLog", ermcp.QuerySpotGoodsPriceLog)
  377. ermcpR.GET("/QueryFuturesCompany", ermcp.QueryFuturesCompany)
  378. // 期货相关
  379. // 查询企业风管期货商品信息
  380. ermcpR.GET("/GetErmcpGoods", ermcp.GetErmcpGoods)
  381. // 查询企业风管期货主力、次主力商品信息
  382. ermcpR.GET("/GetErmcpGoodsSortByPosition", ermcp.GetErmcpGoodsSortByPosition)
  383. // 获取企业风管期货持仓头寸信息
  384. ermcpR.GET("/QueryErmcpTradePosition", ermcp.QueryErmcpTradePosition)
  385. // 获取企业风管期货内部持仓单信息
  386. ermcpR.GET("/QueryErmcpInnerHolderDetails", ermcp.QueryErmcpInnerHolderDetails)
  387. // 获取企业风管期货委托单信息
  388. ermcpR.GET("/QueryErmcpOrderDetails", ermcp.QueryErmcpOrderDetails)
  389. // 获取企业风管期货成交单信息
  390. ermcpR.GET("/QueryErmcpTradeDetails", ermcp.QueryErmcpTradeDetails)
  391. // 获取企业风管期货历史委托单信息
  392. ermcpR.GET("/QueryErmcpHisOrderDetails", ermcp.QueryErmcpHisOrderDetails)
  393. // 获取企业风管期货历史成交单信息
  394. ermcpR.GET("/QueryErmcpHisTradeDetails", ermcp.QueryErmcpHisTradeDetails)
  395. // 权限相关
  396. // 获取企业风管终端权限
  397. ermcpR.GET("/GetErmcpRoleFuncMenuLists", ermcp.GetErmcpRoleFuncMenuLists)
  398. }
  399. return r
  400. }
  401. func ginLoggerMiddleware() gin.HandlerFunc {
  402. return func(c *gin.Context) {
  403. start := time.Now()
  404. c.Next()
  405. end := time.Now()
  406. latency := end.Sub(start)
  407. path := c.Request.URL.RequestURI()
  408. clientip := c.ClientIP()
  409. method := c.Request.Method
  410. statuscode := c.Writer.Status()
  411. logger.GetLogger().Debugf("|%3d|%13v|%15s|%s %s",
  412. statuscode,
  413. latency,
  414. clientip,
  415. method,
  416. path)
  417. }
  418. }
  419. func ginRecoveryMiddleware() gin.HandlerFunc {
  420. return gin.RecoveryWithWriter(logger.GetLogWriter())
  421. }
  422. // CORSMiddleware cors跨域.
  423. func CORSMiddleware() gin.HandlerFunc {
  424. return func(c *gin.Context) {
  425. c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
  426. c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
  427. 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")
  428. c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
  429. c.Writer.Header().Set("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type, X-session-Token")
  430. if c.Request.Method == "OPTIONS" {
  431. c.AbortWithStatus(http.StatusNoContent)
  432. return
  433. }
  434. c.Next()
  435. }
  436. }