|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- package test
-
- import (
- "applet/app/db"
- "applet/app/md"
- "applet/app/svc"
- "applet/app/utils"
- "encoding/base64"
- "encoding/json"
- "fmt"
- "testing"
- )
-
- func TestAesCrypt_Encrypt(t *testing.T) {
- var aesCrypt = utils.AesCrypt{
- Key: []byte("e{&[^<wpliI$AgKs:>Ft(.~g]1eR-]VO"),
- Iv: []byte("ZV`7<5X]/2brS@sz"),
- }
-
- 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@"}}`
- result, err := aesCrypt.Encrypt([]byte(text))
- if err != nil {
- fmt.Println(err)
- return
- }
-
- pass64 := base64.StdEncoding.EncodeToString(result)
- fmt.Println(pass64)
- }
-
- func TestAesCrypt_Decrypt(t *testing.T) {
- var aesCrypt = utils.AesCrypt{
- Key: []byte("e{&[^<wpliI$AgKs:>Ft(.~g]1eR-]VO"),
- Iv: []byte("ZV`7<5X]/2brS@sz"),
- }
-
- pass64 := "JD0RXX1YbZPWKeNiVKsq0jQ1Bfnbln3fIMcmJkovU5gUCf329y9ZdqECWe4OKpoOk25/hPNaBH9VwellhIQhpw=="
- bytesPass, err := base64.StdEncoding.DecodeString(pass64)
- if err != nil {
- fmt.Println(err)
- return
- }
-
- plainText, err := aesCrypt.Decrypt(bytesPass)
- if err != nil {
- fmt.Println(err)
- return
- }
-
- fmt.Println(string(plainText))
- }
-
- func Test_Vi(t *testing.T) {
- fmt.Println("123")
- fmt.Println([]byte("ZV`7<5X]/2brS@sz"))
- }
-
- func Test_CombineData(t *testing.T) {
- data :=
- `{
- "Uid": 21699,
- "Lv": 0,
- "NewLv": 0,
- "LevelWeight": -1,
- "Profit": 7.13,
- "SubsidyFee": 0,
- "ProfitList": [
- {
- "cid": "0",
- "val": 7.13
- },
- {
- "cid": "1",
- "val": 10
- },
- {
- "cid": "19",
- "val": 120
- },
- {
- "cid": "20",
- "val": 0
- },
- {
- "cid": "21",
- "val": 0
- }
- ],
- "SubsidyFeeList": null,
- "OwnbuyReturnType": 0,
- "Diff": 0,
- "ParentUser": {
- "Uid": 553,
- "Lv": 8,
- "NewLv": 0,
- "LevelWeight": 2,
- "Profit": 0,
- "SubsidyFee": 0,
- "ProfitList": [
- {
- "cid": "0",
- "val": 0
- }
- ],
- "SubsidyFeeList": null,
- "OwnbuyReturnType": 0,
- "Diff": 1,
- "ParentUser": {
- "Uid": 21699,
- "Lv": 0,
- "NewLv": 0,
- "LevelWeight": -1,
- "Profit": 7.13,
- "SubsidyFee": 0,
- "ProfitList": [
- {
- "cid": "0",
- "val": 7.13
- },
- {
- "cid": "1",
- "val": 10
- },
- {
- "cid": "19",
- "val": 120
- },
- {
- "cid": "20",
- "val": 0
- },
- {
- "cid": "21",
- "val": 0
- }
- ],
- "SubsidyFeeList": null,
- "OwnbuyReturnType": 0,
- "Diff": 0,
- "ParentUser": {
- "Uid": 553,
- "Lv": 8,
- "NewLv": 0,
- "LevelWeight": 2,
- "Profit": 0,
- "SubsidyFee": 0,
- "ProfitList": [
- {
- "cid": "0",
- "val": 0
- }
- ],
- "SubsidyFeeList": null,
- "OwnbuyReturnType": 0,
- "Diff": 1,
- "ParentUser": null
- }
- }
- }
- }`
- bytes := []byte(data)
- var lvUser md.LvUser
- if err := json.Unmarshal(bytes, &lvUser); err != nil {
- fmt.Println(err)
- return
- }
- dataSlice := svc.CombineVirtualCoinRelateData(&lvUser, 249534162504132595, "mall_goods", 0)
- for _, item := range dataSlice {
- fmt.Printf("%#v\n", item)
- }
- err := db.DbInsertBatch(db.DBs["123456"], dataSlice)
- if err != nil {
- fmt.Println(err)
- }
- }
|