+2
-5
@@ -8,10 +8,7 @@ log:
|
|||||||
log_dir: logs
|
log_dir: logs
|
||||||
log_level: 5
|
log_level: 5
|
||||||
log_save: true
|
log_save: true
|
||||||
redis:
|
leveldb:
|
||||||
host: 192.168.1.9
|
data_path: ./data/honoka-chan.db
|
||||||
port: "6379"
|
|
||||||
pass: "klsbgames"
|
|
||||||
db: 5
|
|
||||||
sifcap:
|
sifcap:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|||||||
+5
-11
@@ -17,7 +17,7 @@ type AppConfigs struct {
|
|||||||
AppName string `yaml:"app_name"`
|
AppName string `yaml:"app_name"`
|
||||||
Server ServerConfigs `yaml:"server"`
|
Server ServerConfigs `yaml:"server"`
|
||||||
Log LogConfigs `yaml:"log"`
|
Log LogConfigs `yaml:"log"`
|
||||||
Redis RedisConfigs `yaml:"redis"`
|
LevelDb LevelDbConfigs `yaml:"leveldb"`
|
||||||
SifCap SifCapConfigs `yaml:"sifcap"`
|
SifCap SifCapConfigs `yaml:"sifcap"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,11 +34,8 @@ type LogConfigs struct {
|
|||||||
LogSave bool `yaml:"log_save"`
|
LogSave bool `yaml:"log_save"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisConfigs struct {
|
type LevelDbConfigs struct {
|
||||||
Host string `yaml:"host"`
|
DataPath string `yaml:"data_path"`
|
||||||
Port string `yaml:"port"`
|
|
||||||
Pass string `yaml:"pass"`
|
|
||||||
Db int `yaml:"db"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SifCapConfigs struct {
|
type SifCapConfigs struct {
|
||||||
@@ -59,11 +56,8 @@ func DefaultConfigs() *AppConfigs {
|
|||||||
LogLevel: 5,
|
LogLevel: 5,
|
||||||
LogSave: true,
|
LogSave: true,
|
||||||
},
|
},
|
||||||
Redis: RedisConfigs{
|
LevelDb: LevelDbConfigs{
|
||||||
Host: "127.0.0.1",
|
DataPath: "./data/honoka-chan.db",
|
||||||
Port: "6379",
|
|
||||||
Pass: "",
|
|
||||||
Db: 0,
|
|
||||||
},
|
},
|
||||||
SifCap: SifCapConfigs{
|
SifCap: SifCapConfigs{
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"honoka-chan/config"
|
||||||
|
|
||||||
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
|
"github.com/syndtr/goleveldb/leveldb/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LevelDbImpl struct {
|
||||||
|
ldb *leveldb.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
LevelDb LevelDbImpl
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
LevelDb.InitDb()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ldb *LevelDbImpl) InitDb() {
|
||||||
|
ldb.ldb, err = leveldb.OpenFile(config.Conf.LevelDb.DataPath, nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ldb *LevelDbImpl) Get(key []byte) (res []byte, err error) {
|
||||||
|
if len(key) == 0 {
|
||||||
|
return nil, errors.New("key is null")
|
||||||
|
}
|
||||||
|
res, err = ldb.ldb.Get(key, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ldb *LevelDbImpl) Put(key, value []byte) (err error) {
|
||||||
|
if len(key) == 0 {
|
||||||
|
return errors.New("key is null")
|
||||||
|
}
|
||||||
|
err = ldb.ldb.Put(key, value, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ldb *LevelDbImpl) List() (res map[string]string) {
|
||||||
|
res = make(map[string]string)
|
||||||
|
iter := ldb.ldb.NewIterator(nil, nil)
|
||||||
|
for iter.Next() {
|
||||||
|
res[string(iter.Key())] = string(iter.Value())
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ldb *LevelDbImpl) ListPrefix(prefix []byte) (res map[string]string) {
|
||||||
|
res = make(map[string]string)
|
||||||
|
iter := ldb.ldb.NewIterator(util.BytesPrefix(prefix), nil)
|
||||||
|
for iter.Next() {
|
||||||
|
res[string(iter.Key())] = string(iter.Value())
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package database
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"honoka-chan/config"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
RedisCli *redis.Client
|
|
||||||
RedisCtx = context.Background()
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
RedisCli = redis.NewClient(&redis.Options{
|
|
||||||
Addr: config.Conf.Redis.Host + ":" + config.Conf.Redis.Port,
|
|
||||||
Password: config.Conf.Redis.Pass,
|
|
||||||
DB: config.Conf.Redis.Db,
|
|
||||||
})
|
|
||||||
|
|
||||||
_, err := RedisCli.Ping(RedisCtx).Result()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUid(key string) (int, error) {
|
|
||||||
uid, err := RedisCli.HGet(RedisCtx, "login_key_uid", key).Result()
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
userId, err := strconv.Atoi(uid)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if userId == 0 {
|
|
||||||
return 0, errors.New("userId is 0")
|
|
||||||
}
|
|
||||||
|
|
||||||
return userId, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func MatchTokenUid(token, uid string) bool {
|
|
||||||
res, err := RedisCli.HGet(RedisCtx, "token_uid", token).Result()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return res == uid
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func MatchTokenUid(token, uid string) bool {
|
||||||
|
// ret := LevelDb.List()
|
||||||
|
// for k, v := range ret {
|
||||||
|
// fmt.Println(k, v)
|
||||||
|
// fmt.Println()
|
||||||
|
// }
|
||||||
|
res, err := LevelDb.Get([]byte(token))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res) == uid
|
||||||
|
}
|
||||||
@@ -2,10 +2,7 @@ module honoka-chan
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require github.com/gin-gonic/gin v1.8.2
|
||||||
github.com/gin-gonic/gin v1.8.2
|
|
||||||
github.com/redis/go-redis/v9 v9.0.2
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/mattn/go-sqlite3 v1.14.16
|
github.com/mattn/go-sqlite3 v1.14.16
|
||||||
@@ -13,13 +10,12 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.0 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.0 // indirect
|
github.com/go-playground/locales v0.14.0 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||||
@@ -32,6 +28,7 @@ require (
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||||
|
github.com/syndtr/goleveldb v1.0.0
|
||||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
|
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
|
||||||
golang.org/x/net v0.4.0 // indirect
|
golang.org/x/net v0.4.0 // indirect
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
github.com/bsm/ginkgo/v2 v2.5.0 h1:aOAnND1T40wEdAtkGSkvSICWeQ8L3UASX7YVCqQx+eQ=
|
|
||||||
github.com/bsm/gomega v1.20.0 h1:JhAwLmtRzXFTx2AkALSLa8ijZafntmhSoU63Ok18Uq8=
|
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY=
|
github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY=
|
||||||
@@ -22,12 +17,17 @@ github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJ
|
|||||||
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
|
||||||
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
|
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
|
||||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
|
||||||
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
|
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
|
||||||
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
|
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
|
||||||
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
@@ -48,13 +48,16 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OH
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
|
||||||
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
|
||||||
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/redis/go-redis/v9 v9.0.2 h1:BA426Zqe/7r56kCcvxYLWe1mkaz71LKF77GwgFzSxfE=
|
|
||||||
github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps=
|
|
||||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||||
@@ -68,6 +71,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
|
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||||
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
@@ -83,12 +88,15 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+Wr
|
|||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -117,6 +125,11 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
|
|||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
+37
-34
@@ -27,7 +27,8 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
var results []interface{}
|
var results []interface{}
|
||||||
for _, v := range formdata {
|
for _, v := range formdata {
|
||||||
var res string
|
var res []byte
|
||||||
|
var key string
|
||||||
var err error
|
var err error
|
||||||
// fmt.Println(v)
|
// fmt.Println(v)
|
||||||
// fmt.Println(v.Module, v.Action)
|
// fmt.Println(v.Module, v.Action)
|
||||||
@@ -36,119 +37,121 @@ func ApiHandler(ctx *gin.Context) {
|
|||||||
case "login":
|
case "login":
|
||||||
if v.Action == "topInfo" {
|
if v.Action == "topInfo" {
|
||||||
// fmt.Println("topInfo")
|
// fmt.Println("topInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "login_topinfo_result").Result()
|
key = "login_topinfo_result"
|
||||||
} else if v.Action == "topInfoOnce" {
|
} else if v.Action == "topInfoOnce" {
|
||||||
// fmt.Println("topInfoOnce")
|
// fmt.Println("topInfoOnce")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "login_topinfo_once_result").Result()
|
key = "login_topinfo_once_result"
|
||||||
}
|
}
|
||||||
case "live":
|
case "live":
|
||||||
if v.Action == "liveStatus" {
|
if v.Action == "liveStatus" {
|
||||||
// fmt.Println("liveStatus")
|
// fmt.Println("liveStatus")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "live_status_result").Result()
|
key = "live_status_result"
|
||||||
} else if v.Action == "schedule" {
|
} else if v.Action == "schedule" {
|
||||||
// fmt.Println("schedule")
|
// fmt.Println("schedule")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "live_list_result").Result()
|
key = "live_list_result"
|
||||||
}
|
}
|
||||||
case "unit":
|
case "unit":
|
||||||
switch v.Action {
|
switch v.Action {
|
||||||
case "unitAll":
|
case "unitAll":
|
||||||
// fmt.Println("unitAll")
|
// fmt.Println("unitAll")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "unit_list_result").Result()
|
key = "unit_list_result"
|
||||||
case "deckInfo":
|
case "deckInfo":
|
||||||
// fmt.Println("deckInfo")
|
// fmt.Println("deckInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "unit_deck_result").Result()
|
key = "unit_deck_result"
|
||||||
case "supporterAll":
|
case "supporterAll":
|
||||||
// fmt.Println("supporterAll")
|
// fmt.Println("supporterAll")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "unit_support_result").Result()
|
key = "unit_support_result"
|
||||||
case "removableSkillInfo":
|
case "removableSkillInfo":
|
||||||
// fmt.Println("removableSkillInfo")
|
// fmt.Println("removableSkillInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "owning_equip_result").Result()
|
key = "owning_equip_result"
|
||||||
case "accessoryAll":
|
case "accessoryAll":
|
||||||
// fmt.Println("accessoryAll")
|
// fmt.Println("accessoryAll")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "unit_accessory_result").Result()
|
key = "unit_accessory_result"
|
||||||
}
|
}
|
||||||
case "costume":
|
case "costume":
|
||||||
// fmt.Println("costumeList")
|
// fmt.Println("costumeList")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "costume_list_result").Result()
|
key = "costume_list_result"
|
||||||
case "album":
|
case "album":
|
||||||
// fmt.Println("albumAll")
|
// fmt.Println("albumAll")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "album_unit_result").Result()
|
key = "album_unit_result"
|
||||||
case "scenario":
|
case "scenario":
|
||||||
// fmt.Println("scenarioStatus")
|
// fmt.Println("scenarioStatus")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "scenario_status_result").Result()
|
key = "scenario_status_result"
|
||||||
case "subscenario":
|
case "subscenario":
|
||||||
// fmt.Println("subscenarioStatus")
|
// fmt.Println("subscenarioStatus")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "subscenario_status_result").Result()
|
key = "subscenario_status_result"
|
||||||
case "eventscenario":
|
case "eventscenario":
|
||||||
// fmt.Println("status")
|
// fmt.Println("status")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "event_scenario_result").Result()
|
key = "event_scenario_result"
|
||||||
case "multiunit":
|
case "multiunit":
|
||||||
// fmt.Println("multiunitscenarioStatus")
|
// fmt.Println("multiunitscenarioStatus")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "multi_unit_scenario_result").Result()
|
key = "multi_unit_scenario_result"
|
||||||
case "payment":
|
case "payment":
|
||||||
// fmt.Println("productList")
|
// fmt.Println("productList")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "product_result").Result()
|
key = "product_result"
|
||||||
case "banner":
|
case "banner":
|
||||||
// fmt.Println("bannerList")
|
// fmt.Println("bannerList")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "banner_result").Result()
|
key = "banner_result"
|
||||||
case "notice":
|
case "notice":
|
||||||
// fmt.Println("noticeMarquee")
|
// fmt.Println("noticeMarquee")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "item_marquee_result").Result()
|
key = "item_marquee_result"
|
||||||
case "user":
|
case "user":
|
||||||
// fmt.Println("getNavi")
|
// fmt.Println("getNavi")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "user_intro_result").Result()
|
key = "user_intro_result"
|
||||||
case "navigation":
|
case "navigation":
|
||||||
// fmt.Println("specialCutin")
|
// fmt.Println("specialCutin")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "special_cutin_result").Result()
|
key = "special_cutin_result"
|
||||||
case "award":
|
case "award":
|
||||||
// fmt.Println("awardInfo")
|
// fmt.Println("awardInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "award_result").Result()
|
key = "award_result"
|
||||||
case "background":
|
case "background":
|
||||||
// fmt.Println("backgroundInfo")
|
// fmt.Println("backgroundInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "background_result").Result()
|
key = "background_result"
|
||||||
case "stamp":
|
case "stamp":
|
||||||
// fmt.Println("stampInfo")
|
// fmt.Println("stampInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "stamp_result").Result()
|
key = "stamp_result"
|
||||||
case "exchange":
|
case "exchange":
|
||||||
// fmt.Println("owningPoint")
|
// fmt.Println("owningPoint")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "exchange_point_result").Result()
|
key = "exchange_point_result"
|
||||||
case "livese":
|
case "livese":
|
||||||
// fmt.Println("liveseInfo")
|
// fmt.Println("liveseInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "live_se_result").Result()
|
key = "live_se_result"
|
||||||
case "liveicon":
|
case "liveicon":
|
||||||
// fmt.Println("liveiconInfo")
|
// fmt.Println("liveiconInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "live_icon_result").Result()
|
key = "live_icon_result"
|
||||||
case "item":
|
case "item":
|
||||||
// fmt.Println("list")
|
// fmt.Println("list")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "item_list_result").Result()
|
key = "item_list_result"
|
||||||
case "marathon":
|
case "marathon":
|
||||||
// fmt.Println("marathonInfo")
|
// fmt.Println("marathonInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "marathon_result").Result()
|
key = "marathon_result"
|
||||||
case "challenge":
|
case "challenge":
|
||||||
// fmt.Println("challengeInfo")
|
// fmt.Println("challengeInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "challenge_result").Result()
|
key = "challenge_result"
|
||||||
case "museum":
|
case "museum":
|
||||||
// fmt.Println("info")
|
// fmt.Println("info")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "museum_result").Result()
|
key = "museum_result"
|
||||||
case "profile":
|
case "profile":
|
||||||
if v.Action == "liveCnt" {
|
if v.Action == "liveCnt" {
|
||||||
// fmt.Println("liveCnt")
|
// fmt.Println("liveCnt")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "profile_livecnt_result").Result()
|
key = "profile_livecnt_result"
|
||||||
} else if v.Action == "cardRanking" {
|
} else if v.Action == "cardRanking" {
|
||||||
// fmt.Println("cardRanking")
|
// fmt.Println("cardRanking")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "profile_card_ranking_result").Result()
|
key = "profile_card_ranking_result"
|
||||||
} else if v.Action == "profileInfo" {
|
} else if v.Action == "profileInfo" {
|
||||||
// fmt.Println("profileInfo")
|
// fmt.Println("profileInfo")
|
||||||
res, err = database.RedisCli.HGet(database.RedisCtx, "temp_dataset", "profile_info_result").Result()
|
key = "profile_info_result"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// fmt.Println("Fuck you!")
|
// fmt.Println("Fuck you!")
|
||||||
err = errors.New("invalid option")
|
err = errors.New("invalid option")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res, err = database.LevelDb.Get([]byte(key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var result interface{}
|
var result interface{}
|
||||||
err = json.Unmarshal([]byte(res), &result)
|
err = json.Unmarshal([]byte(res), &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+15
-4
@@ -9,9 +9,11 @@ import (
|
|||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/utils"
|
"honoka-chan/utils"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AuthKeyHandler(ctx *gin.Context) {
|
func AuthKeyHandler(ctx *gin.Context) {
|
||||||
@@ -49,7 +51,11 @@ func AuthKeyHandler(ctx *gin.Context) {
|
|||||||
"client_token": clientToken,
|
"client_token": clientToken,
|
||||||
"server_token": serverToken,
|
"server_token": serverToken,
|
||||||
}
|
}
|
||||||
_, err = database.RedisCli.HSet(database.RedisCtx, authorizeToken, authData).Result()
|
authJson, err := json.Marshal(authData)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
database.LevelDb.Put([]byte(authorizeToken), authJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -87,13 +93,16 @@ func LoginHandler(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
authData, err := database.RedisCli.HGetAll(database.RedisCtx, authToken).Result()
|
// authData, err := database.RedisCli.HGetAll(database.RedisCtx, authToken).Result()
|
||||||
|
authData, err := database.LevelDb.Get([]byte(authToken))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println(authData)
|
fmt.Println(authData)
|
||||||
|
|
||||||
clientToken, serverToken := authData["client_token"], authData["server_token"]
|
// clientToken, serverToken := authData["client_token"], authData["server_token"]
|
||||||
|
clientToken := gjson.Get(string(authData), "client_token").String()
|
||||||
|
serverToken := gjson.Get(string(authData), "server_token").String()
|
||||||
clientToken64, err := base64.RawStdEncoding.DecodeString(clientToken)
|
clientToken64, err := base64.RawStdEncoding.DecodeString(clientToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -138,9 +147,11 @@ func LoginHandler(ctx *gin.Context) {
|
|||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
userId := 9999999
|
userId := 9999999
|
||||||
|
sUserId := strconv.Itoa(userId)
|
||||||
authorizeToken := utils.RandomBase64Token(32)
|
authorizeToken := utils.RandomBase64Token(32)
|
||||||
|
|
||||||
_, err = database.RedisCli.HSet(database.RedisCtx, "token_uid", authorizeToken, userId).Result()
|
// _, err = database.RedisCli.HSet(database.RedisCtx, "token_uid", authorizeToken, userId).Result()
|
||||||
|
err = database.LevelDb.Put([]byte(authorizeToken), []byte(sUserId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-3
@@ -89,7 +89,11 @@ func AnalysisApi1Data(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if key != "" {
|
if key != "" {
|
||||||
database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m))
|
// database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m))
|
||||||
|
err = database.LevelDb.Put([]byte(key), m)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +137,11 @@ func AnalysisApi2Data(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if key != "" {
|
if key != "" {
|
||||||
database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m))
|
// database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m))
|
||||||
|
err = database.LevelDb.Put([]byte(key), m)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +183,11 @@ func AnalysisApi3Data(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if key != "" {
|
if key != "" {
|
||||||
database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m))
|
// database.RedisCli.HSet(database.RedisCtx, "temp_dataset", key, string(m))
|
||||||
|
err = database.LevelDb.Put([]byte(key), m)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user