client.yaml 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919
  1. /*
  2. * OpenAPI Petstore
  3. *
  4. * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
  5. *
  6. * API version: 1.0.0
  7. * Generated by: OpenAPI Generator (https://openapi-generator.tech)
  8. */
  9. package openapi
  10. import (
  11. "encoding/json"
  12. "fmt"
  13. "github.com/gin-gonic/gin"
  14. "io"
  15. "net/http"
  16. "os"
  17. "path"
  18. "server/errors"
  19. "server/service"
  20. "strconv"
  21. "strings"
  22. "time"
  23. )
  24. type ApiAPI struct {
  25. }
  26. type GenVerifyPicReq struct {
  27. Height int `json:"height"`
  28. Width int `json:"width"`
  29. NoiseCount int `json:"noiseCount"`
  30. Length int `json:"length"`
  31. Source string `json:"source"`
  32. }
  33. type Response struct {
  34. Code int `json:"code"`
  35. Message interface{} `json:"message"`
  36. Data interface{} `json:"data"`
  37. }
  38. func (api *ApiAPI) ApiCardCardRankDetailQueryPost(context *gin.Context) {
  39. //fmt.Println("mcIdListStr", context.PostForm("mcIdListStr"))
  40. //fmt.Println("mcType", context.PostForm("mcType"))
  41. mcIdArrStr := context.PostForm("mcIdListStr") //活动id逗号分隔字符串
  42. var mcIdArr []string
  43. if mcIdArrStr != "" {
  44. mcIdArr = strings.Split(mcIdArrStr, ",")
  45. } else {
  46. context.JSON(200, gin.H{
  47. "code": -2,
  48. "message": "传入参数mcIdArrStr不正确",
  49. "data": nil,
  50. })
  51. return
  52. }
  53. if len(mcIdArr) > 1 {
  54. context.JSON(200, gin.H{
  55. "code": -2,
  56. "message": "传入参数mcIdArrStr不正确",
  57. "data": nil,
  58. })
  59. return
  60. }
  61. compId, err_ := strconv.Atoi(mcIdArr[0])
  62. if err_ != nil {
  63. context.JSON(200, gin.H{
  64. "code": -2,
  65. "message": "传入参数mcIdArrStr不正确",
  66. "data": nil,
  67. })
  68. return
  69. }
  70. mcType := api.postInt(context, "mcType")
  71. ocaId := api.postInt(context, "ocaId")
  72. dispArrStr := context.PostForm("dispArrStr")
  73. token := context.GetHeader("token")
  74. var userId int
  75. if token == "" {
  76. userId = 0
  77. } else {
  78. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  79. }
  80. //fmt.Println("userId:", userId)
  81. r, msg, err_ := service.Card{}.CardRankDetailQuery(compId, dispArrStr, userId, mcType, ocaId)
  82. if err_ == nil {
  83. context.JSON(200, gin.H{
  84. "code": 0,
  85. "message": "success",
  86. "data": r,
  87. })
  88. } else {
  89. context.JSON(200, gin.H{
  90. "code": -1,
  91. "message": msg,
  92. "data": nil,
  93. })
  94. }
  95. }
  96. func (api *ApiAPI) ApiCardCardBaseQueryPost(context *gin.Context) {
  97. ecId := api.postInt(context, "ecId") //卡片id
  98. r, msg, err_ := service.Card{}.CarBaseQuery(ecId)
  99. if err_ == nil {
  100. context.JSON(200, gin.H{
  101. "code": 0,
  102. "message": "success",
  103. "data": r,
  104. })
  105. } else {
  106. context.JSON(200, gin.H{
  107. "code": -1,
  108. "message": msg,
  109. "data": nil,
  110. })
  111. }
  112. }
  113. func (api *ApiAPI) ApiCardCardDetailQueryPost(context *gin.Context) {
  114. ecId := api.postInt(context, "ecId") //卡片id
  115. token := context.GetHeader("token")
  116. var userId int
  117. if token == "" {
  118. userId = 0
  119. } else {
  120. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  121. }
  122. //if userId == 0 {
  123. // context.JSON(401, gin.H{
  124. // "code": -2,
  125. // "message": "用户未登录",
  126. // "data": nil,
  127. // })
  128. // return
  129. //}
  130. r, msg, err_ := service.Card{}.CardDetailQuery(ecId, userId)
  131. if err_ == nil {
  132. context.JSON(200, gin.H{
  133. "code": 0,
  134. "message": "success",
  135. "data": r,
  136. })
  137. } else {
  138. context.JSON(200, gin.H{
  139. "code": -1,
  140. "message": msg,
  141. "data": nil,
  142. })
  143. }
  144. }
  145. func (api *ApiAPI) ApiCardOnlineMcSignUpDetailPost(context *gin.Context) {
  146. token := context.GetHeader("token")
  147. var userId int
  148. if token == "" {
  149. userId = 0
  150. } else {
  151. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  152. }
  153. //if userId == 0 {
  154. // context.JSON(401, gin.H{
  155. // "code": -2,
  156. // "message": "用户未登录",
  157. // "data": nil,
  158. // })
  159. // return
  160. //}
  161. mcId := api.postInt(context, "mcId") //赛事id
  162. r, msg, err_ := service.To{}.CardOnlineMcSignUpDetail(mcId, userId)
  163. if err_ == nil {
  164. context.JSON(200, gin.H{
  165. "code": 0,
  166. "message": "success",
  167. "data": r,
  168. })
  169. } else {
  170. context.JSON(200, gin.H{
  171. "code": -1,
  172. "message": msg,
  173. "data": nil,
  174. })
  175. }
  176. }
  177. func (api *ApiAPI) ApiCardOnlineMcSignUpPost(context *gin.Context) {
  178. token := context.GetHeader("token")
  179. var userId int
  180. if token == "" {
  181. userId = 0
  182. } else {
  183. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  184. }
  185. if userId == 0 {
  186. context.JSON(401, gin.H{
  187. "code": -2,
  188. "message": "用户未登录",
  189. "data": nil,
  190. })
  191. return
  192. }
  193. mcId := api.postInt(context, "mcId") //
  194. coiId := api.postInt(context, "coiId") //
  195. selectTeam := api.postInt(context, "selectTeam") //
  196. nickName := context.PostForm("nickName")
  197. //_ = service.AppLogCreate(token, "ApiCardOnlineMcSignUpPost", "mcId="+strconv.Itoa(mcId), ",nickName="+nickName, 1, userId, "")
  198. msg, err_ := service.To{}.OnlineMcSignUp(userId, mcId, coiId, selectTeam, nickName)
  199. if err_ == nil {
  200. //生成排行榜
  201. _ = service.Card{}.OnlineGameRankInit(userId, mcId)
  202. context.JSON(200, gin.H{
  203. "code": 0,
  204. "message": "success",
  205. "data": nil,
  206. })
  207. } else {
  208. context.JSON(200, gin.H{
  209. "code": -1,
  210. "message": msg,
  211. "data": nil,
  212. })
  213. }
  214. }
  215. func (api *ApiAPI) ApiCardUserJoinCardQueryPost(context *gin.Context) {
  216. token := context.GetHeader("token")
  217. var userId int
  218. if token == "" {
  219. userId = 0
  220. } else {
  221. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  222. }
  223. if userId == 0 {
  224. context.JSON(401, gin.H{
  225. "code": -2,
  226. "message": "用户未登录",
  227. "data": nil,
  228. })
  229. return
  230. }
  231. ecId := api.postInt(context, "ecId") //卡片id
  232. isJoin, msg, err_ := service.To{}.UserJoinCardQuery(userId, ecId)
  233. if err_ == nil {
  234. context.JSON(200, gin.H{
  235. "code": 0,
  236. "message": msg,
  237. "data": isJoin,
  238. })
  239. } else {
  240. context.JSON(200, gin.H{
  241. "code": -1,
  242. "message": "未报名",
  243. "data": nil,
  244. })
  245. }
  246. }
  247. func (api *ApiAPI) ApiCardAchievementQueryPost(context *gin.Context) {
  248. token := context.GetHeader("token")
  249. var userId int
  250. if token == "" {
  251. userId = 0
  252. } else {
  253. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  254. }
  255. if userId == 0 {
  256. context.JSON(401, gin.H{
  257. "code": -2,
  258. "message": "用户未登录",
  259. "data": nil,
  260. })
  261. return
  262. }
  263. isJoin, msg, err_ := service.To{}.CardAchievementQuery(userId)
  264. if err_ == nil {
  265. context.JSON(200, gin.H{
  266. "code": 0,
  267. "message": msg,
  268. "data": isJoin,
  269. })
  270. } else {
  271. context.JSON(200, gin.H{
  272. "code": -1,
  273. "message": "未报名",
  274. "data": nil,
  275. })
  276. }
  277. }
  278. func (api *ApiAPI) ApiCardMonthlyChallengeQueryPost(context *gin.Context) {
  279. token := context.GetHeader("token")
  280. var userId int
  281. if token == "" {
  282. userId = 0
  283. } else {
  284. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  285. }
  286. if userId == 0 {
  287. context.JSON(401, gin.H{
  288. "code": -2,
  289. "message": "用户未登录",
  290. "data": nil,
  291. })
  292. return
  293. }
  294. r, msg, err_ := service.To{}.MonthlyChallengeQuery(userId)
  295. if err_ == nil {
  296. context.JSON(200, gin.H{
  297. "code": 0,
  298. "message": msg,
  299. "data": r,
  300. })
  301. } else {
  302. context.JSON(200, gin.H{
  303. "code": -1,
  304. "message": "未报名",
  305. "data": nil,
  306. })
  307. }
  308. }
  309. func (api *ApiAPI) ApiCardCurrentMonthlyChallengeQueryPost(context *gin.Context) {
  310. token := context.GetHeader("token")
  311. var userId int
  312. if token == "" {
  313. userId = 0
  314. } else {
  315. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  316. }
  317. year := api.postInt(context, "year")
  318. month := api.postInt(context, "month")
  319. r, msg, err_ := service.To{}.CurrentMonthlyChallengeQuery(userId, year, month)
  320. if err_ == nil {
  321. if userId == 0 {
  322. context.JSON(401, gin.H{
  323. "code": 0,
  324. "message": msg,
  325. "data": r,
  326. })
  327. } else {
  328. context.JSON(200, gin.H{
  329. "code": 0,
  330. "message": msg,
  331. "data": r,
  332. })
  333. }
  334. } else {
  335. context.JSON(200, gin.H{
  336. "code": -1,
  337. "message": "未报名",
  338. "data": nil,
  339. })
  340. }
  341. }
  342. func (api *ApiAPI) ApiCardExchangeListQueryPost(context *gin.Context) {
  343. token := context.GetHeader("token")
  344. var userId int
  345. if token == "" {
  346. userId = 0
  347. } else {
  348. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  349. }
  350. if userId == 0 {
  351. context.JSON(401, gin.H{
  352. "code": -2,
  353. "message": "用户未登录",
  354. "data": nil,
  355. })
  356. return
  357. }
  358. r, msg, err_ := service.Verf{}.UserExchangeListQuery(userId)
  359. if err_ == nil {
  360. context.JSON(200, gin.H{
  361. "code": 0,
  362. "message": msg,
  363. "data": r,
  364. })
  365. } else {
  366. context.JSON(200, gin.H{
  367. "code": -1,
  368. "message": "未报名",
  369. "data": nil,
  370. })
  371. }
  372. }
  373. func (api *ApiAPI) ApiCardExchangeDetailQueryPost(context *gin.Context) {
  374. oarId := api.postInt(context, "oarId")
  375. token := context.GetHeader("token")
  376. var userId int
  377. if token == "" {
  378. userId = 0
  379. } else {
  380. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  381. }
  382. if userId == 0 {
  383. context.JSON(401, gin.H{
  384. "code": -2,
  385. "message": "用户未登录",
  386. "data": nil,
  387. })
  388. return
  389. }
  390. r, msg, err_ := service.Card{}.ExchangeDetailQuery(oarId, userId)
  391. if err_ == nil {
  392. context.JSON(200, gin.H{
  393. "code": 0,
  394. "message": "success",
  395. "data": r,
  396. })
  397. } else {
  398. context.JSON(200, gin.H{
  399. "code": -1,
  400. "message": msg,
  401. "data": nil,
  402. })
  403. }
  404. }
  405. func (api *ApiAPI) ApiCardCardConfigQueryPost(context *gin.Context) {
  406. //fmt.Println("=========================ecId===============", context.PostForm("ecId"))
  407. ecId := api.postInt(context, "ecId") //卡片id
  408. pageName := context.PostForm("pageName")
  409. if pageName == "all" {
  410. r, msg, err_ := service.Card{}.CarConfigAllQuery(ecId, pageName)
  411. if err_ == nil {
  412. context.JSON(200, gin.H{
  413. "code": 0,
  414. "message": "success",
  415. "data": r,
  416. })
  417. } else {
  418. context.JSON(200, gin.H{
  419. "code": -1,
  420. "message": msg,
  421. "data": nil,
  422. })
  423. }
  424. } else {
  425. r, msg, err_ := service.Card{}.CarConfigQuery(ecId, pageName)
  426. if err_ == nil {
  427. context.JSON(200, gin.H{
  428. "code": 0,
  429. "message": "success",
  430. "data": r,
  431. })
  432. } else {
  433. context.JSON(200, gin.H{
  434. "code": -1,
  435. "message": msg,
  436. "data": nil,
  437. })
  438. }
  439. }
  440. }
  441. func (api *ApiAPI) ApiCardReadMessagePost(context *gin.Context) {
  442. token := context.GetHeader("token")
  443. var userId int
  444. if token == "" {
  445. userId = 0
  446. } else {
  447. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  448. }
  449. mqIdListStr := context.PostForm("mqIdListStr") //已读消息id逗号分隔字符串
  450. msg, err_ := service.Card{}.CardReadMessage(userId, mqIdListStr)
  451. if err_ == nil {
  452. context.JSON(200, gin.H{
  453. "code": 0,
  454. "message": "success",
  455. "data": nil,
  456. })
  457. } else {
  458. context.JSON(200, gin.H{
  459. "code": -1,
  460. "message": msg,
  461. "data": nil,
  462. })
  463. }
  464. }
  465. func (api *ApiAPI) ApiCardUnReadMessageQueryPost(context *gin.Context) {
  466. token := context.GetHeader("token")
  467. var userId int
  468. if token == "" {
  469. userId = 0
  470. } else {
  471. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  472. }
  473. relationType := api.postInt(context, "relationType") //消息类型 1成就 2 卡片
  474. relationId := api.postInt(context, "relationId") //消息类型 1成就 2 卡片
  475. r, msg, err_ := service.Card{}.CardUnReadMessageQuery(userId, relationType, relationId)
  476. if err_ == nil {
  477. context.JSON(200, gin.H{
  478. "code": 0,
  479. "message": "success",
  480. "data": r,
  481. })
  482. } else {
  483. context.JSON(200, gin.H{
  484. "code": -1,
  485. "message": msg,
  486. "data": nil,
  487. })
  488. }
  489. }
  490. func (api *ApiAPI) ApiCardCurrentRankNumQueryPost(context *gin.Context) {
  491. }
  492. func (api *ApiAPI) ApiCardUserCurrentRankNumQueryPost(context *gin.Context) {
  493. token := context.GetHeader("token")
  494. var userId int
  495. if token == "" {
  496. userId = 0
  497. } else {
  498. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  499. }
  500. if userId == 0 {
  501. context.JSON(401, gin.H{
  502. "code": -2,
  503. "message": "用户未登录",
  504. "data": nil,
  505. })
  506. return
  507. }
  508. ecId := api.postInt(context, "ecId") //卡片id
  509. rankNum, err_ := service.To{}.CardCurrentRankNumQuery(userId, ecId)
  510. if err_ == nil {
  511. context.JSON(200, gin.H{
  512. "code": 0,
  513. "message": "success",
  514. "data": rankNum,
  515. })
  516. } else {
  517. context.JSON(200, gin.H{
  518. "code": -1,
  519. "message": "未报名",
  520. "data": nil,
  521. })
  522. }
  523. }
  524. func (api *ApiAPI) ApiCardIsAllowMcSignUpPost(context *gin.Context) {
  525. token := context.GetHeader("token")
  526. var userId int
  527. if token == "" {
  528. userId = 0
  529. } else {
  530. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  531. }
  532. if userId == 0 {
  533. context.JSON(401, gin.H{
  534. "code": -2,
  535. "message": "用户未登录",
  536. "data": nil,
  537. })
  538. return
  539. }
  540. ecId := api.postInt(context, "ecId") //卡片id
  541. isAllowMcSignUp, err_ := service.To{}.IsAllowMcSignUpQuery(userId, ecId)
  542. if err_ == nil {
  543. context.JSON(200, gin.H{
  544. "code": 0,
  545. "message": "success",
  546. "data": isAllowMcSignUp,
  547. })
  548. } else {
  549. context.JSON(200, gin.H{
  550. "code": -1,
  551. "message": "未报名",
  552. "data": nil,
  553. })
  554. }
  555. }
  556. func (api *ApiAPI) ApiShopVerfSignInPost(context *gin.Context) {
  557. phone := context.PostForm("username")
  558. vfCode := context.PostForm("password")
  559. Ip := context.ClientIP()
  560. loginReply, msg, err_ := service.Verf{}.VerfSignIn(phone, vfCode, Ip)
  561. if err_ == nil {
  562. context.JSON(200, gin.H{
  563. "code": 0,
  564. "message": "success",
  565. "data": loginReply,
  566. })
  567. } else {
  568. context.JSON(200, gin.H{
  569. "code": -1,
  570. "message": msg,
  571. "data": nil,
  572. })
  573. }
  574. }
  575. func (api *ApiAPI) ApiShopVerfExchangePost(context *gin.Context) {
  576. token := context.GetHeader("token")
  577. var userId int
  578. userId, err_ := service.Verf{}.GetUserIdByToken(token)
  579. if err_ != nil {
  580. context.JSON(401, gin.H{
  581. "code": -2,
  582. "message": "用户未登录",
  583. "data": nil,
  584. })
  585. return
  586. }
  587. qrCode := context.PostForm("qrCode")
  588. msg, err_ := service.Verf{}.VerfExchange(userId, qrCode)
  589. if err_ == nil {
  590. context.JSON(200, gin.H{
  591. "code": 0,
  592. "message": "success",
  593. "data": nil,
  594. })
  595. } else {
  596. context.JSON(200, gin.H{
  597. "code": -1,
  598. "message": msg,
  599. "data": nil,
  600. })
  601. }
  602. }
  603. func (api *ApiAPI) ApiShopVerfExchangedListQueryPost(context *gin.Context) {
  604. token := context.GetHeader("token")
  605. var userId int
  606. userId, err_ := service.Verf{}.GetUserIdByToken(token)
  607. if err_ != nil {
  608. context.JSON(401, gin.H{
  609. "code": -2,
  610. "message": "用户未登录",
  611. "data": nil,
  612. })
  613. return
  614. }
  615. yearMonth := context.PostForm("yearMonth")
  616. rs, err_ := service.Verf{}.VerfExchangedListQuery(userId, yearMonth)
  617. if err_ == nil {
  618. context.JSON(200, gin.H{
  619. "code": 0,
  620. "message": "success",
  621. "data": rs,
  622. })
  623. } else {
  624. context.JSON(200, gin.H{
  625. "code": -1,
  626. "message": "未报名",
  627. "data": nil,
  628. })
  629. }
  630. }
  631. func (api *ApiAPI) ApiCardMatchRsDetailQueryPost(context *gin.Context) {
  632. ecId := api.postInt(context, "ecId") //卡片id
  633. ocaId := api.postInt(context, "ocaId") //关联关系id
  634. token := context.GetHeader("token")
  635. var userId int
  636. if token == "" {
  637. userId = 0
  638. } else {
  639. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  640. }
  641. if userId == 0 {
  642. context.JSON(401, gin.H{
  643. "code": -2,
  644. "message": "用户未登录",
  645. "data": nil,
  646. })
  647. return
  648. }
  649. r, msg, err_ := service.Card{}.MatchRsDetail(ecId, ocaId, userId)
  650. if err_ == nil {
  651. context.JSON(200, gin.H{
  652. "code": 0,
  653. "message": "success",
  654. "data": r,
  655. })
  656. } else {
  657. context.JSON(200, gin.H{
  658. "code": -1,
  659. "message": msg,
  660. "data": nil,
  661. })
  662. }
  663. }
  664. func (api *ApiAPI) GetWxJsSdkConfig(c *gin.Context) {
  665. url := c.PostForm("url")
  666. r, msg, err_ := service.WxPay{}.GetJssdkConfig(url)
  667. if err_ == nil {
  668. c.JSON(200, gin.H{
  669. "code": 0,
  670. "data": r,
  671. "message": "sucess",
  672. })
  673. } else {
  674. c.JSON(200, gin.H{
  675. "code": -1,
  676. "message": msg,
  677. })
  678. }
  679. }
  680. func (api *ApiAPI) ApiCardAchievementDetailQueryPost(context *gin.Context) {
  681. }
  682. func (api *ApiAPI) ApiCardCompStatisticQueryPost(context *gin.Context) {
  683. mcId := api.postInt(context, "mcId")
  684. token := context.GetHeader("token")
  685. var userId int
  686. if token == "" {
  687. userId = 0
  688. } else {
  689. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  690. }
  691. if userId == 0 {
  692. context.JSON(401, gin.H{
  693. "code": -2,
  694. "message": "用户未登录",
  695. "data": nil,
  696. })
  697. return
  698. }
  699. r, msg, err_ := service.Card{}.CompStatisticQuery(mcId, userId)
  700. if err_ == nil {
  701. context.JSON(200, gin.H{
  702. "code": 0,
  703. "message": "success",
  704. "data": r,
  705. })
  706. } else {
  707. context.JSON(200, gin.H{
  708. "code": -1,
  709. "message": msg,
  710. "data": nil,
  711. })
  712. }
  713. }
  714. func (api *ApiAPI) ApiCardMapListQueryPost(context *gin.Context) {
  715. mcId := api.postInt(context, "mcId")
  716. token := context.GetHeader("token")
  717. var userId int
  718. if token == "" {
  719. userId = 0
  720. } else {
  721. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  722. }
  723. if userId == 0 {
  724. context.JSON(401, gin.H{
  725. "code": -2,
  726. "message": "用户未登录",
  727. "data": nil,
  728. })
  729. return
  730. }
  731. r, msg, err_ := service.Card{}.MapListQuery(mcId, userId)
  732. if err_ == nil {
  733. context.JSON(200, gin.H{
  734. "code": 0,
  735. "message": "success",
  736. "data": r,
  737. })
  738. } else {
  739. context.JSON(200, gin.H{
  740. "code": -1,
  741. "message": msg,
  742. "data": nil,
  743. })
  744. }
  745. }
  746. func (api *ApiAPI) ApiCardCardUrlQueryPost(context *gin.Context) {
  747. actId := api.postInt(context, "actId")
  748. matchType := api.postInt(context, "matchType")
  749. token := context.GetHeader("token")
  750. //fmt.Println("查询url的token:" + token)
  751. var userId int
  752. if token == "" {
  753. userId = 0
  754. } else {
  755. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  756. }
  757. if userId == 0 {
  758. context.JSON(401, gin.H{
  759. "code": -2,
  760. "message": "用户未登录",
  761. "data": nil,
  762. })
  763. return
  764. }
  765. r, msg, err_ := service.Card{}.CardUrlQuery(actId, matchType, userId)
  766. if err_ == nil {
  767. context.JSON(200, gin.H{
  768. "code": 0,
  769. "message": "success",
  770. "data": r,
  771. })
  772. } else {
  773. context.JSON(200, gin.H{
  774. "code": -1,
  775. "message": msg,
  776. "data": nil,
  777. })
  778. }
  779. }
  780. func (api *ApiAPI) ApiCardWarnMessageQueryPost(context *gin.Context) {
  781. token := context.GetHeader("token")
  782. var userId int
  783. if token == "" {
  784. userId = 0
  785. } else {
  786. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  787. }
  788. if userId == 0 {
  789. context.JSON(401, gin.H{
  790. "code": -2,
  791. "message": "用户未登录",
  792. "data": nil,
  793. })
  794. return
  795. }
  796. ecId := api.postInt(context, "ecId") // 2 卡片
  797. r, msg, err_ := service.Card{}.CardWarnMessageQuery(userId, ecId)
  798. if err_ == nil {
  799. context.JSON(200, gin.H{
  800. "code": 0,
  801. "message": "success",
  802. "data": r,
  803. })
  804. } else {
  805. context.JSON(200, gin.H{
  806. "code": -1,
  807. "message": msg,
  808. "data": nil,
  809. })
  810. }
  811. }
  812. func (api *ApiAPI) ApiCardCertStyleQueryPost(context *gin.Context) {
  813. token := context.GetHeader("token")
  814. var userId int
  815. if token == "" {
  816. userId = 0
  817. } else {
  818. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  819. }
  820. if userId == 0 {
  821. context.JSON(401, gin.H{
  822. "code": -2,
  823. "message": "用户未登录",
  824. "data": nil,
  825. })
  826. return
  827. }
  828. certStyleType := context.PostForm("certStyleType") //证书样式
  829. //certStyleType := api.postInt(context, "certStyleType") // 2 卡片
  830. r, msg, err_ := service.Card{}.CardCertStyleQuery(userId, certStyleType)
  831. if err_ == nil {
  832. context.JSON(200, gin.H{
  833. "code": 0,
  834. "message": "success",
  835. "data": r,
  836. })
  837. } else {
  838. context.JSON(200, gin.H{
  839. "code": -1,
  840. "message": msg,
  841. "data": nil,
  842. })
  843. }
  844. }
  845. func (api *ApiAPI) ApiCardCertificateCreateByUserAiPost(context *gin.Context) {
  846. token := context.GetHeader("token")
  847. var userId int
  848. if token == "" {
  849. userId = 0
  850. } else {
  851. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  852. }
  853. if userId == 0 {
  854. context.JSON(401, gin.H{
  855. "code": -2,
  856. "message": "用户未登录",
  857. "data": nil,
  858. })
  859. return
  860. }
  861. nickName := context.PostForm("nickName") //证书样式
  862. oarId := api.postInt(context, "oarId") // 2 卡片
  863. msg, err_ := service.Card{}.UpdateCertificateIssued(userId, oarId, nickName)
  864. if err_ == nil {
  865. context.JSON(200, gin.H{
  866. "code": 0,
  867. "message": "success",
  868. })
  869. } else {
  870. context.JSON(200, gin.H{
  871. "code": -1,
  872. "message": msg,
  873. "data": nil,
  874. })
  875. }
  876. }
  877. func (api *ApiAPI) ApiCardUserBaseQueryInCertificatePost(context *gin.Context) {
  878. token := context.GetHeader("token")
  879. var userId int
  880. if token == "" {
  881. userId = 0
  882. } else {
  883. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  884. }
  885. if userId == 0 {
  886. context.JSON(401, gin.H{
  887. "code": -2,
  888. "message": "用户未登录",
  889. "data": nil,
  890. })
  891. return
  892. }
  893. //nickName := context.PostForm("nickName") //证书样式
  894. oarId := api.postInt(context, "oarId") // 2 卡片
  895. r, msg, err_ := service.Card{}.CardCertificateCreateByUserAi(userId, oarId)
  896. if err_ == nil {
  897. context.JSON(200, gin.H{
  898. "code": 0,
  899. "message": "success",
  900. "data": r,
  901. })
  902. } else {
  903. context.JSON(200, gin.H{
  904. "code": -1,
  905. "message": msg,
  906. "data": nil,
  907. })
  908. }
  909. }
  910. func (api *ApiAPI) ApiCardCanExchangeGoodsDetailPost(context *gin.Context) {
  911. token := context.GetHeader("token")
  912. var userId int
  913. if token == "" {
  914. userId = 0
  915. } else {
  916. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  917. }
  918. if userId == 0 {
  919. context.JSON(401, gin.H{
  920. "code": -2,
  921. "message": "用户未登录",
  922. "data": nil,
  923. })
  924. return
  925. }
  926. goodsId := api.postInt(context, "goodsId") // 商品
  927. ecId := api.postInt(context, "ecId") // 2 卡片
  928. r, msg, err_ := service.Card{}.CardCanExchangeGoodsDetail(userId, ecId, goodsId)
  929. if err_ == nil {
  930. context.JSON(200, gin.H{
  931. "code": 0,
  932. "message": "success",
  933. "data": r,
  934. })
  935. } else {
  936. context.JSON(200, gin.H{
  937. "code": -1,
  938. "message": msg,
  939. "data": nil,
  940. })
  941. }
  942. }
  943. func (api *ApiAPI) ApiCardCanExchangeGoodsListPost(context *gin.Context) {
  944. token := context.GetHeader("token")
  945. var userId int
  946. if token == "" {
  947. userId = 0
  948. } else {
  949. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  950. }
  951. if userId == 0 {
  952. context.JSON(401, gin.H{
  953. "code": -2,
  954. "message": "用户未登录",
  955. "data": nil,
  956. })
  957. return
  958. }
  959. ecId := api.postInt(context, "ecId") // 2 卡片
  960. r, msg, err_ := service.Card{}.CardCanExchangeGoodsList(userId, ecId)
  961. if err_ == nil {
  962. context.JSON(200, gin.H{
  963. "code": 0,
  964. "message": "success",
  965. "data": r,
  966. })
  967. } else {
  968. context.JSON(200, gin.H{
  969. "code": -1,
  970. "message": msg,
  971. "data": nil,
  972. })
  973. }
  974. }
  975. func (api *ApiAPI) ApiCardOnlineScoreQueryPost(context *gin.Context) {
  976. token := context.GetHeader("token")
  977. var userId int
  978. if token == "" {
  979. userId = 0
  980. } else {
  981. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  982. }
  983. if userId == 0 {
  984. context.JSON(401, gin.H{
  985. "code": -2,
  986. "message": "用户未登录",
  987. "data": nil,
  988. })
  989. return
  990. }
  991. ecId := api.postInt(context, "ecId") // 2 卡片
  992. r, msg, err_ := service.Card{}.CardOnlineScoreQuery(userId, ecId)
  993. if err_ == nil {
  994. context.JSON(200, gin.H{
  995. "code": 0,
  996. "message": "success",
  997. "data": r,
  998. })
  999. } else {
  1000. context.JSON(200, gin.H{
  1001. "code": -1,
  1002. "message": msg,
  1003. "data": nil,
  1004. })
  1005. }
  1006. }
  1007. func (api *ApiAPI) ApiCardScoreExchangeGoodsPost(context *gin.Context) {
  1008. token := context.GetHeader("token")
  1009. var userId int
  1010. if token == "" {
  1011. userId = 0
  1012. } else {
  1013. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  1014. }
  1015. if userId == 0 {
  1016. context.JSON(401, gin.H{
  1017. "code": -2,
  1018. "message": "用户未登录",
  1019. "data": nil,
  1020. })
  1021. return
  1022. }
  1023. goodsId := api.postInt(context, "goodsId") // 商品
  1024. ecId := api.postInt(context, "ecId") // 2 卡片
  1025. exchNum := api.postInt(context, "exchNum") // 2 卡片
  1026. msg, err_ := service.Card{}.CardScoreExchangeGoods(userId, ecId, goodsId, exchNum)
  1027. if err_ == nil {
  1028. context.JSON(200, gin.H{
  1029. "code": 0,
  1030. "message": "success",
  1031. "data": nil,
  1032. })
  1033. } else {
  1034. context.JSON(200, gin.H{
  1035. "code": -1,
  1036. "message": msg,
  1037. "data": nil,
  1038. })
  1039. }
  1040. }
  1041. func (api *ApiAPI) ApiShopVerfSignOutPost(context *gin.Context) {
  1042. token := context.GetHeader("token")
  1043. var userId int
  1044. userId, err_ := service.Verf{}.GetUserIdByToken(token)
  1045. if err_ != nil {
  1046. context.JSON(401, gin.H{
  1047. "code": -2,
  1048. "message": "用户未登录",
  1049. "data": nil,
  1050. })
  1051. return
  1052. }
  1053. err_ = service.Verf{}.VerfSignOut(userId)
  1054. if err_ == nil {
  1055. context.JSON(200, gin.H{
  1056. "code": 0,
  1057. "message": "success",
  1058. "data": nil,
  1059. })
  1060. } else {
  1061. context.JSON(200, gin.H{
  1062. "code": -1,
  1063. "message": "",
  1064. "data": nil,
  1065. })
  1066. }
  1067. }
  1068. func (api *ApiAPI) ApiCardIsNewUserInCardCompPost(context *gin.Context) {
  1069. token := context.GetHeader("token")
  1070. var userId int
  1071. if token == "" {
  1072. userId = 0
  1073. } else {
  1074. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  1075. }
  1076. if userId == 0 {
  1077. context.JSON(401, gin.H{
  1078. "code": -2,
  1079. "message": "用户未登录",
  1080. "data": nil,
  1081. })
  1082. return
  1083. }
  1084. ecId := api.postInt(context, "ecId") //卡片id
  1085. isNew, msg, err_ := service.Card{}.IsNewUserInCardComp(userId, ecId)
  1086. if err_ == nil {
  1087. context.JSON(200, gin.H{
  1088. "code": 0,
  1089. "message": msg,
  1090. "data": isNew,
  1091. })
  1092. } else {
  1093. context.JSON(200, gin.H{
  1094. "code": -1,
  1095. "message": "",
  1096. "data": nil,
  1097. })
  1098. }
  1099. }
  1100. func (api *ApiAPI) ApiCardRedisRebulidPost(context *gin.Context) {
  1101. compId := api.postInt(context, "compId") //卡片id
  1102. err_ := service.Card{}.OnlineGameRankAddGenerate(compId)
  1103. if err_ == nil {
  1104. context.JSON(200, gin.H{
  1105. "code": 0,
  1106. "message": "",
  1107. "data": nil,
  1108. })
  1109. } else {
  1110. context.JSON(200, gin.H{
  1111. "code": -1,
  1112. "message": "",
  1113. "data": nil,
  1114. })
  1115. }
  1116. }
  1117. func (api *ApiAPI) ApiCardMatchFininshInfoQueryPost(context *gin.Context) {
  1118. actId := api.postInt(context, "actId")
  1119. matchType := api.postInt(context, "matchType")
  1120. token := context.GetHeader("token")
  1121. //fmt.Println("查询url的token:" + token)
  1122. var userId int
  1123. if token == "" {
  1124. userId = 0
  1125. } else {
  1126. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  1127. }
  1128. if userId == 0 {
  1129. context.JSON(401, gin.H{
  1130. "code": -2,
  1131. "message": "用户未登录",
  1132. "data": nil,
  1133. })
  1134. return
  1135. }
  1136. r, msg, err_ := service.Card{}.MatchFininshInfoQuery(actId, matchType, userId)
  1137. if err_ == nil {
  1138. context.JSON(200, gin.H{
  1139. "code": 0,
  1140. "message": "success",
  1141. "data": r,
  1142. })
  1143. } else {
  1144. context.JSON(200, gin.H{
  1145. "code": -1,
  1146. "message": msg,
  1147. "data": nil,
  1148. })
  1149. }
  1150. }
  1151. func (api *ApiAPI) ApiActMgtSignInPost(context *gin.Context) {
  1152. username := context.PostForm("username")
  1153. vfCode := context.PostForm("vfCode")
  1154. Ip := context.ClientIP()
  1155. loginReply, msg, err_ := service.ActMgt{}.ActGmtSignInV2(username, vfCode, Ip)
  1156. if err_ == nil {
  1157. context.JSON(200, gin.H{
  1158. "code": 0,
  1159. "message": "success",
  1160. "data": loginReply,
  1161. })
  1162. } else {
  1163. context.JSON(200, gin.H{
  1164. "code": -1,
  1165. "message": msg,
  1166. "data": nil,
  1167. })
  1168. }
  1169. }
  1170. func (api *ApiAPI) ApiActMgtSignOutPost(context *gin.Context) {
  1171. token := context.GetHeader("token")
  1172. var userId int
  1173. userId, err_ := service.ActMgt{}.GetUserIdByToken(token)
  1174. if err_ != nil {
  1175. context.JSON(401, gin.H{
  1176. "code": -2,
  1177. "message": "用户未登录",
  1178. "data": nil,
  1179. })
  1180. return
  1181. }
  1182. err_ = service.ActMgt{}.SignOut(userId)
  1183. if err_ == nil {
  1184. context.JSON(200, gin.H{
  1185. "code": 0,
  1186. "message": "success",
  1187. "data": nil,
  1188. })
  1189. } else {
  1190. context.JSON(200, gin.H{
  1191. "code": -1,
  1192. "message": "",
  1193. "data": nil,
  1194. })
  1195. }
  1196. }
  1197. func (api *ApiAPI) ApiActMgtSignUpPost(c *gin.Context) {
  1198. phone := c.PostForm("phone")
  1199. vfCode := c.PostForm("vfCode")
  1200. password := c.PostForm("password")
  1201. username := c.PostForm("username")
  1202. msg, err_ := service.ActMgt{}.SignUp(phone, vfCode, password, username)
  1203. if err_ == nil {
  1204. loginReply, msg2, err2_ := service.ActMgt{}.ActGmtSignIn(username, password, "")
  1205. if err2_ == nil {
  1206. c.JSON(200, gin.H{
  1207. "code": 0,
  1208. "message": "success",
  1209. "data": loginReply,
  1210. })
  1211. } else {
  1212. c.JSON(200, gin.H{
  1213. "code": -1,
  1214. "message": msg2,
  1215. "data": nil,
  1216. })
  1217. }
  1218. } else {
  1219. c.JSON(200, gin.H{
  1220. "code": -1,
  1221. "message": msg,
  1222. "data": nil,
  1223. })
  1224. }
  1225. }
  1226. func (api *ApiAPI) ApiActMgtSmsSendPost(c *gin.Context) {
  1227. phone := c.PostForm("phone")
  1228. //smsType := api.postInt(c, "smsType")
  1229. msg, err_ := service.ActMgt{}.ToSendSms(phone, 1)
  1230. if err_ == nil {
  1231. c.JSON(200, gin.H{
  1232. "code": 0,
  1233. "message": "success",
  1234. "data": nil,
  1235. })
  1236. } else {
  1237. c.JSON(200, gin.H{
  1238. "code": -1,
  1239. "message": msg,
  1240. "data": nil,
  1241. })
  1242. }
  1243. }
  1244. func (api *ApiAPI) ApiActMgtCompInfoAddPost(context *gin.Context) {
  1245. token := context.GetHeader("token")
  1246. var userId int
  1247. if token == "" {
  1248. userId = 0
  1249. } else {
  1250. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1251. }
  1252. if userId == 0 {
  1253. context.JSON(401, gin.H{
  1254. "code": -2,
  1255. "message": "用户未登录",
  1256. "data": nil,
  1257. })
  1258. return
  1259. }
  1260. inJson := context.PostForm("inJson")
  1261. prodId := api.postInt(context, "prodId")
  1262. if prodId == 0 {
  1263. prodId = 1
  1264. }
  1265. msg, err_ := service.ActMgt{}.ActMgtCompInfoAdd(userId, inJson, prodId)
  1266. if err_ == nil {
  1267. context.JSON(200, gin.H{
  1268. "code": 0,
  1269. "message": "",
  1270. "data": nil,
  1271. })
  1272. } else {
  1273. context.JSON(200, gin.H{
  1274. "code": -1,
  1275. "message": msg,
  1276. "data": nil,
  1277. })
  1278. }
  1279. }
  1280. func (api *ApiAPI) ApiActMgtCompInfoQueryPost(context *gin.Context) {
  1281. token := context.GetHeader("token")
  1282. var userId int
  1283. if token == "" {
  1284. userId = 0
  1285. } else {
  1286. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1287. }
  1288. if userId == 0 {
  1289. context.JSON(401, gin.H{
  1290. "code": -2,
  1291. "message": "用户未登录",
  1292. "data": nil,
  1293. })
  1294. return
  1295. }
  1296. prodId := api.postInt(context, "prodId")
  1297. if prodId == 0 {
  1298. prodId = 1
  1299. }
  1300. r, err_ := service.ActMgt{}.ApiActMgtCompInfoQueryPost(userId, prodId)
  1301. if err_ == nil {
  1302. context.JSON(200, gin.H{
  1303. "code": 0,
  1304. "message": "",
  1305. "data": r,
  1306. })
  1307. } else {
  1308. context.JSON(200, gin.H{
  1309. "code": -1,
  1310. "message": "查询失败",
  1311. "data": nil,
  1312. })
  1313. }
  1314. }
  1315. func (api *ApiAPI) ApiActMgtGetSelfInfoPost(context *gin.Context) {
  1316. token := context.GetHeader("token")
  1317. var userId int
  1318. if token == "" {
  1319. userId = 0
  1320. } else {
  1321. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1322. }
  1323. if userId == 0 {
  1324. context.JSON(401, gin.H{
  1325. "code": -2,
  1326. "message": "用户未登录",
  1327. "data": nil,
  1328. })
  1329. return
  1330. }
  1331. r, err_ := service.ActMgt{}.ActMgtGetSelfInfo(userId)
  1332. if err_ == nil {
  1333. context.JSON(200, gin.H{
  1334. "code": 0,
  1335. "message": "",
  1336. "data": r,
  1337. })
  1338. } else {
  1339. context.JSON(200, gin.H{
  1340. "code": -1,
  1341. "message": "查询失败",
  1342. "data": nil,
  1343. })
  1344. }
  1345. }
  1346. func (api *ApiAPI) ApiActMgtSelectMapQueryPost(context *gin.Context) {
  1347. token := context.GetHeader("token")
  1348. var userId int
  1349. if token == "" {
  1350. userId = 0
  1351. } else {
  1352. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1353. }
  1354. if userId == 0 {
  1355. context.JSON(401, gin.H{
  1356. "code": -2,
  1357. "message": "用户未登录",
  1358. "data": nil,
  1359. })
  1360. return
  1361. }
  1362. prodId := api.postInt(context, "prodId")
  1363. if prodId == 0 {
  1364. prodId = 1
  1365. }
  1366. selectOption, msg, err_ := service.ActMgt{}.MapSelect(userId, prodId)
  1367. if err_ == nil {
  1368. context.JSON(200, gin.H{
  1369. "code": 0,
  1370. "message": "",
  1371. "data": selectOption,
  1372. })
  1373. } else {
  1374. context.JSON(200, gin.H{
  1375. "code": -1,
  1376. "message": msg,
  1377. "data": nil,
  1378. })
  1379. }
  1380. }
  1381. func (api *ApiAPI) ApiActMgtSelectPlanQueryPost(context *gin.Context) {
  1382. token := context.GetHeader("token")
  1383. var userId int
  1384. if token == "" {
  1385. userId = 0
  1386. } else {
  1387. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1388. }
  1389. if userId == 0 {
  1390. context.JSON(401, gin.H{
  1391. "code": -2,
  1392. "message": "用户未登录",
  1393. "data": nil,
  1394. })
  1395. return
  1396. }
  1397. mapId := api.postInt(context, "mapId")
  1398. prodId := api.postInt(context, "prodId")
  1399. if prodId == 0 {
  1400. prodId = 1
  1401. }
  1402. selectOption, msg, err_ := service.ActMgt{}.PlanSelect(mapId, prodId)
  1403. if err_ == nil {
  1404. context.JSON(200, gin.H{
  1405. "code": 0,
  1406. "message": "",
  1407. "data": selectOption,
  1408. })
  1409. } else {
  1410. context.JSON(200, gin.H{
  1411. "code": -1,
  1412. "message": msg,
  1413. "data": nil,
  1414. })
  1415. }
  1416. }
  1417. func (api *ApiAPI) ApiActMgtSelectSsctQueryPost(context *gin.Context) {
  1418. token := context.GetHeader("token")
  1419. var userId int
  1420. if token == "" {
  1421. userId = 0
  1422. } else {
  1423. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1424. }
  1425. if userId == 0 {
  1426. context.JSON(401, gin.H{
  1427. "code": -2,
  1428. "message": "用户未登录",
  1429. "data": nil,
  1430. })
  1431. return
  1432. }
  1433. prodId := api.postInt(context, "prodId")
  1434. if prodId == 0 {
  1435. prodId = 1
  1436. }
  1437. selectOption, msg, err_ := service.ActMgt{}.SsctSelect(userId)
  1438. if err_ == nil {
  1439. context.JSON(200, gin.H{
  1440. "code": 0,
  1441. "message": "",
  1442. "data": selectOption,
  1443. })
  1444. } else {
  1445. context.JSON(200, gin.H{
  1446. "code": -1,
  1447. "message": msg,
  1448. "data": nil,
  1449. })
  1450. }
  1451. }
  1452. func (api *ApiAPI) ApiActMgtUploadFilesPost(context *gin.Context) {
  1453. token := context.GetHeader("token")
  1454. var userId int
  1455. if token == "" {
  1456. userId = 0
  1457. } else {
  1458. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1459. }
  1460. if userId == 0 {
  1461. context.JSON(401, gin.H{
  1462. "code": -2,
  1463. "message": "用户未登录",
  1464. "data": nil,
  1465. })
  1466. return
  1467. }
  1468. // 文件处理
  1469. file, err := context.FormFile("uploadFile")
  1470. if err != nil {
  1471. //fmt.Println(err)
  1472. context.JSON(200, gin.H{
  1473. "code": -1,
  1474. "message": "上传文件不能为空",
  1475. "data": nil,
  1476. })
  1477. return
  1478. }
  1479. ext := path.Ext(file.Filename)
  1480. originalName := file.Filename
  1481. file.Open()
  1482. uploadData := make([]byte, file.Size)
  1483. dst := "tmp/" + file.Filename
  1484. err = context.SaveUploadedFile(file, dst)
  1485. if err != nil {
  1486. context.JSON(200, gin.H{
  1487. "code": -1,
  1488. "message": "上传文件失败",
  1489. "data": nil,
  1490. })
  1491. return
  1492. }
  1493. f, err := os.Open(dst)
  1494. if err != nil {
  1495. context.JSON(200, gin.H{
  1496. "code": -1,
  1497. "message": "上传文件失败",
  1498. "data": nil,
  1499. })
  1500. return
  1501. }
  1502. defer f.Close()
  1503. uploadData, err = io.ReadAll(f)
  1504. if err != nil {
  1505. context.JSON(200, gin.H{
  1506. "code": -1,
  1507. "message": "上传文件失败",
  1508. "data": nil,
  1509. })
  1510. return
  1511. }
  1512. picUrl, msg, err_ := service.ActMgt{}.GenUpload(userId, ext, originalName, uploadData)
  1513. if err_ != nil {
  1514. context.JSON(200, Response{
  1515. Code: -1,
  1516. Message: msg,
  1517. Data: nil,
  1518. })
  1519. return
  1520. }
  1521. context.JSON(http.StatusOK, Response{
  1522. Code: 0,
  1523. Message: "success",
  1524. Data: map[string]interface{}{
  1525. "url": picUrl,
  1526. },
  1527. })
  1528. }
  1529. func (api *ApiAPI) ApiActMgtUploadFilesPostOld(context *gin.Context) {
  1530. token := context.GetHeader("token")
  1531. var userId int
  1532. if token == "" {
  1533. userId = 0
  1534. } else {
  1535. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1536. }
  1537. if userId == 0 {
  1538. context.JSON(401, gin.H{
  1539. "code": -2,
  1540. "message": "用户未登录",
  1541. "data": nil,
  1542. })
  1543. return
  1544. }
  1545. // 文件处理
  1546. file, err := context.FormFile("uploadFile")
  1547. if err != nil || file == nil {
  1548. //fmt.Println(err)
  1549. context.JSON(200, gin.H{
  1550. "code": -1,
  1551. "message": "上传文件不能为空",
  1552. "data": nil,
  1553. })
  1554. return
  1555. }
  1556. ext := path.Ext(file.Filename)
  1557. originalName := file.Filename
  1558. file.Open()
  1559. uploadData := make([]byte, file.Size)
  1560. dst := "tmp/" + file.Filename
  1561. err = context.SaveUploadedFile(file, dst)
  1562. if err != nil {
  1563. context.JSON(200, gin.H{
  1564. "code": -1,
  1565. "message": "上传文件失败",
  1566. "data": nil,
  1567. })
  1568. return
  1569. }
  1570. f, err := os.Open(dst)
  1571. if err != nil {
  1572. context.JSON(200, gin.H{
  1573. "code": -1,
  1574. "message": "上传文件失败",
  1575. "data": nil,
  1576. })
  1577. return
  1578. }
  1579. defer f.Close()
  1580. uploadData, err = readAndProcessFile(f)
  1581. if err != nil {
  1582. context.JSON(200, gin.H{
  1583. "code": -1,
  1584. "message": "上传文件失败",
  1585. "data": nil,
  1586. })
  1587. return
  1588. }
  1589. picUrl, msg, err_ := service.ActMgt{}.GenUpload(userId, ext, originalName, uploadData)
  1590. if err_ != nil {
  1591. context.JSON(http.StatusInternalServerError, Response{
  1592. Code: -1,
  1593. Message: msg,
  1594. Data: nil,
  1595. })
  1596. return
  1597. }
  1598. context.JSON(http.StatusOK, Response{
  1599. Code: 0,
  1600. Message: "success",
  1601. Data: map[string]interface{}{
  1602. "url": picUrl,
  1603. },
  1604. })
  1605. }
  1606. func (api *ApiAPI) ApiActMgtCardRankDetailQueryPost(context *gin.Context) {
  1607. token := context.GetHeader("token")
  1608. var userId int
  1609. if token == "" {
  1610. userId = 0
  1611. } else {
  1612. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1613. }
  1614. var code int
  1615. if userId == 0 {
  1616. code = 601
  1617. } else {
  1618. code = 0
  1619. }
  1620. //fmt.Println("compId:" + context.PostForm("compId"))
  1621. compId := api.postInt(context, "compId")
  1622. ocaId := api.postInt(context, "ocaId")
  1623. dispArrStr := context.PostForm("dispArrStr")
  1624. r, msg, err_ := service.Card{}.CardRankDetailQuery(compId, dispArrStr, userId, 3, ocaId)
  1625. if err_ == nil {
  1626. context.JSON(200, gin.H{
  1627. "code": code,
  1628. "message": "success",
  1629. "data": r,
  1630. })
  1631. } else {
  1632. context.JSON(200, gin.H{
  1633. "code": -1,
  1634. "message": msg,
  1635. "data": nil,
  1636. })
  1637. }
  1638. }
  1639. func readAndProcessFile(f *os.File) (allData []byte, err error) {
  1640. // 确保文件在函数返回前被关闭
  1641. defer f.Close()
  1642. // 分块读取文件,而不是一次性读入所有内容到内存
  1643. buf := make([]byte, 1024)
  1644. //var allData []byte
  1645. for {
  1646. // 读取数据块
  1647. n, err_ := f.Read(buf[:cap(buf)])
  1648. allData = append(allData, buf[:n]...)
  1649. // 处理错误情况
  1650. if err_ != nil {
  1651. if err == io.EOF {
  1652. break // 正常结束,读取完所有数据
  1653. }
  1654. // 打印错误并处理,例如返回错误
  1655. fmt.Println(err)
  1656. return
  1657. }
  1658. }
  1659. // 这里可以添加对allData的处理逻辑,例如打印或进一步处理数据
  1660. // fmt.Println(string(allData))
  1661. // 没有发生错误,返回nil
  1662. return
  1663. }
  1664. // Get /api/card/UserBasicInformationQuery
  1665. // App设置中“个人信息收集清单”-用户基本信息查询
  1666. func (api *ApiAPI) ApiCardUserBasicInformationQueryGet(c *gin.Context) {
  1667. userId, err := validateTokenByApp(c)
  1668. if err != nil {
  1669. c.JSON(http.StatusUnauthorized, Response{
  1670. Code: -1,
  1671. Message: "token失效",
  1672. Data: nil,
  1673. })
  1674. return
  1675. }
  1676. list, msg, err := service.User{}.GetUserBasicInformation(userId)
  1677. if err != nil {
  1678. c.JSON(http.StatusInternalServerError, Response{
  1679. Code: -1,
  1680. Message: msg,
  1681. Data: nil,
  1682. })
  1683. return
  1684. }
  1685. c.JSON(http.StatusOK, Response{
  1686. Code: 0,
  1687. Message: "success",
  1688. Data: map[string]interface{}{
  1689. "list": list,
  1690. },
  1691. })
  1692. }
  1693. func (api *ApiAPI) ApiCardMonthRankDetailQueryPost(context *gin.Context) {
  1694. token := context.GetHeader("token")
  1695. var userId int
  1696. if token == "" {
  1697. userId = 0
  1698. } else {
  1699. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  1700. }
  1701. dispArrStr := context.PostForm("dispArrStr")
  1702. year := api.postInt(context, "year")
  1703. month := api.postInt(context, "month")
  1704. r, msg, err_ := service.Card{}.MonthRankDetailQuery(year, month, userId, dispArrStr)
  1705. if err_ == nil {
  1706. context.JSON(200, gin.H{
  1707. "code": 0,
  1708. "message": "success",
  1709. "data": r,
  1710. })
  1711. } else {
  1712. context.JSON(200, gin.H{
  1713. "code": -1,
  1714. "message": msg,
  1715. "data": nil,
  1716. })
  1717. }
  1718. }
  1719. func (api *ApiAPI) ApiCardGridsQueryPost(context *gin.Context) {
  1720. token := context.GetHeader("token")
  1721. ecId := api.postInt(context, "ecId") //卡片id
  1722. var userId int
  1723. if token == "" {
  1724. userId = 0
  1725. } else {
  1726. userId = service.User{}.GetUserIdByTokenAllowNil(token)
  1727. }
  1728. r, err_ := service.Card{}.CardGridsQuery(ecId, userId)
  1729. if err_ == nil {
  1730. context.JSON(200, gin.H{
  1731. "code": 0,
  1732. "message": "success",
  1733. "data": r,
  1734. })
  1735. } else {
  1736. context.JSON(200, gin.H{
  1737. "code": -1,
  1738. "message": "",
  1739. "data": nil,
  1740. })
  1741. }
  1742. }
  1743. func (api *ApiAPI) ApiActMgtCompInfoDetailPost(context *gin.Context) {
  1744. token := context.GetHeader("token")
  1745. var userId int
  1746. if token == "" {
  1747. userId = 0
  1748. } else {
  1749. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1750. }
  1751. var code int
  1752. if userId == 0 {
  1753. code = 601
  1754. } else {
  1755. code = 0
  1756. }
  1757. compId := api.postInt(context, "compId")
  1758. r, err_ := service.ActMgt{}.ApiActMgtCompInfoDetailPost(userId, compId)
  1759. if err_ == nil {
  1760. context.JSON(200, gin.H{
  1761. "code": code,
  1762. "message": "",
  1763. "data": r,
  1764. })
  1765. } else {
  1766. context.JSON(200, gin.H{
  1767. "code": -1,
  1768. "message": "查询失败",
  1769. "data": nil,
  1770. })
  1771. }
  1772. }
  1773. func (api *ApiAPI) ApiActMgtCompInfoEditPost(context *gin.Context) {
  1774. token := context.GetHeader("token")
  1775. var userId int
  1776. if token == "" {
  1777. userId = 0
  1778. } else {
  1779. userId = service.ActMgt{}.GetUserIdByTokenAllowNil(token)
  1780. }
  1781. if userId == 0 {
  1782. context.JSON(401, gin.H{
  1783. "code": -2,
  1784. "message": "用户未登录",
  1785. "data": nil,
  1786. })
  1787. return
  1788. }
  1789. compId := api.postInt(context, "compId")
  1790. inJson := context.PostForm("inJson")
  1791. msg, err_ := service.ActMgt{}.ActMgtCompInfoEdit(userId, compId, inJson)
  1792. if err_ == nil {
  1793. context.JSON(200, gin.H{
  1794. "code": 0,
  1795. "message": "",
  1796. "data": nil,
  1797. })
  1798. } else {
  1799. context.JSON(200, gin.H{
  1800. "code": -1,
  1801. "message": msg,
  1802. "data": nil,
  1803. })
  1804. }
  1805. }
  1806. func (api *ApiAPI) ApiCardUserConfigQueryPost(context *gin.Context) {
  1807. ecId := api.postInt(context, "ecId") //卡片id
  1808. pageName := context.PostForm("pageName")
  1809. r, msg, err_ := service.Card{}.UserConfigQuery(ecId, pageName)
  1810. if err_ == nil {
  1811. context.JSON(200, gin.H{
  1812. "code": 0,
  1813. "message": "success",
  1814. "data": r,
  1815. })
  1816. } else {
  1817. context.JSON(200, gin.H{
  1818. "code": -1,
  1819. "message": msg,
  1820. "data": nil,
  1821. })
  1822. }
  1823. }