router.go 19 KB

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