siaga/modules/plate.go
zhangkun9038@dingtalk.com 9e7aa4fb94 实现maX
2024-12-15 22:27:50 +08:00

37 lines
850 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package module
import (
"encoding/json"
// "errors"
// "fmt"
"github.com/phyer/core"
// "os"
// "strconv"
// "strings"
// // "sync"
// "time"
// //
// // simple "github.com/bitly/go-simplejson"
// "github.com/go-redis/redis"
// // "github.com/phyer/core/utils"
// logrus "github.com/sirupsen/logrus"
)
// TODO 从redis里读出来已经存储的plate如果不存在就创建一个新的
func LoadPlate(cr *core.Core, instId string) (*core.Plate, error) {
pl := core.Plate{}
plateName := instId + "|plate"
_, err := cr.RedisLocalCli.Exists().Result()
if err == nil {
str, _ := cr.RedisLocalCli.Get(plateName).Result()
json.Unmarshal([]byte(str), &pl)
} else {
pl.Init(instId)
prs := cr.Cfg.Config.Get("candleDimentions").MustArray()
for _, v := range prs {
pl.MakeCoaster(cr, v.(string))
}
}
return &pl, nil
}