Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gomicro-base
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
lizifeng
gomicro-base
Commits
1ae63cd0
Commit
1ae63cd0
authored
Jun 10, 2022
by
kzkzzzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 调整
parent
5205d2de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
base64.go
common/hashutil/base64.go
+8
-0
config.yaml
service/demo/config/config.yaml
+1
-1
handler.go
service/demo/internal/server/handler.go
+6
-5
No files found.
common/hashutil/base64.go
0 → 100644
View file @
1ae63cd0
package
hashutil
import
"encoding/base64"
func
Base64Decode
(
src
string
)
string
{
res
,
_
:=
base64
.
StdEncoding
.
DecodeString
(
src
)
return
string
(
res
)
}
service/demo/config/config.yaml
View file @
1ae63cd0
...
@@ -8,7 +8,7 @@ Server:
...
@@ -8,7 +8,7 @@ Server:
Addr
:
"
"
Addr
:
"
"
Mysql
:
Mysql
:
d
sn
:
remote:admin666@tcp(127.0.0.1:3306)/test?loc=Local&charset=utf8mb4&writeTimeout=3s&readTimeout=3s&timeout=1s&parseTime=true
D
sn
:
remote:admin666@tcp(127.0.0.1:3306)/test?loc=Local&charset=utf8mb4&writeTimeout=3s&readTimeout=3s&timeout=1s&parseTime=true
MaxConn
:
8
MaxConn
:
8
MaxIdleConn
:
2
MaxIdleConn
:
2
MaxLifetime
:
1800
# 连接有效时间,单位秒
MaxLifetime
:
1800
# 连接有效时间,单位秒
...
...
service/demo/internal/server/handler.go
View file @
1ae63cd0
...
@@ -22,7 +22,7 @@ func (h *handler) GetDemo(ctx context.Context, req *demo.DemoReq, resp *demo.Dem
...
@@ -22,7 +22,7 @@ func (h *handler) GetDemo(ctx context.Context, req *demo.DemoReq, resp *demo.Dem
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
*
resp
=
h
.
convertUserModel
(
getDemo
)
*
resp
=
*
h
.
convertUserModel
(
getDemo
)
return
nil
return
nil
}
}
...
@@ -30,7 +30,7 @@ func (h *handler) ListDemo(ctx context.Context, req *demo.ListDemoReq, resp *dem
...
@@ -30,7 +30,7 @@ func (h *handler) ListDemo(ctx context.Context, req *demo.ListDemoReq, resp *dem
if
req
.
Limit
<=
0
{
if
req
.
Limit
<=
0
{
req
.
Limit
=
15
req
.
Limit
=
15
}
}
listDemo
,
err
:=
h
.
svc
.
ListDemo
(
ctx
,
req
)
listDemo
,
err
:=
h
.
svc
.
ListDemo
(
ctx
,
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -38,7 +38,7 @@ func (h *handler) ListDemo(ctx context.Context, req *demo.ListDemoReq, resp *dem
...
@@ -38,7 +38,7 @@ func (h *handler) ListDemo(ctx context.Context, req *demo.ListDemoReq, resp *dem
list
:=
make
([]
*
demo
.
DemoResp
,
0
)
list
:=
make
([]
*
demo
.
DemoResp
,
0
)
for
_
,
v
:=
range
listDemo
{
for
_
,
v
:=
range
listDemo
{
c
:=
h
.
convertUserModel
(
v
)
c
:=
*
h
.
convertUserModel
(
v
)
list
=
append
(
list
,
&
c
)
list
=
append
(
list
,
&
c
)
}
}
resp
.
List
=
list
resp
.
List
=
list
...
@@ -46,8 +46,8 @@ func (h *handler) ListDemo(ctx context.Context, req *demo.ListDemoReq, resp *dem
...
@@ -46,8 +46,8 @@ func (h *handler) ListDemo(ctx context.Context, req *demo.ListDemoReq, resp *dem
return
nil
return
nil
}
}
func
(
h
*
handler
)
convertUserModel
(
users
*
model
.
User
)
(
resp
demo
.
DemoResp
)
{
func
(
h
*
handler
)
convertUserModel
(
users
*
model
.
User
)
(
resp
*
demo
.
DemoResp
)
{
r
eturn
demo
.
DemoResp
{
r
:=
&
demo
.
DemoResp
{
Id
:
cast
.
ToString
(
users
.
Id
),
Id
:
cast
.
ToString
(
users
.
Id
),
Username
:
users
.
Username
,
Username
:
users
.
Username
,
Email
:
users
.
Email
,
Email
:
users
.
Email
,
...
@@ -56,4 +56,5 @@ func (h *handler) convertUserModel(users *model.User) (resp demo.DemoResp) {
...
@@ -56,4 +56,5 @@ func (h *handler) convertUserModel(users *model.User) (resp demo.DemoResp) {
CreatedAt
:
timestamppb
.
New
(
users
.
CreatedAt
),
CreatedAt
:
timestamppb
.
New
(
users
.
CreatedAt
),
UpdatedAt
:
timestamppb
.
New
(
users
.
UpdatedAt
),
UpdatedAt
:
timestamppb
.
New
(
users
.
UpdatedAt
),
}
}
return
r
}
}
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