wx-server/internal/config/config.go

64 lines
2.0 KiB
Go
Raw Normal View History

2024-06-04 21:22:50 +08:00
package config
import (
"github.com/sirupsen/logrus"
)
// 微信全局配置表
type weixin struct {
AppId string
AppSecret string
Site string
HttpTail string
}
func (wx weixin) AppUrl(code string) string {
return wx.Site + "appid=" + wx.AppId + "&secret=" + wx.AppSecret + "&js_code=" + code + wx.HttpTail
}
// 微信小程序配置表
var WeiXin = weixin{
AppId: "wxae661fd0f9edd7da",
AppSecret: "f086d7be25d4cc53bc96f5411cf44548",
Site: "https://api.weixin.qq.com/sns/jscode2session?",
HttpTail: "&grant_type=authorization_code",
}
// 数据库连接信息
// var MysqlDSN = "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=true&loc=Local"
var MysqlDSN = "takway:takway123456@tcp(127.0.0.1:3306)/takway?charset=utf8mb4&parseTime=true&loc=Local"
// 是否使用tls
var TlsEnable = true
var TlsFileKey = "./cert/takway-ai.top.key"
var TlsFilePem = "./cert/takway-ai.top.pem"
// 本程序的服务监听地址
var ServerListenAddress = "0.0.0.0:8002"
// jwtkey
var JwtEnable = true // 是否开启jwt
// var JwtEnable = false // 是否开启jwt仅测试时打开方便使用apifox测试。
var JwtKey = "weilaimengzhu_api_ajsdkfajsldfkjasl"
var JwtApiAuthWhiteList = map[string]string{
"/api/users/wx/login": "POST", // 微信快捷登录
}
// 是否处理跨域请求
var CorsEnable = false
// 设置logrus日志等级和日志文件
var LogLevel = logrus.TraceLevel
var LogFile = "./server.log"
// 是否使用默认用户仅测试时打开方便使用apifox测试。
// var UseDefaultUserId = true
var UseDefaultUserId = false
var DefaultUserId = int32(7) // 7是我的用户ID
// 是否开启文件缓存机制。key为fileIdvalue为*dao.File缓存一段时间减少与mysql交互。
// var FileCacheEnable = true
var FileCacheEnable = false // 由于客户可能会手动修改mysql中的群二维码截图所以这里关闭文件缓存服务避免二维码更新不及时。
// 后续可以考虑提供接口专门更新二维码图片,这样文件缓存开关就可以一直开着。