Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
colorway
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
golang
colorway
Commits
886cf7e2
Commit
886cf7e2
authored
Jul 03, 2025
by
zhengyaoqiu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(colorway): 代码优化
parent
83fdf144
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
4 deletions
+42
-4
manager.go
internal/pkg/database/mongo/manager.go
+6
-4
servicecontext.go
internal/rpc/internal/svc/servicecontext.go
+4
-0
platform.go
pkg/platform/platform.go
+0
-0
reflect.go
pkg/reflect/reflect.go
+32
-0
store.go
pkg/store/store.go
+0
-0
No files found.
internal/pkg/database/mongo/manager.go
View file @
886cf7e2
...
...
@@ -4,6 +4,8 @@ import (
"context"
productModel
"git.chillcy.com/golang/colorway/internal/pkg/database/mongo/model/product"
sitePlatformPriceConfigModel
"git.chillcy.com/golang/colorway/internal/pkg/database/mongo/model/site_platform_price_config"
reflect2
"git.chillcy.com/golang/colorway/pkg/reflect"
"reflect"
)
const
DatabaseColorWay
=
"color_way"
...
...
@@ -21,9 +23,9 @@ func NewManager(mongoUrl string) *Manager {
}
func
(
receiver
*
Manager
)
StartCache
()
error
{
err
:=
receiver
.
SitePlatformPriceConfigModel
.
StartCache
(
context
.
Background
()
)
if
err
!=
nil
{
re
turn
err
ctx
:=
context
.
TODO
(
)
args
:=
[]
reflect
.
Value
{
re
flect
.
ValueOf
(
ctx
),
}
return
reflect2
.
MemberMethodCall
(
receiver
,
"StartCache"
,
args
)
}
internal/rpc/internal/svc/servicecontext.go
View file @
886cf7e2
...
...
@@ -24,6 +24,10 @@ func NewServiceContext(c config.Config) *ServiceContext {
etcd
.
Init
(
etcd
.
Env
(
c
.
Mode
))
pc4RpcProductServiceTarget
:=
etcd
.
Get
(
etcd
.
KeyRpcPc4
)
mongoManager
:=
mongo
.
NewManager
(
etcd
.
Get
(
etcd
.
KeyMongoProductUri
))
err
:=
mongoManager
.
StartCache
()
if
err
!=
nil
{
panic
(
err
)
}
if
etcd
.
GetEnv
()
==
etcd
.
EnvDev
{
pc4RpcProductServiceTarget
=
"127.0.0.1:5100"
}
...
...
internal/
pkg/platform/platform.go
→
pkg/platform/platform.go
View file @
886cf7e2
File moved
pkg/reflect/reflect.go
0 → 100644
View file @
886cf7e2
package
reflect
import
(
"fmt"
"reflect"
)
func
MemberMethodCall
(
obj
any
,
methodName
string
,
in
[]
reflect
.
Value
)
error
{
v
:=
reflect
.
ValueOf
(
obj
)
.
Elem
()
// 获取指针指向的值
t
:=
reflect
.
TypeOf
(
obj
)
.
Elem
()
// 获取指针指向的类型
for
i
:=
0
;
i
<
v
.
NumField
();
i
++
{
field
:=
v
.
Field
(
i
)
fieldType
:=
t
.
Field
(
i
)
// 检查字段是否为 nil
if
field
.
IsNil
()
{
return
fmt
.
Errorf
(
"字段 %s 为 nil,跳过
\n
"
,
fieldType
.
Name
)
}
// 检查是否有 methodName 方法
method
:=
field
.
MethodByName
(
methodName
)
if
!
method
.
IsValid
()
{
return
fmt
.
Errorf
(
"字段 %s 没有 %s 方法
\n
"
,
fieldType
.
Name
,
methodName
)
}
// 调用 methodName 方法
fmt
.
Printf
(
"调用 %s.%s()
\n
"
,
fieldType
.
Name
,
methodName
)
method
.
Call
(
in
)
}
return
nil
}
internal/
pkg/store/store.go
→
pkg/store/store.go
View file @
886cf7e2
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment