广告平台(媒体使用)
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

aces_test.go 3.5 KiB

před 2 měsíci
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package test
  2. import (
  3. "applet/app/db"
  4. "applet/app/md"
  5. "applet/app/svc"
  6. "applet/app/utils"
  7. "encoding/base64"
  8. "encoding/json"
  9. "fmt"
  10. "testing"
  11. )
  12. func TestAesCrypt_Encrypt(t *testing.T) {
  13. var aesCrypt = utils.AesCrypt{
  14. Key: []byte("e{&[^<wpliI$AgKs:>Ft(.~g]1eR-]VO"),
  15. Iv: []byte("ZV`7<5X]/2brS@sz"),
  16. }
  17. var text = `{"uid":"82","applyOrder":"821607392542143106","db":{"db_host":"119.23.182.117","db_port":"3306","db_name":"fnuoos_template","db_username":"root","db_password":"Fnuo123com@"}}`
  18. result, err := aesCrypt.Encrypt([]byte(text))
  19. if err != nil {
  20. fmt.Println(err)
  21. return
  22. }
  23. pass64 := base64.StdEncoding.EncodeToString(result)
  24. fmt.Println(pass64)
  25. }
  26. func TestAesCrypt_Decrypt(t *testing.T) {
  27. var aesCrypt = utils.AesCrypt{
  28. Key: []byte("e{&[^<wpliI$AgKs:>Ft(.~g]1eR-]VO"),
  29. Iv: []byte("ZV`7<5X]/2brS@sz"),
  30. }
  31. pass64 := "JD0RXX1YbZPWKeNiVKsq0jQ1Bfnbln3fIMcmJkovU5gUCf329y9ZdqECWe4OKpoOk25/hPNaBH9VwellhIQhpw=="
  32. bytesPass, err := base64.StdEncoding.DecodeString(pass64)
  33. if err != nil {
  34. fmt.Println(err)
  35. return
  36. }
  37. plainText, err := aesCrypt.Decrypt(bytesPass)
  38. if err != nil {
  39. fmt.Println(err)
  40. return
  41. }
  42. fmt.Println(string(plainText))
  43. }
  44. func Test_Vi(t *testing.T) {
  45. fmt.Println("123")
  46. fmt.Println([]byte("ZV`7<5X]/2brS@sz"))
  47. }
  48. func Test_CombineData(t *testing.T) {
  49. data :=
  50. `{
  51. "Uid": 21699,
  52. "Lv": 0,
  53. "NewLv": 0,
  54. "LevelWeight": -1,
  55. "Profit": 7.13,
  56. "SubsidyFee": 0,
  57. "ProfitList": [
  58. {
  59. "cid": "0",
  60. "val": 7.13
  61. },
  62. {
  63. "cid": "1",
  64. "val": 10
  65. },
  66. {
  67. "cid": "19",
  68. "val": 120
  69. },
  70. {
  71. "cid": "20",
  72. "val": 0
  73. },
  74. {
  75. "cid": "21",
  76. "val": 0
  77. }
  78. ],
  79. "SubsidyFeeList": null,
  80. "OwnbuyReturnType": 0,
  81. "Diff": 0,
  82. "ParentUser": {
  83. "Uid": 553,
  84. "Lv": 8,
  85. "NewLv": 0,
  86. "LevelWeight": 2,
  87. "Profit": 0,
  88. "SubsidyFee": 0,
  89. "ProfitList": [
  90. {
  91. "cid": "0",
  92. "val": 0
  93. }
  94. ],
  95. "SubsidyFeeList": null,
  96. "OwnbuyReturnType": 0,
  97. "Diff": 1,
  98. "ParentUser": {
  99. "Uid": 21699,
  100. "Lv": 0,
  101. "NewLv": 0,
  102. "LevelWeight": -1,
  103. "Profit": 7.13,
  104. "SubsidyFee": 0,
  105. "ProfitList": [
  106. {
  107. "cid": "0",
  108. "val": 7.13
  109. },
  110. {
  111. "cid": "1",
  112. "val": 10
  113. },
  114. {
  115. "cid": "19",
  116. "val": 120
  117. },
  118. {
  119. "cid": "20",
  120. "val": 0
  121. },
  122. {
  123. "cid": "21",
  124. "val": 0
  125. }
  126. ],
  127. "SubsidyFeeList": null,
  128. "OwnbuyReturnType": 0,
  129. "Diff": 0,
  130. "ParentUser": {
  131. "Uid": 553,
  132. "Lv": 8,
  133. "NewLv": 0,
  134. "LevelWeight": 2,
  135. "Profit": 0,
  136. "SubsidyFee": 0,
  137. "ProfitList": [
  138. {
  139. "cid": "0",
  140. "val": 0
  141. }
  142. ],
  143. "SubsidyFeeList": null,
  144. "OwnbuyReturnType": 0,
  145. "Diff": 1,
  146. "ParentUser": null
  147. }
  148. }
  149. }
  150. }`
  151. bytes := []byte(data)
  152. var lvUser md.LvUser
  153. if err := json.Unmarshal(bytes, &lvUser); err != nil {
  154. fmt.Println(err)
  155. return
  156. }
  157. dataSlice := svc.CombineVirtualCoinRelateData(&lvUser, 249534162504132595, "mall_goods", 0)
  158. for _, item := range dataSlice {
  159. fmt.Printf("%#v\n", item)
  160. }
  161. err := db.DbInsertBatch(db.DBs["123456"], dataSlice)
  162. if err != nil {
  163. fmt.Println(err)
  164. }
  165. }