|
- 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)
- }
- }
|