Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xpkg
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
屠思豪
xpkg
Commits
76b710b4
提交
76b710b4
authored
9月 10, 2025
作者:
mooncake9527
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
4970d53d
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
63 行增加
和
40 行删除
+63
-40
config.go
config/config.go
+9
-9
enums.go
gin/enums/enums.go
+10
-1
global.go
global/global.go
+1
-1
httpcli.go
httpcli/httpcli.go
+3
-0
init.go
init.go
+36
-27
mysql.go
sgorm/mysql/mysql.go
+3
-1
oss.go
third/oss/oss.go
+1
-1
没有找到文件。
config/config.go
浏览文件 @
76b710b4
...
...
@@ -6,7 +6,7 @@ import (
"time"
"github.com/jinzhu/copier"
alioss
"gitlab.wanzhuangkj.com/tush/xpkg/third/
ali
oss"
alioss
"gitlab.wanzhuangkj.com/tush/xpkg/third/oss"
)
var
Cfg
=
&
Config
{
...
...
@@ -61,13 +61,13 @@ func CronOpen() bool {
func
GetOssConfig
()
*
alioss
.
AliOssConfig
{
ossCfg
:=
&
alioss
.
AliOssConfig
{}
Read
(
func
(
c
*
Config
)
{
ossCfg
.
Endpoint
=
c
.
Ali
Oss
.
Endpoint
ossCfg
.
AccessKeyId
=
c
.
Ali
Oss
.
AccessKeyId
ossCfg
.
AccessKeySecret
=
c
.
Ali
Oss
.
AccessKeySecret
ossCfg
.
BucketName
=
c
.
Ali
Oss
.
BucketName
ossCfg
.
BasePath
=
c
.
Ali
Oss
.
BasePath
ossCfg
.
BucketUrl
=
c
.
Ali
Oss
.
BucketUrl
ossCfg
.
Region
=
c
.
Ali
Oss
.
Region
ossCfg
.
Endpoint
=
c
.
Oss
.
Endpoint
ossCfg
.
AccessKeyId
=
c
.
Oss
.
AccessKeyId
ossCfg
.
AccessKeySecret
=
c
.
Oss
.
AccessKeySecret
ossCfg
.
BucketName
=
c
.
Oss
.
BucketName
ossCfg
.
BasePath
=
c
.
Oss
.
BasePath
ossCfg
.
BucketUrl
=
c
.
Oss
.
BucketUrl
ossCfg
.
Region
=
c
.
Oss
.
Region
})
return
ossCfg
}
...
...
@@ -114,7 +114,7 @@ type Config struct {
CronJobs
Cron
`yaml:"cron" json:"cron"`
Leaf
Leaf
`yaml:"leaf" json:"leaf"`
NacosConfClient
*
NacosClient
`yaml:"-" json:"-"`
AliOss
alioss
.
AliOssConfig
`yaml:"oss" json:"oss"`
Oss
alioss
.
AliOssConfig
`yaml:"oss" json:"oss"`
Content
[]
byte
`yaml:"-" json:"-"`
}
...
...
gin/enums/enums.go
浏览文件 @
76b710b4
...
...
@@ -27,11 +27,20 @@ func HandleDict(c *gin.Context) {
response
.
Success
(
c
,
dict
)
}
func
HandleDictWithDict
(
c
*
gin
.
Context
,
d
*
EnumDictionary
)
{
response
.
Success
(
c
,
d
)
}
func
HandleDictOptions
(
c
*
gin
.
Context
)
{
ret
,
_
:=
convertMap
(
dict
)
response
.
Success
(
c
,
ret
)
}
func
HandleDictOptionsWithDict
(
c
*
gin
.
Context
,
d
*
EnumDictionary
)
{
ret
,
_
:=
convertMap
(
d
)
response
.
Success
(
c
,
ret
)
}
type
BaseReply
struct
{
Code
int
`json:"code" form:"code" example:"1"`
Msg
string
`json:"message" form:"message" example:"OK"`
...
...
@@ -60,7 +69,7 @@ func convertMap(input *EnumDictionary) (map[string][]LabelValue, error) {
}
var
keyValue
any
switch
key
.
Kind
()
{
case
reflect
.
String
,
reflect
.
Int
,
reflect
.
Float64
,
reflect
.
Bool
:
case
reflect
.
String
,
reflect
.
Int
,
reflect
.
Int8
,
reflect
.
Int16
,
reflect
.
Float64
,
reflect
.
Bool
:
keyValue
=
key
.
Interface
()
default
:
keyValue
=
fmt
.
Sprintf
(
"%v"
,
key
.
Interface
())
...
...
global/global.go
浏览文件 @
76b710b4
...
...
@@ -3,5 +3,5 @@ package global
import
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
var
(
NacosCli
ent
*
nacos
.
NacosServiceClient
NacosCli
*
nacos
.
NacosServiceClient
)
httpcli/httpcli.go
浏览文件 @
76b710b4
...
...
@@ -15,6 +15,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/httpContentType"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"github.com/duke-git/lancet/v2/retry"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
...
...
@@ -392,6 +393,7 @@ func (x *Request) pushDo(ctx context.Context) {
var
rsp
*
http
.
Response
rsp
,
x
.
err
=
client
.
Do
(
x
.
request
)
if
x
.
err
!=
nil
{
x
.
err
=
xerror
.
Wrap
(
x
.
err
,
"httpcli do url["
+
x
.
url
+
"] failed"
)
return
}
if
rsp
!=
nil
{
...
...
@@ -403,6 +405,7 @@ func (x *Request) pushDo(ctx context.Context) {
defer
rsp
.
Body
.
Close
()
x
.
response
.
body
,
x
.
err
=
io
.
ReadAll
(
rsp
.
Body
)
if
x
.
err
!=
nil
{
x
.
err
=
xerror
.
Wrap
(
x
.
err
,
"read response body failed"
)
return
}
if
len
(
x
.
response
.
body
)
>
0
{
...
...
init.go
浏览文件 @
76b710b4
...
...
@@ -15,6 +15,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
"gitlab.wanzhuangkj.com/tush/xpkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
func
Init
()
(
err
error
)
{
...
...
@@ -54,40 +55,48 @@ func Init() (err error) {
}
rdt
:=
conf
.
App
.
RegistryDiscoveryType
if
rdt
==
"nacos"
{
localhost
:=
ips
.
GetLocalHost
()
config
.
Write
(
func
(
c
*
config
.
Config
)
{
c
.
Rd
.
Nacos
.
ServiceName
=
conf
.
App
.
Name
c
.
Rd
.
Nacos
.
ServiceIP
=
localhost
c
.
Rd
.
Nacos
.
ServicePort
=
conf
.
HTTP
.
Port
})
config
.
Read
(
func
(
c
*
config
.
Config
)
{
copier
.
Copy
(
&
conf
,
c
)
})
var
nnc
*
nacos
.
NacosServiceClient
if
conf
.
ConfType
==
"nacos"
{
cc
:=
conf
.
NacosConfClient
.
GetCC
()
sc
:=
conf
.
NacosConfClient
.
GetSC
()
nnc
,
err
=
nacos
.
New
(
&
conf
.
Rd
.
Nacos
,
cc
,
sc
)
if
err
!=
nil
{
return
err
}
}
else
{
nnc
,
err
=
nacos
.
NewWithConfig
(
&
conf
.
Rd
.
Nacos
)
if
err
!=
nil
{
return
err
}
}
if
err
:=
nnc
.
Register
();
err
!=
nil
{
if
err
:=
nacosRegisterInstance
();
err
!=
nil
{
return
err
}
config
.
Write
(
func
(
c
*
config
.
Config
)
{
global
.
NacosClient
=
nnc
})
}
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicCoreInitFinish
)
return
nil
}
func
nacosRegisterInstance
()
(
err
error
)
{
conf
:=
config
.
Cfg
localhost
:=
ips
.
GetLocalHost
()
config
.
Write
(
func
(
c
*
config
.
Config
)
{
c
.
Rd
.
Nacos
.
ServiceName
=
conf
.
App
.
Name
c
.
Rd
.
Nacos
.
ServiceIP
=
localhost
c
.
Rd
.
Nacos
.
ServicePort
=
conf
.
HTTP
.
Port
})
config
.
Read
(
func
(
c
*
config
.
Config
)
{
copier
.
Copy
(
&
conf
,
c
)
})
var
nacosCli
*
nacos
.
NacosServiceClient
if
conf
.
ConfType
==
"nacos"
{
cc
:=
conf
.
NacosConfClient
.
GetCC
()
sc
:=
conf
.
NacosConfClient
.
GetSC
()
nacosCli
,
err
=
nacos
.
New
(
&
conf
.
Rd
.
Nacos
,
cc
,
sc
)
if
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"nacos new client failed"
)
}
}
else
{
nacosCli
,
err
=
nacos
.
NewWithConfig
(
&
conf
.
Rd
.
Nacos
)
if
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"nacos new client failed"
)
}
}
if
err
:=
nacosCli
.
Register
();
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"nacos register instance failed"
)
}
config
.
Write
(
func
(
c
*
config
.
Config
)
{
global
.
NacosCli
=
nacosCli
})
return
nil
}
func
initLogger
(
cfg
*
config
.
Config
)
(
err
error
)
{
var
loggerOpts
[]
logger
.
Option
loggerOpts
=
append
(
loggerOpts
,
logger
.
WithLevel
(
cfg
.
Logger
.
Level
),
logger
.
WithFormat
(
cfg
.
Logger
.
Format
))
...
...
sgorm/mysql/mysql.go
浏览文件 @
76b710b4
...
...
@@ -44,7 +44,9 @@ func Init(dsn string, opts ...Option) (*gorm.DB, error) {
return
nil
,
xerror
.
Errorf
(
"using gorm opentelemetry, err: %v"
,
err
)
}
}
if
err
=
sqlDB
.
Ping
();
err
!=
nil
{
return
nil
,
xerror
.
Errorf
(
"ping db failed, err: %v"
,
err
)
}
// register read-write separation plugin
if
len
(
o
.
slavesDsn
)
>
0
{
err
=
db
.
Use
(
rwSeparationPlugin
(
o
))
...
...
third/
ali
oss/oss.go
→
third/oss/oss.go
浏览文件 @
76b710b4
package
aliyun
package
oss
import
(
"io"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论