37 changed files with 1397 additions and 2 deletions
@ -1,3 +1,19 @@ |
|||||
# appNewPlatform |
# App服务端 |
||||
|
|
||||
新的应用平台采用国密SM4算法进行加解密 |
## 文件结构 |
||||
|
|
||||
|
``` |
||||
|
|—— config |
||||
|
└── app |
||||
|
└── database |
||||
|
└── nosql |
||||
|
└── yamlConfig |
||||
|
|—— constant |
||||
|
|—— controller |
||||
|
└── database |
||||
|
└── nosql |
||||
|
└── app |
||||
|
└── route |
||||
|
|initialization |
||||
|
|—— main.go |
||||
|
``` |
||||
|
|||||
@ -0,0 +1,12 @@ |
|||||
|
package appConstant |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/config/app" |
||||
|
) |
||||
|
|
||||
|
// 常量
|
||||
|
var ( |
||||
|
AppConfigPath = "./config/yamlConfig/app.yaml" //服务基础配置文件
|
||||
|
Constant_Config app.Server //服务基础配置
|
||||
|
MaxCpuNumber int |
||||
|
) |
||||
@ -0,0 +1,15 @@ |
|||||
|
package appConstant |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/config/database" |
||||
|
|
||||
|
"gorm.io/gorm" |
||||
|
) |
||||
|
|
||||
|
//数据库常量配置
|
||||
|
|
||||
|
var ( |
||||
|
ConfigDatabaseConstant = "./config/yamlConfig/database.yaml" //数据库配置文件
|
||||
|
CONSTANT_MYSQL database.MysqlSetUp //数据库预设
|
||||
|
CONSTANT_DB_Master *gorm.DB //主数据库
|
||||
|
) |
||||
@ -0,0 +1,29 @@ |
|||||
|
package appConstant |
||||
|
|
||||
|
import ( |
||||
|
"github.com/redis/go-redis/v9" |
||||
|
) |
||||
|
|
||||
|
//redis全局配置
|
||||
|
|
||||
|
var ( |
||||
|
ConfigRedisConstant = "./config/yamlConfig/redis.yaml" //Redis配置文件
|
||||
|
|
||||
|
CONSTANT_REDIS0 *redis.Client |
||||
|
CONSTANT_REDIS1 *redis.Client |
||||
|
CONSTANT_REDIS2 *redis.Client |
||||
|
CONSTANT_REDIS3 *redis.Client |
||||
|
CONSTANT_REDIS4 *redis.Client |
||||
|
CONSTANT_REDIS5 *redis.Client |
||||
|
CONSTANT_REDIS6 *redis.Client |
||||
|
CONSTANT_REDIS7 *redis.Client |
||||
|
CONSTANT_REDIS8 *redis.Client |
||||
|
CONSTANT_REDIS9 *redis.Client |
||||
|
CONSTANT_REDIS10 *redis.Client |
||||
|
CONSTANT_REDIS11 *redis.Client |
||||
|
CONSTANT_REDIS12 *redis.Client |
||||
|
CONSTANT_REDIS13 *redis.Client |
||||
|
CONSTANT_REDIS14 *redis.Client |
||||
|
CONSTANT_REDIS15 *redis.Client |
||||
|
CONSTANT_ClusterClient *redis.ClusterClient //集群库
|
||||
|
) |
||||
@ -0,0 +1,57 @@ |
|||||
|
package app |
||||
|
|
||||
|
//服务基础配置
|
||||
|
type Server struct { |
||||
|
Appsetup appsetup `mapstructure:"appsetup" json:"appsetup" yaml:"appsetup"` |
||||
|
Logsetup logsetup `mapstructure:"logconfig" json:"logconfig" yaml:"logconfig"` |
||||
|
Captcha captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"` |
||||
|
RedisPrefixStr redisPrefixStr `mapstructure:"redisprefix" json:"redisprefix" yaml:"redisprefix"` |
||||
|
WechatCompany wechatCompany `mapstructure:"wechatcompany" json:"wechatcompany" yaml:"wechatcompany"` //企业ID
|
||||
|
} |
||||
|
|
||||
|
//服务配置详情
|
||||
|
type appsetup struct { |
||||
|
Port int `mapstructure:"port" json:"port" yaml:"port"` |
||||
|
Readtime int `mapstructure:"readtime" json:"readtime" yaml:"readtime"` |
||||
|
Writetime int `mapstructure:"writetime" json:"writetime" yaml:"writetime"` |
||||
|
AppKey string `mapstructure:"appkey" json:"appkey" yaml:"appkey"` |
||||
|
DefaultPassword string `mapstructure:"password" json:"password" yaml:"password"` |
||||
|
PreFix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` |
||||
|
WebUrl string `mapstructure:"weburl" json:"weburl" yaml:"weburl"` |
||||
|
PcbUrl string `mapstructure:"pcurl" json:"pcurl" yaml:"pcurl"` |
||||
|
} |
||||
|
|
||||
|
//日志配置
|
||||
|
type logsetup struct { |
||||
|
Path string `mapstructure:"path" json:"path" yaml:"path"` |
||||
|
} |
||||
|
|
||||
|
//验证码相关
|
||||
|
type captcha struct { |
||||
|
KeyLong int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"` // 验证码长度
|
||||
|
ImgWidth int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"` // 验证码宽度
|
||||
|
ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"` // 验证码高度
|
||||
|
} |
||||
|
|
||||
|
type redisPrefixStr struct { |
||||
|
PreFix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 键前缀
|
||||
|
Alias string `mapstructure:"alias" json:"alias" yaml:"alias"` // 别名
|
||||
|
ActivateCluster bool `mapstructure:"activateCluster" json:"activateCluster" yaml:"activateCluster"` // 是否开启集群
|
||||
|
|
||||
|
PoolSize int `mapstructure:"poolSize" json:"poolSize" yaml:"poolSize"` // 连接池最大socket连接数,默认为4倍CPU数, 4 * runtime.NumCPU
|
||||
|
MinIdleConns int `mapstructure:"minIdleConns" json:"minIdleConns" yaml:"minIdleConns"` //在启动阶段创建指定数量的Idle连接,并长期维持idle状态的连接数不少于指定数量;。
|
||||
|
DialTimeout int `mapstructure:"dialTimeout" json:"dialTimeout" yaml:"dialTimeout"` //连接建立超时时间,默认5秒。
|
||||
|
} |
||||
|
|
||||
|
//企业微信基础配置
|
||||
|
type wechatCompany struct { |
||||
|
CompanyId string `mapstructure:"companyid" json:"companyid" yaml:"companyid"` // 企业ID
|
||||
|
} |
||||
|
|
||||
|
//企业微信自建引用结构
|
||||
|
type wechatConfig struct { |
||||
|
Agentid string `mapstructure:"agentid" json:"agentid" yaml:"agentid"` // Agentid
|
||||
|
Secret string `mapstructure:"secret" json:"secret" yaml:"secret"` // Secret
|
||||
|
Token string `mapstructure:"token" json:"token" yaml:"token"` // Token
|
||||
|
Encodingaeskey string `mapstructure:"encodingaeskey" json:"encodingaeskey" yaml:"encodingaeskey"` // EncodingAESKey
|
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package app |
||||
|
|
||||
|
import ( |
||||
|
"net/http" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
type server interface { |
||||
|
ListenAndServe() error |
||||
|
} |
||||
|
|
||||
|
// 设置服务启动
|
||||
|
func InitServer(port string, handler *gin.Engine) server { |
||||
|
return &http.Server{ |
||||
|
Addr: port, //监听的TCP地址,如果为空字符串会使用":http"
|
||||
|
Handler: handler, //调用的处理器,如为nil会调用http.DefaultServeMux
|
||||
|
ReadTimeout: 3600 * time.Second, //请求的读取操作在超时前的最大持续时间
|
||||
|
WriteTimeout: 3600 * time.Second, //回复的写入操作在超时前的最大持续时间
|
||||
|
MaxHeaderBytes: 1 << 60, //请求的头域最大长度,如为0则用DefaultMaxHeaderBytes
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
package database |
||||
|
|
||||
|
//数据库连接结构体
|
||||
|
|
||||
|
type MasterMysqlSetUp struct { |
||||
|
UrlPath string `mapstructure:"url_path" json:"url_path" yaml:"url_path"` // 服务器地址
|
||||
|
Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口
|
||||
|
Charset string `mapstructure:"charset" json:"charset" yaml:"charset"` // 编码方式
|
||||
|
ParseTime bool `mapstructure:"parseTime" json:"parseTime" yaml:"parseTime"` // 是否自动转换时间
|
||||
|
Loc string `mapstructure:"loc" json:"loc" yaml:"loc"` // 时区
|
||||
|
Name string `mapstructure:"name" json:"name" yaml:"name"` // 数据库名称
|
||||
|
UserName string `mapstructure:"username" json:"username" yaml:"username"` // 账号
|
||||
|
PassWord string `mapstructure:"password" json:"password" yaml:"password"` // 密码
|
||||
|
MaxIdleConns int `mapstructure:"max_idle_conns" json:"max_idle_conns" yaml:"max_idle_conns"` // 最大空闲数
|
||||
|
MaxOpenConns int `mapstructure:"max_open_conns" json:"max_open_conns" yaml:"max_open_conns"` // 最大链接数
|
||||
|
GormLog bool `mapstructure:"gorm_log" json:"gorm_log" yaml:"gorm_log"` // 是否开启Gorm全局日志
|
||||
|
} |
||||
|
|
||||
|
type MysqlSetUp struct { |
||||
|
MasterMysql MasterMysqlSetUp `mapstructure:"master" json:"master" yaml:"master"` //主数据库
|
||||
|
AppPlatformDatabase MasterMysqlSetUp `mapstructure:"appPlatformDatabase" json:"appPlatformDatabase" yaml:"appPlatformDatabase"` //应用平台
|
||||
|
//其他数据库依次添加
|
||||
|
WechatMysql MasterMysqlSetUp `mapstructure:"wechat" json:"wechat" yaml:"wechat"` //微信数据库
|
||||
|
HrMysql MasterMysqlSetUp `mapstructure:"hrdatabase" json:"hrdatabase" yaml:"hrdatabase"` //HR数据库
|
||||
|
FileBookDate MasterMysqlSetUp `mapstructure:"fileBookDate" json:"fileBookDate" yaml:"fileBookDate"` //文档属性数据库
|
||||
|
ErrorSubjectDate MasterMysqlSetUp `mapstructure:"errorSubjectDate" json:"errorSubjectDate" yaml:"errorSubjectDate"` //错题库
|
||||
|
MyTestDate MasterMysqlSetUp `mapstructure:"myTestDate" json:"myTestDate" yaml:"myTestDate"` //自我测验
|
||||
|
ImageTextDate MasterMysqlSetUp `mapstructure:"imageTextDate" json:"imageTextDate" yaml:"imageTextDate"` //图文信息数据库
|
||||
|
ScoringDetailsDate MasterMysqlSetUp `mapstructure:"scoringDetailsDate" json:"scoringDetailsDate" yaml:"scoringDetailsDate"` //计分明细数据库
|
||||
|
QuestionsAnswersDate MasterMysqlSetUp `mapstructure:"questionsAnswersDate" json:"questionsAnswersDate" yaml:"questionsAnswersDate"` //趣味问答
|
||||
|
BillboardDate MasterMysqlSetUp `mapstructure:"billboardDate" json:"billboardDate" yaml:"billboardDate"` //风云榜统计数据库
|
||||
|
HealthReportDate MasterMysqlSetUp `mapstructure:"healthReportDate" json:"healthReportDate" yaml:"healthReportDate"` //健康上报数据库
|
||||
|
KpiDate MasterMysqlSetUp `mapstructure:"kpiDate" json:"kpiDate" yaml:"kpiDate"` //绩效考核数据库
|
||||
|
WechatCallBackLogDate MasterMysqlSetUp `mapstructure:"wechatCallBackLogDate" json:"wechatCallBackLogDate" yaml:"wechatCallBackLogDate"` //企业微信回调记录
|
||||
|
Managearchives MasterMysqlSetUp `mapstructure:"managearchives" json:"managearchives" yaml:"managearchives"` //管理档案
|
||||
|
SystemPermission MasterMysqlSetUp `mapstructure:"systempermission" json:"systempermission" yaml:"systempermission"` //系统权限配置数据库
|
||||
|
Storage MasterMysqlSetUp `mapstructure:"storage" json:"storage" yaml:"storage"` //仓储系统数据库
|
||||
|
ServerMaster MasterMysqlSetUp `mapstructure:"servermaster" json:"servermaster" yaml:"servermaster"` //仓储系统数据库
|
||||
|
TidbrMaster MasterMysqlSetUp `mapstructure:"tidbrmaster" json:"tidbrmaster" yaml:"tidbrmaster"` //仓储系统数据库
|
||||
|
CustomerForm MasterMysqlSetUp `mapstructure:"customerFormDatabase" json:"customerFormDatabase" yaml:"customerFormDatabase"` //自定义表单数据库
|
||||
|
FlowLogDatabase MasterMysqlSetUp `mapstructure:"flowLogDatabase" json:"flowLogDatabase" yaml:"flowLogDatabase"` //工作流记录
|
||||
|
ReviseFormData MasterMysqlSetUp `mapstructure:"reviseFormData" json:"reviseFormData" yaml:"reviseFormData"` |
||||
|
PersonalityColor MasterMysqlSetUp `mapstructure:"charactercolor" json:"charactercolor" yaml:"charactercolor"` //性格色彩
|
||||
|
HrDatabaseInside MasterMysqlSetUp `mapstructure:"hrdatabaseinside" json:"hrdatabaseinside" yaml:"hrdatabaseinside"` //内网Hr数据库
|
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
package database |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"time" |
||||
|
|
||||
|
"gorm.io/driver/mysql" |
||||
|
"gorm.io/gorm" |
||||
|
"gorm.io/gorm/logger" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-02 16:55:33 |
||||
|
@ 功能: 组装连接语句 |
||||
|
*/ |
||||
|
func (m *MasterMysqlSetUp) SqlDsn() (dsnStr string) { |
||||
|
dsnStr = fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=%v", m.UserName, m.PassWord, m.UrlPath, m.Port, m.Name, m.Charset) |
||||
|
if m.ParseTime { |
||||
|
dsnStr = fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=%v&parseTime=%v&loc=%v", m.UserName, m.PassWord, m.UrlPath, m.Port, m.Name, m.Charset, m.ParseTime, m.Loc) |
||||
|
} |
||||
|
// fmt.Printf("dsnStr:%v\n", dsnStr)
|
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-02 16:56:15 |
||||
|
@ 功能: 打开数据连接 |
||||
|
*/ |
||||
|
func (m *MasterMysqlSetUp) OpenSql() *gorm.DB { |
||||
|
sqlConfig := mysql.Config{ |
||||
|
DSN: m.SqlDsn(), // DSN
|
||||
|
DefaultStringSize: 255, // string 类型字段的默认长度
|
||||
|
DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
|
||||
|
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
|
||||
|
DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
|
||||
|
SkipInitializeWithVersion: false, // 根据版本自动配置
|
||||
|
} |
||||
|
if m.GormLog { |
||||
|
if opDb, err := gorm.Open(mysql.New(sqlConfig), &gorm.Config{ |
||||
|
Logger: logger.Default.LogMode(logger.Info), |
||||
|
}); err != nil { |
||||
|
return nil |
||||
|
} else { |
||||
|
sqlDb, _ := opDb.DB() |
||||
|
sqlDb.SetMaxIdleConns(m.MaxIdleConns) |
||||
|
sqlDb.SetMaxOpenConns(m.MaxOpenConns) |
||||
|
sqlDb.SetConnMaxLifetime(5 * time.Minute) |
||||
|
return opDb |
||||
|
} |
||||
|
} else { |
||||
|
if opDb, err := gorm.Open(mysql.New(sqlConfig)); err != nil { |
||||
|
return nil |
||||
|
} else { |
||||
|
sqlDb, _ := opDb.DB() |
||||
|
sqlDb.SetMaxIdleConns(m.MaxIdleConns) |
||||
|
sqlDb.SetMaxOpenConns(m.MaxOpenConns) |
||||
|
sqlDb.SetConnMaxLifetime(5 * time.Minute) |
||||
|
return opDb |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
package nosqlData |
||||
|
|
||||
|
var ( |
||||
|
CONSTANT_Redis RedisSetUp |
||||
|
CONSTANT_RedisCluster RedisSetUpV9 |
||||
|
) |
||||
|
|
||||
|
type RedisSetUp struct { |
||||
|
MasterRedis RedisConfitSetUp `mapstructure:"master" json:"master" yaml:"master"` //主数据库
|
||||
|
MasterRedis1 RedisConfitSetUp `mapstructure:"master1" json:"master1" yaml:"master1"` //主数据库
|
||||
|
MasterRedis2 RedisConfitSetUp `mapstructure:"master2" json:"master2" yaml:"master2"` //主数据库
|
||||
|
MasterRedis3 RedisConfitSetUp `mapstructure:"master3" json:"master3" yaml:"master3"` //主数据库
|
||||
|
MasterRedis4 RedisConfitSetUp `mapstructure:"master4" json:"master4" yaml:"master4"` //主数据库
|
||||
|
MasterRedis5 RedisConfitSetUp `mapstructure:"master5" json:"master5" yaml:"master5"` //主数据库
|
||||
|
MasterRedis6 RedisConfitSetUp `mapstructure:"master6" json:"master6" yaml:"master6"` //主数据库
|
||||
|
MasterRedis7 RedisConfitSetUp `mapstructure:"master7" json:"master7" yaml:"master7"` //主数据库
|
||||
|
MasterRedis8 RedisConfitSetUp `mapstructure:"master8" json:"master8" yaml:"master8"` //主数据库
|
||||
|
MasterRedis9 RedisConfitSetUp `mapstructure:"master9" json:"master9" yaml:"master9"` //主数据库
|
||||
|
MasterRedis10 RedisConfitSetUp `mapstructure:"master10" json:"master10" yaml:"master10"` //主数据库
|
||||
|
MasterRedis11 RedisConfitSetUp `mapstructure:"master11" json:"master11" yaml:"master11"` //主数据库
|
||||
|
MasterRedis12 RedisConfitSetUp `mapstructure:"master12" json:"master12" yaml:"master12"` //主数据库
|
||||
|
MasterRedis13 RedisConfitSetUp `mapstructure:"master13" json:"master13" yaml:"master13"` //主数据库
|
||||
|
MasterRedis14 RedisConfitSetUp `mapstructure:"master14" json:"master14" yaml:"master14"` //主数据库
|
||||
|
MasterRedis15 RedisConfitSetUp `mapstructure:"master15" json:"master15" yaml:"master15"` //主数据库
|
||||
|
RedisCluster RedisConfitSetUp `mapstructure:"redisCluster" json:"redisCluster" yaml:"redisCluster"` //内网集群
|
||||
|
} |
||||
|
|
||||
|
type RedisConfitSetUp struct { |
||||
|
UrlPath string `mapstructure:"url_path" json:"url_path" yaml:"url_path"` // 服务器地址
|
||||
|
Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口
|
||||
|
Name int `mapstructure:"name" json:"name" yaml:"name"` // 数据库名称
|
||||
|
PassWord string `mapstructure:"password" json:"password" yaml:"password"` // 密码
|
||||
|
UrlPathList []string `mapstructure:"url_path_list" json:"url_path_list"` |
||||
|
} |
||||
|
type RedisSetUpV9 struct { |
||||
|
RedisClusterV9 RedisConfitSetUp `mapstructure:"redisCluster" json:"redisCluster" yaml:"redisCluster"` //内网集群
|
||||
|
} |
||||
@ -0,0 +1,92 @@ |
|||||
|
package nosqlData |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"context" |
||||
|
"fmt" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/redis/go-redis/v9" |
||||
|
) |
||||
|
|
||||
|
func (r *RedisConfitSetUp) OpenRedis() *redis.Client { |
||||
|
address := fmt.Sprintf("%v:%v", r.UrlPath, r.Port) |
||||
|
fmt.Printf("开启%v Redis库 %v\n", address, r.Name) |
||||
|
redisClient := redis.NewClient(&redis.Options{ |
||||
|
Addr: address, |
||||
|
Password: r.PassWord, |
||||
|
DB: r.Name, |
||||
|
PoolSize: GetMaxLine(), |
||||
|
MinIdleConns: appConstant.Constant_Config.RedisPrefixStr.MinIdleConns, |
||||
|
DialTimeout: DialTimeout(), |
||||
|
}) |
||||
|
pingLink, err := redisClient.Ping(context.Background()).Result() |
||||
|
if err != nil { |
||||
|
fmt.Printf("%v Redis链接失败!原因:%v\n", r.Name, err) |
||||
|
} else { |
||||
|
fmt.Printf("%v Redis链接成功!==%v===>%v\n", r.Name, r.UrlPath, pingLink) |
||||
|
} |
||||
|
return redisClient |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 11:33:39 |
||||
|
@ 功能: 获取最大连接池数量 |
||||
|
*/ |
||||
|
func GetMaxLine() int { |
||||
|
|
||||
|
if appConstant.Constant_Config.RedisPrefixStr.PoolSize == 0 { |
||||
|
return appConstant.MaxCpuNumber * 4 |
||||
|
} |
||||
|
return appConstant.Constant_Config.RedisPrefixStr.PoolSize |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 13:06:22 |
||||
|
@ 功能: 计算超时时间 |
||||
|
*/ |
||||
|
func DialTimeout() time.Duration { |
||||
|
return time.Duration(appConstant.Constant_Config.RedisPrefixStr.DialTimeout) * time.Second |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2023-12-13 10:12:38 |
||||
|
@ 功能: 链接redis集群 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (r *RedisConfitSetUp) OpenRedisColony() *redis.ClusterClient { |
||||
|
fmt.Printf("开启%v Redis集群库 %v\n", r.UrlPathList, r.Name) |
||||
|
redisClient := redis.NewClusterClient(&redis.ClusterOptions{ |
||||
|
Addrs: r.UrlPathList, |
||||
|
Password: r.PassWord, |
||||
|
RouteRandomly: true, |
||||
|
// DB: r.Name,
|
||||
|
PoolSize: GetMaxLine(), |
||||
|
MinIdleConns: appConstant.Constant_Config.RedisPrefixStr.MinIdleConns, |
||||
|
DialTimeout: DialTimeout(), |
||||
|
}) |
||||
|
|
||||
|
pingLink, err := redisClient.Ping(context.Background()).Result() |
||||
|
if err != nil { |
||||
|
fmt.Printf("%v Redis集群链接失败!原因:%v\n", r.Name, err) |
||||
|
} else { |
||||
|
fmt.Printf("%v Redis集群链接成功!==%v===>%v\n", r.Name, r.UrlPathList, pingLink) |
||||
|
} |
||||
|
return redisClient |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
#App主配置 |
||||
|
appsetup: |
||||
|
port: 18888 #服务端口 |
||||
|
readtime: 3600 #请求的读取操作在超时前的最大持续时间 |
||||
|
writetime : 3600 #回复的写入操作在超时前的最大持续时间 |
||||
|
appkey: 'application_platform_qin_dong' #应用程序密钥 |
||||
|
password: '666666' #系统默认密码 |
||||
|
prefix: 'App' #系统字段前缀 |
||||
|
weburl: 'http://web.xxx.com' #web访问地址 |
||||
|
pcurl: 'http://www.xxx.com' #PC访问地址 |
||||
|
#日志配置 |
||||
|
logconfig: |
||||
|
path: 'log' #日志保存地址 |
||||
|
#验证码相关设置 |
||||
|
captcha: |
||||
|
key-long: 6 |
||||
|
img-width: 240 |
||||
|
img-height: 80 |
||||
|
|
||||
|
#Redis前缀 |
||||
|
redisprefix: |
||||
|
prefix: "HXGK_GO_ZhixingCollege" |
||||
|
alias: "dev" |
||||
|
activateCluster: false |
||||
|
poolSize: 0 # 连接池最大socket连接数,默认为4倍CPU数, 4 * runtime.NumCPU |
||||
|
minIdleConns: 17 #在启动阶段创建指定数量的Idle连接,并长期维持idle状态的连接数不少于指定数量;。 |
||||
|
dialTimeout: 5 #连接建立超时时间,默认5秒。 |
||||
|
|
||||
|
#企业微信相关配置 |
||||
|
wechatcompany: |
||||
|
companyid: 'xxxxxxxxxxx' #企业ID |
||||
@ -0,0 +1,15 @@ |
|||||
|
#数据库配置 |
||||
|
|
||||
|
#主数据库 |
||||
|
master: |
||||
|
url_path: '127.0.0.1' #数据库地址 |
||||
|
port: 3306 #数据库端口 |
||||
|
name: 'app_database' #数据库名称 |
||||
|
username: 'root' #数据库用户民 |
||||
|
password: 'root' #数据库密码 |
||||
|
charset: 'utf8mb4' #数据库编码方式 |
||||
|
parseTime: 'True' #是否自动转换时间 |
||||
|
loc: 'Local' #时区 |
||||
|
max_idle_conns: 100 #最大空闲数量 |
||||
|
max_open_conns: 1500 #最大打开数量 |
||||
|
gorm_log: true #是否开启gorm日志 |
||||
@ -0,0 +1,99 @@ |
|||||
|
#Redis配置文件 |
||||
|
master: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口 |
||||
|
password: "" |
||||
|
name: 0 |
||||
|
|
||||
|
#Redis配置文件 |
||||
|
master1: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口 |
||||
|
password: "" |
||||
|
name: 1 |
||||
|
|
||||
|
#Redis配置文件 |
||||
|
master2: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口 |
||||
|
password: "" |
||||
|
name: 2 |
||||
|
|
||||
|
#Redis配置文件 |
||||
|
master3: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口 |
||||
|
password: "" |
||||
|
name: 3 |
||||
|
|
||||
|
#Redis配置文件 |
||||
|
master4: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口 |
||||
|
password: "" |
||||
|
name: 4 |
||||
|
|
||||
|
#Redis配置文件 |
||||
|
master5: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 5 |
||||
|
master6: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 6 |
||||
|
master7: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 7 |
||||
|
master8: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 8 |
||||
|
master9: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 9 |
||||
|
master10: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 10 |
||||
|
master11: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 11 |
||||
|
master12: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 12 |
||||
|
master13: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 13 |
||||
|
master14: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 14 |
||||
|
master15: |
||||
|
url_path: '127.0.0.1' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "" |
||||
|
name: 15 |
||||
|
#Redis配置文件 |
||||
|
redisCluster: |
||||
|
url_path: '120.224.6.6' |
||||
|
port: 6379 #数据库端口11 |
||||
|
password: "Redis+brngJ3U19@8_Z2^7a" |
||||
|
name: 0 |
||||
|
# url_path_list: ['172.20.5.34:6379','172.20.5.30:6379','172.20.5.31:6379'] |
||||
|
url_path_list: ['120.224.6.6:6379','120.224.6.6:6380','120.224.6.6:6381'] |
||||
@ -0,0 +1,38 @@ |
|||||
|
package common |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/generalmethod" |
||||
|
"appNewPlatform/utils" |
||||
|
"appNewPlatform/utils/formatoutput" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 13:57:49 |
||||
|
@ 功能: 实验函数 |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func (a *ApiMethod) Index(c *gin.Context) { |
||||
|
sendMap := generalmethod.MapOut[string]() |
||||
|
token, _ := utils.ReleaseToken("300450") |
||||
|
sendMap["token"] = token |
||||
|
sendMap["tokenStr"], sendMap["claims"], sendMap["err"] = utils.ParseToken(token) |
||||
|
formatoutput.Result(0, sendMap, c) |
||||
|
} |
||||
|
|
||||
|
func (a *ApiMethod) JieXiJwt(c *gin.Context) { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
package common |
||||
|
|
||||
|
type ApiMethod struct{} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package controller |
||||
|
|
||||
|
import "appNewPlatform/controller/common" |
||||
|
|
||||
|
type ApiEmpty struct { |
||||
|
CommonApi common.ApiMethod |
||||
|
} |
||||
|
|
||||
|
var ApiInlet = new(ApiEmpty) |
||||
@ -0,0 +1,34 @@ |
|||||
|
package generalmethod |
||||
|
|
||||
|
import ( |
||||
|
"bytes" |
||||
|
"io/ioutil" |
||||
|
"net/http" |
||||
|
) |
||||
|
|
||||
|
// Get请求
|
||||
|
func CurlGet(getUrl string) []byte { |
||||
|
client := &http.Client{} |
||||
|
reqest, err := http.NewRequest("GET", getUrl, nil) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
response, _ := client.Do(reqest) |
||||
|
defer response.Body.Close() |
||||
|
body, err := ioutil.ReadAll(response.Body) |
||||
|
return body |
||||
|
} |
||||
|
|
||||
|
// Post请求 json
|
||||
|
func CurlPostJosn(postUrl string, jsonData []byte) []byte { |
||||
|
req, err := http.NewRequest("POST", postUrl, bytes.NewBuffer(jsonData)) |
||||
|
req.Header.Set("Content-Type", "application/json;charset=utf-8") |
||||
|
client := &http.Client{} |
||||
|
resp, err := client.Do(req) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
defer resp.Body.Close() |
||||
|
body, _ := ioutil.ReadAll(resp.Body) |
||||
|
return body |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package generalmethod |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/utils/snowflake" |
||||
|
"crypto/rand" |
||||
|
"fmt" |
||||
|
"math/big" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
// 初始化map(泛型)
|
||||
|
func MapOut[T GenericityVariable]() (data map[T]interface{}) { |
||||
|
data = make(map[T]interface{}) //必可不少,分配内存
|
||||
|
return data |
||||
|
} |
||||
|
|
||||
|
// 编号,纯数字
|
||||
|
func TableNumber(class ...string) (number int64) { |
||||
|
result, _ := rand.Int(rand.Reader, big.NewInt(8999)) |
||||
|
numberTeam := result.Int64() + 1000 |
||||
|
numberStr := fmt.Sprintf("%v%v", time.Now().Unix(), numberTeam) |
||||
|
if len(class) > 0 { |
||||
|
resultLong, _ := rand.Int(rand.Reader, big.NewInt(8999999)) |
||||
|
numberTeamLong := resultLong.Int64() + 1000000 |
||||
|
numberStr = fmt.Sprintf("%v%v", time.Now().Unix(), numberTeamLong) |
||||
|
} |
||||
|
number, _ = strconv.ParseInt(numberStr, 10, 64) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 获取UUID
|
||||
|
func GetUUid(workId int64) (uuId int64) { |
||||
|
snowflakeId, snowflakeErr := snowflake.NewWorker(workId) |
||||
|
if snowflakeErr != nil { |
||||
|
uuId = TableNumber() |
||||
|
} else { |
||||
|
uuId = snowflakeId.GetId() |
||||
|
} |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package generalmethod |
||||
|
|
||||
|
// 泛型基础变量类型
|
||||
|
type GenericityVariable interface { |
||||
|
int | int8 | int16 | int32 | int64 | float32 | float64 | string |
||||
|
} |
||||
|
type CommonId[T GenericityVariable] struct { |
||||
|
Id T `json:"id"` |
||||
|
} |
||||
|
|
||||
|
// 翻页信息
|
||||
|
type PagesTurn struct { |
||||
|
Page int `json:"page"` |
||||
|
PageSize int `json:"pagesize"` |
||||
|
} |
||||
@ -0,0 +1,67 @@ |
|||||
|
module appNewPlatform |
||||
|
|
||||
|
go 1.21.5 |
||||
|
|
||||
|
require ( |
||||
|
github.com/fsnotify/fsnotify v1.7.0 |
||||
|
github.com/gin-gonic/gin v1.10.0 |
||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible |
||||
|
github.com/golang-jwt/jwt/v5 v5.2.1 |
||||
|
github.com/redis/go-redis/v9 v9.6.1 |
||||
|
github.com/spf13/viper v1.19.0 |
||||
|
gorm.io/driver/mysql v1.5.7 |
||||
|
gorm.io/gorm v1.25.12 |
||||
|
) |
||||
|
|
||||
|
require ( |
||||
|
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect |
||||
|
github.com/bytedance/sonic v1.11.6 // indirect |
||||
|
github.com/bytedance/sonic/loader v0.1.1 // indirect |
||||
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect |
||||
|
github.com/cloudwego/base64x v0.1.4 // indirect |
||||
|
github.com/cloudwego/iasm v0.2.0 // indirect |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect |
||||
|
github.com/disintegration/imaging v1.6.2 // indirect |
||||
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect |
||||
|
github.com/gin-contrib/sse v0.1.0 // indirect |
||||
|
github.com/go-playground/locales v0.14.1 // indirect |
||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect |
||||
|
github.com/go-playground/validator/v10 v10.20.0 // indirect |
||||
|
github.com/go-sql-driver/mysql v1.7.0 // indirect |
||||
|
github.com/goccy/go-json v0.10.2 // indirect |
||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect |
||||
|
github.com/hashicorp/hcl v1.0.0 // indirect |
||||
|
github.com/jinzhu/inflection v1.0.0 // indirect |
||||
|
github.com/jinzhu/now v1.1.5 // indirect |
||||
|
github.com/json-iterator/go v1.1.12 // indirect |
||||
|
github.com/klauspost/cpuid/v2 v2.2.7 // indirect |
||||
|
github.com/leodido/go-urn v1.4.0 // indirect |
||||
|
github.com/llgcode/draw2d v0.0.0-20240627062922-0ed1ff131195 // indirect |
||||
|
github.com/magiconair/properties v1.8.7 // indirect |
||||
|
github.com/mattn/go-isatty v0.0.20 // indirect |
||||
|
github.com/mitchellh/mapstructure v1.5.0 // indirect |
||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect |
||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect |
||||
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect |
||||
|
github.com/sagikazarmark/locafero v0.4.0 // indirect |
||||
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect |
||||
|
github.com/sourcegraph/conc v0.3.0 // indirect |
||||
|
github.com/spf13/afero v1.11.0 // indirect |
||||
|
github.com/spf13/cast v1.6.0 // indirect |
||||
|
github.com/spf13/pflag v1.0.5 // indirect |
||||
|
github.com/subosito/gotenv v1.6.0 // indirect |
||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect |
||||
|
github.com/ugorji/go/codec v1.2.12 // indirect |
||||
|
go.uber.org/atomic v1.9.0 // indirect |
||||
|
go.uber.org/multierr v1.9.0 // indirect |
||||
|
golang.org/x/arch v0.8.0 // indirect |
||||
|
golang.org/x/crypto v0.23.0 // indirect |
||||
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect |
||||
|
golang.org/x/image v0.22.0 // indirect |
||||
|
golang.org/x/net v0.25.0 // indirect |
||||
|
golang.org/x/sys v0.20.0 // indirect |
||||
|
golang.org/x/text v0.20.0 // indirect |
||||
|
google.golang.org/protobuf v1.34.1 // indirect |
||||
|
gopkg.in/ini.v1 v1.67.0 // indirect |
||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect |
||||
|
) |
||||
@ -0,0 +1,199 @@ |
|||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= |
||||
|
github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= |
||||
|
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= |
||||
|
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= |
||||
|
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= |
||||
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= |
||||
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= |
||||
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= |
||||
|
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= |
||||
|
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= |
||||
|
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= |
||||
|
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= |
||||
|
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= |
||||
|
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/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= |
||||
|
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= |
||||
|
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= |
||||
|
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= |
||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= |
||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= |
||||
|
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= |
||||
|
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= |
||||
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= |
||||
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= |
||||
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= |
||||
|
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= |
||||
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= |
||||
|
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= |
||||
|
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-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= |
||||
|
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= |
||||
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= |
||||
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= |
||||
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= |
||||
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= |
||||
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= |
||||
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= |
||||
|
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= |
||||
|
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= |
||||
|
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= |
||||
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
||||
|
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= |
||||
|
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= |
||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= |
||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= |
||||
|
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= |
||||
|
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= |
||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= |
||||
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= |
||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= |
||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
||||
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= |
||||
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= |
||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= |
||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= |
||||
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= |
||||
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
||||
|
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/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= |
||||
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= |
||||
|
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= |
||||
|
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= |
||||
|
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= |
||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= |
||||
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= |
||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= |
||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= |
||||
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= |
||||
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= |
||||
|
github.com/llgcode/draw2d v0.0.0-20240627062922-0ed1ff131195 h1:Vdz2cBh5Fw2MYHWi3ED2PraDQaWEUhNCr1XFHrP4N5A= |
||||
|
github.com/llgcode/draw2d v0.0.0-20240627062922-0ed1ff131195/go.mod h1:1Vk0LDW6jG5cGc2D9RQUxHaE0vYhTvIwSo9mOL6K4/U= |
||||
|
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= |
||||
|
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= |
||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
||||
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= |
||||
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= |
||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= |
||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
||||
|
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/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= |
||||
|
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= |
||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= |
||||
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
|
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= |
||||
|
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA= |
||||
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= |
||||
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= |
||||
|
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= |
||||
|
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= |
||||
|
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= |
||||
|
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= |
||||
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= |
||||
|
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= |
||||
|
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= |
||||
|
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= |
||||
|
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= |
||||
|
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= |
||||
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= |
||||
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= |
||||
|
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= |
||||
|
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= |
||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= |
||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= |
||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= |
||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= |
||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= |
||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= |
||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= |
||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= |
||||
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= |
||||
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= |
||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= |
||||
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= |
||||
|
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= |
||||
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= |
||||
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
||||
|
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= |
||||
|
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= |
||||
|
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= |
||||
|
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= |
||||
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= |
||||
|
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= |
||||
|
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= |
||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= |
||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= |
||||
|
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= |
||||
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= |
||||
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= |
||||
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= |
||||
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= |
||||
|
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= |
||||
|
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= |
||||
|
golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g= |
||||
|
golang.org/x/image v0.22.0/go.mod h1:9hPFhljd4zZ1GNSIZJ49sqbp45GKK9t6w+iXvGqZUz4= |
||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
||||
|
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-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
||||
|
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= |
||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= |
||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
|
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-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= |
||||
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
||||
|
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= |
||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= |
||||
|
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= |
||||
|
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= |
||||
|
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= |
||||
|
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= |
||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |
||||
|
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= |
||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
|
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= |
||||
|
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= |
||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= |
||||
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
|
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= |
||||
|
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= |
||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
||||
|
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= |
||||
|
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= |
||||
|
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= |
||||
|
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= |
||||
|
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= |
||||
|
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= |
||||
|
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= |
||||
|
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= |
||||
@ -0,0 +1,20 @@ |
|||||
|
package initialization |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"appNewPlatform/config/app" |
||||
|
"fmt" |
||||
|
) |
||||
|
|
||||
|
// 启动服务
|
||||
|
func RunItem() { |
||||
|
//加载基础配置
|
||||
|
RunViper(&appConstant.Constant_Config, appConstant.AppConfigPath) |
||||
|
routers := InitializeRouter() |
||||
|
portStr := fmt.Sprintf(":%d", appConstant.Constant_Config.Appsetup.Port) |
||||
|
startUp := app.InitServer(portStr, routers) |
||||
|
fmt.Printf("\n\n默认API运行地址:http://127.0.0.1%s\n", portStr) |
||||
|
err := startUp.ListenAndServe().Error() |
||||
|
fmt.Printf("\n\n%s\n", err) |
||||
|
panic(fmt.Errorf(err)) |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
package initialization |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"fmt" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 08:57:09 |
||||
|
@ 功能: 加载数据库 |
||||
|
*/ |
||||
|
func LoadingDatabase() { |
||||
|
sqlConfig := appConstant.CONSTANT_MYSQL |
||||
|
RunViper(&sqlConfig, appConstant.ConfigDatabaseConstant) |
||||
|
//开启主数据库
|
||||
|
appConstant.CONSTANT_DB_Master = sqlConfig.MasterMysql.OpenSql() |
||||
|
if appConstant.CONSTANT_DB_Master == nil { |
||||
|
fmt.Printf("%v:数据库开启失败!\n", sqlConfig.MasterMysql.Name) |
||||
|
} else { |
||||
|
fmt.Printf("%v:数据库开启成功!\n", sqlConfig.MasterMysql.Name) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package initialization |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"appNewPlatform/config/nosqlData" |
||||
|
) |
||||
|
|
||||
|
// 加载Redis
|
||||
|
func LoadRedis() { |
||||
|
//读取Redis配置
|
||||
|
redisConfig := nosqlData.CONSTANT_Redis |
||||
|
RunViper(&redisConfig, appConstant.ConfigRedisConstant) |
||||
|
appConstant.CONSTANT_REDIS0 = redisConfig.MasterRedis.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS1 = redisConfig.MasterRedis1.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS2 = redisConfig.MasterRedis2.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS3 = redisConfig.MasterRedis3.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS4 = redisConfig.MasterRedis4.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS5 = redisConfig.MasterRedis5.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS6 = redisConfig.MasterRedis6.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS7 = redisConfig.MasterRedis7.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS8 = redisConfig.MasterRedis8.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS9 = redisConfig.MasterRedis9.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS10 = redisConfig.MasterRedis10.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS11 = redisConfig.MasterRedis11.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS12 = redisConfig.MasterRedis12.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS13 = redisConfig.MasterRedis13.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS14 = redisConfig.MasterRedis14.OpenRedis() |
||||
|
appConstant.CONSTANT_REDIS15 = redisConfig.MasterRedis15.OpenRedis() |
||||
|
appConstant.CONSTANT_ClusterClient = redisConfig.RedisCluster.OpenRedisColony() |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
package initialization |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/routers" |
||||
|
"io/ioutil" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 10:25:27 |
||||
|
@ 功能: 初始化路由 |
||||
|
*/ |
||||
|
|
||||
|
func InitializeRouter() *gin.Engine { |
||||
|
gin.SetMode(gin.ReleaseMode) |
||||
|
gin.DefaultWriter = ioutil.Discard |
||||
|
var router = gin.Default() |
||||
|
//app默认响应
|
||||
|
appLoadRouterGroup := router.Group("") |
||||
|
{ |
||||
|
// 跨域设置
|
||||
|
// router.Use(middleware.CrossDomainRequest()) // 如需跨域可以打开
|
||||
|
appLoadRouterGroup.GET("/", func(c *gin.Context) { |
||||
|
c.JSON(0, "通讯成功!") |
||||
|
}) |
||||
|
appLoadRouterGroup.POST("/", func(c *gin.Context) { |
||||
|
c.JSON(0, "通讯成功!") |
||||
|
}) |
||||
|
appLoadRouterGroup.PUT("/", func(c *gin.Context) { |
||||
|
c.JSON(0, "通讯成功!") |
||||
|
}) |
||||
|
|
||||
|
shiyanApiRouters := routers.RouterGroupEntry.AppShiyanRouter |
||||
|
{ |
||||
|
shiyanApiRouters.RouterGroup(appLoadRouterGroup) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
return router |
||||
|
} |
||||
@ -0,0 +1,61 @@ |
|||||
|
package initialization |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"fmt" |
||||
|
|
||||
|
"github.com/fsnotify/fsnotify" |
||||
|
"github.com/spf13/viper" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 09:10:48 |
||||
|
@ 功能: 使用viper读取配置文件 |
||||
|
*/ |
||||
|
func RunViper(configInfo interface{}, path ...string) *viper.Viper { |
||||
|
// fmt.Printf("你正在使用系统默认值。11111配置路径为:%v\n", path)
|
||||
|
var config string |
||||
|
if len(path) == 0 { |
||||
|
config = appConstant.AppConfigPath |
||||
|
fmt.Printf("你正在使用系统默认值。配置路径为:%v\n", config) |
||||
|
} else { |
||||
|
config = path[0] |
||||
|
fmt.Printf("你正在使用RunViper传值。配置路径为:%v\n", config) |
||||
|
} |
||||
|
v := viper.New() |
||||
|
// 设置配置文件信息
|
||||
|
v.SetConfigFile(config) |
||||
|
v.SetConfigType("yaml") |
||||
|
//读取配置信息
|
||||
|
err := v.ReadInConfig() |
||||
|
if err != nil { |
||||
|
panic(fmt.Errorf("配置文件读取失败?原因:%s\n", err)) |
||||
|
} |
||||
|
// 监控配置和重新获取配置
|
||||
|
v.WatchConfig() |
||||
|
|
||||
|
v.OnConfigChange(func(e fsnotify.Event) { |
||||
|
fmt.Printf("配置文件已经更改:%v\n", e.Name) |
||||
|
if errSet := v.Unmarshal(&configInfo); errSet != nil { |
||||
|
fmt.Printf("新配置文件解析失败!系统继续使用原配置!失败原因:%s\n", errSet) |
||||
|
} else { |
||||
|
// LoadDatabase()
|
||||
|
if e.Name == "config\\configDatabase\\database.yaml" { |
||||
|
LoadingDatabase() |
||||
|
} |
||||
|
if e.Name == "config\\configNosql\\redis.yaml" { |
||||
|
LoadRedis() |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
//解析配置映射到切片
|
||||
|
if errStruct := v.Unmarshal(&configInfo); errStruct != nil { |
||||
|
fmt.Printf("配置解析失败!原因:%s\n", errStruct) |
||||
|
} |
||||
|
// json.Marshal(configInfo)
|
||||
|
// cfi, _ := json.Marshal(configInfo)
|
||||
|
// fmt.Printf("============>%v\n", string(cfi))
|
||||
|
return v |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"appNewPlatform/initialization" |
||||
|
"fmt" |
||||
|
"runtime" |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
var Ncpu = runtime.NumCPU() |
||||
|
fmt.Printf("服务器核心数量:%v\n", Ncpu) |
||||
|
if Ncpu-1 <= 0 { |
||||
|
Ncpu = 1 |
||||
|
} else { |
||||
|
Ncpu = Ncpu - 1 |
||||
|
} |
||||
|
appConstant.MaxCpuNumber = Ncpu |
||||
|
fmt.Printf("设置并发服务器核心数量:%v\n", Ncpu) |
||||
|
runtime.GOMAXPROCS(Ncpu) //设置使用核心数量
|
||||
|
//加载数据库
|
||||
|
initialization.LoadingDatabase() |
||||
|
//加载Redis
|
||||
|
initialization.LoadRedis() |
||||
|
//启动App
|
||||
|
initialization.RunItem() |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
package appShiyan |
||||
|
|
||||
|
//路由
|
||||
|
type ApiRouter struct{} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package appShiyan |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/controller" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 路由
|
||||
|
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
||||
|
apiRouter := router.Group("shiyan") |
||||
|
var methodBinding = controller.ApiInlet.CommonApi |
||||
|
{ |
||||
|
apiRouter.GET("", methodBinding.Index) //入口
|
||||
|
apiRouter.POST("", methodBinding.Index) //入口
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package routers |
||||
|
|
||||
|
import "appNewPlatform/routers/appShiyan" |
||||
|
|
||||
|
type RouterGroup struct { |
||||
|
AppShiyanRouter appShiyan.ApiRouter |
||||
|
} |
||||
|
|
||||
|
var RouterGroupEntry = new(RouterGroup) |
||||
@ -0,0 +1,16 @@ |
|||||
|
package formatoutput |
||||
|
|
||||
|
var ErrorCodeMsg = map[int]string{ |
||||
|
0: "成功", |
||||
|
1: "", |
||||
|
100: "提交的数据格式错误!", |
||||
|
101: "提交的数据不能为空!", |
||||
|
102: "关键参数不能为空!", |
||||
|
103: "该数据已经存在!请不要重复添加", |
||||
|
104: "数据写入失败!", |
||||
|
105: "数据查询失败!", |
||||
|
106: "编辑失败!", |
||||
|
107: "未能查询到数据!", |
||||
|
108: "删除失败", |
||||
|
2000: "账户或密码错误!", |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
package formatoutput |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/generalmethod" |
||||
|
"fmt" |
||||
|
"net/http" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// 格式化输出
|
||||
|
func Result(code int, data interface{}, c *gin.Context, msgAry ...string) { |
||||
|
var msg string |
||||
|
if _, isTrue := ErrorCodeMsg[code]; isTrue { |
||||
|
msg = ErrorCodeMsg[code] |
||||
|
} |
||||
|
if len(msgAry) > 0 { |
||||
|
for _, v := range msgAry { |
||||
|
if msg == "" { |
||||
|
msg = fmt.Sprintf("%v", v) |
||||
|
} else { |
||||
|
msg = fmt.Sprintf("%v。%v", msg, v) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据
|
||||
|
} |
||||
|
|
||||
|
// 格式化输出
|
||||
|
func ResultInterface(data interface{}, c *gin.Context) { |
||||
|
c.JSON(http.StatusOK, data) //输出json格式数据
|
||||
|
} |
||||
|
|
||||
|
//列表输出标准格式
|
||||
|
/* |
||||
|
@total 总数 |
||||
|
@count 当前页总数 |
||||
|
@page 页数 |
||||
|
@pageSize 每页显示数量 |
||||
|
@data 返回数据 |
||||
|
*/ |
||||
|
func ResultList(code, page, pageSize int, total, count int64, data interface{}, c *gin.Context) (printMap map[string]interface{}) { |
||||
|
outMap := generalmethod.MapOut[string]() |
||||
|
outMap["count"] = count |
||||
|
outMap["total"] = total |
||||
|
outMap["page"] = page |
||||
|
outMap["pagesize"] = pageSize |
||||
|
outMap["list"] = data |
||||
|
printMap = outMap |
||||
|
Result(code, outMap, c) |
||||
|
return |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
package formatoutput |
||||
|
|
||||
|
type Reply struct { |
||||
|
Code int `json:"code"` |
||||
|
Msg string `json:"msg"` |
||||
|
Data interface{} `json:"data"` |
||||
|
} |
||||
@ -0,0 +1,75 @@ |
|||||
|
package utils |
||||
|
|
||||
|
import ( |
||||
|
"appNewPlatform/appConstant" |
||||
|
"appNewPlatform/generalmethod" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/golang-jwt/jwt" |
||||
|
) |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 13:36:08 |
||||
|
@ 功能: 获取Token |
||||
|
@ 参数 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func ReleaseToken(userKey string) (token string, err error) { |
||||
|
expirationTime := time.Now().Add(7 * 24 * time.Hour) //过期时间
|
||||
|
claims := &Claims{ |
||||
|
UserId: userKey, |
||||
|
UUID: strconv.FormatInt(generalmethod.GetUUid(2), 10), |
||||
|
StandardClaims: jwt.StandardClaims{ |
||||
|
ExpiresAt: expirationTime.Unix(), |
||||
|
IssuedAt: time.Now().Unix(), //token发放的时间
|
||||
|
Issuer: "admin", //发放人
|
||||
|
Subject: "AppJwtToken", //主题
|
||||
|
}, |
||||
|
} |
||||
|
// fmt.Printf("tokenJwt:%v--->%v\n", jwt.SigningMethodHS256, err)
|
||||
|
tokenJwt := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) |
||||
|
// fmt.Printf("tokenJwt:%v--->%v\n", tokenJwt, err)
|
||||
|
token, err = tokenJwt.SignedString([]byte(appConstant.Constant_Config.Appsetup.AppKey)) |
||||
|
// fmt.Printf("tokenJwt:%v--->%v\n", appConstant.Constant_Config.Appsetup.AppKey, err)
|
||||
|
if err != nil { |
||||
|
return "", err |
||||
|
} |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2024-10-03 14:41:32 |
||||
|
@ 功能: 解析Jwt信息 |
||||
|
@ 参数 |
||||
|
|
||||
|
#tokenString token字符串 |
||||
|
|
||||
|
@ 返回值 |
||||
|
|
||||
|
# |
||||
|
|
||||
|
@ 方法原型 |
||||
|
|
||||
|
# |
||||
|
*/ |
||||
|
func ParseToken(tokenString string) (*jwt.Token, *Claims, error) { |
||||
|
claims := &Claims{} |
||||
|
token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) { |
||||
|
return []byte(appConstant.Constant_Config.Appsetup.AppKey), nil |
||||
|
}) |
||||
|
return token, claims, err |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
package snowflake |
||||
|
|
||||
|
import ( |
||||
|
"errors" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
//雪花算法
|
||||
|
func NewWorker(workerId int64) (*Worker, error) { |
||||
|
if workerId < 0 || workerId > workerMax { |
||||
|
return nil, errors.New("工作机器的ID超出范围!") |
||||
|
} |
||||
|
// 生成一个新节点
|
||||
|
return &Worker{ |
||||
|
timestamp: 0, |
||||
|
workerId: workerId, |
||||
|
number: 0, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
func (w *Worker) GetId() int64 { |
||||
|
w.mu.Lock() |
||||
|
defer w.mu.Unlock() |
||||
|
now := time.Now().UnixNano() / 1e6 |
||||
|
if w.timestamp == now { |
||||
|
w.number++ |
||||
|
if w.number > numberMax { |
||||
|
for now <= w.timestamp { |
||||
|
now = time.Now().UnixNano() / 1e6 |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
w.number = 0 |
||||
|
w.timestamp = now |
||||
|
} |
||||
|
ID := int64((now-startTime)<<timeShift | (w.workerId << workerShift) | (w.number)) |
||||
|
return ID |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package snowflake |
||||
|
|
||||
|
import "sync" |
||||
|
|
||||
|
//雪花算法
|
||||
|
const ( |
||||
|
workerBits uint8 = 10 |
||||
|
numberBits uint8 = 12 |
||||
|
workerMax int64 = -1 ^ (-1 << workerBits) |
||||
|
numberMax int64 = -1 ^ (-1 << numberBits) |
||||
|
timeShift uint8 = workerBits + numberBits |
||||
|
workerShift uint8 = numberBits |
||||
|
startTime int64 = 1655827200000 // 如果在程序跑了一段时间修改了epoch这个值 可能会导致生成相同的ID
|
||||
|
) |
||||
|
|
||||
|
type Worker struct { |
||||
|
mu sync.Mutex |
||||
|
timestamp int64 |
||||
|
workerId int64 |
||||
|
number int64 |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package utils |
||||
|
|
||||
|
import "github.com/golang-jwt/jwt" |
||||
|
|
||||
|
type Claims struct { |
||||
|
UserId string |
||||
|
UUID string |
||||
|
jwt.StandardClaims |
||||
|
} |
||||
Loading…
Reference in new issue