123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package config
- import (
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jypkg/middleground"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/gogf/gf/v2/os/gcfg"
- )
- type appConfig struct {
- WebPort string `json:"webport"` //程序端口
- AppId string `json:"appid"` //程序标识
- OssAdmin string `json:"ossAdmin"` //阿里云oss域名
- OssBucket struct {
- Std string `json:"std"` //标准库bucket
- User string `json:"user"` //用户库
- Priv string `json:"priv"` //缩略图片
- } `json:"ossBucket"` //阿里云ossbucket
- RpcServers struct {
- StdDoc rpcConfig `json:"stdDoc"` //标准库rpc接口
- UserDoc rpcConfig `json:"userDoc"` //用户收藏rpc接口
- Points rpcConfig `json:"points"` //剑鱼积分rpc接口
- JyFile rpcConfig `json:"jyFile"` //剑鱼文件rpc接口
- } `json:"rpcServers"` //rpc服务配置
- IndexSearchTag []string `json:"indexSearchTag"` //首页标签
- SearchNumLimit int64 `json:"searchNumLimit"` //检索条数限制
- ShareUrl string `json:"shareUrl"` //分享地址
- DoudingImg string `json:"doudingImg"` // 豆丁封面图片地址
- Price map[int64]map[int64]struct {
- Rate int64 `json:"rate"` // 价格转换比率
- Base int64 `json:"base"` // 价格基数
- } `json:"price"`
- DocMember struct {
- Times int `json:"times"` // 会员免费下载次数
- Discount int64 `json:"discount"` // 会员折扣
- Source []string `json:"source"` // 留资source
- } `json:"docMember"`
- }
- /*
- 例如
- "price": {
- "2": { // 对应文档来源 文档来源:;2:豆丁;
- "1": { // 对应商品类型 1:会员免费;2:精品(付费)
- "rate": 0, // 比率
- "base": 50 // 基数 例如会员免费文档 50+0*price = 50
- },
- "2": {
- "rate": 100, // 例如 精品 100+100*price
- "base": 100
- }
- }
- }
- */
- type rpcConfig struct {
- Key string `json:"key"`
- Address []string `json:"address"` //集群地址
- }
- var JyDocsAppConfig appConfig
- var Middleground *middleground.Middleground
- func init() {
- g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("config.yaml")
- var ctx = gctx.New()
- Middleground = middleground.NewMiddleground(g.Cfg().MustGet(ctx, "etcd.hosts").Strings()).
- RegUserCenter(g.Cfg().MustGet(ctx, "userCenterKey").String())
- common.ReadConfig(&JyDocsAppConfig)
- }
|