Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kratos-layout
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
kratos-layout
Commits
2f3cd151
Commit
2f3cd151
authored
Jun 08, 2022
by
kzkzzzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
c72bd7a8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
112 deletions
+0
-112
greeter.go
internal/biz/greeter.go
+0
-45
greeter.go
internal/data/greeter.go
+0
-38
greeter.go
internal/service/greeter.go
+0
-29
No files found.
internal/biz/greeter.go
deleted
100644 → 0
View file @
c72bd7a8
package
biz
import
(
"context"
v1
"github.com/go-kratos/kratos-layout/api/helloworld/v1"
"github.com/go-kratos/kratos/v2/errors"
"github.com/go-kratos/kratos/v2/log"
)
var
(
// ErrUserNotFound is user not found.
ErrUserNotFound
=
errors
.
NotFound
(
v1
.
ErrorReason_USER_NOT_FOUND
.
String
(),
"user not found"
)
)
// Greeter is a Greeter model.
type
Greeter
struct
{
Hello
string
}
// GreeterRepo is a Greater repo.
type
GreeterRepo
interface
{
Save
(
context
.
Context
,
*
Greeter
)
(
*
Greeter
,
error
)
Update
(
context
.
Context
,
*
Greeter
)
(
*
Greeter
,
error
)
FindByID
(
context
.
Context
,
int64
)
(
*
Greeter
,
error
)
ListByHello
(
context
.
Context
,
string
)
([]
*
Greeter
,
error
)
ListAll
(
context
.
Context
)
([]
*
Greeter
,
error
)
}
// GreeterUsecase is a Greeter usecase.
type
GreeterUsecase
struct
{
repo
GreeterRepo
log
*
log
.
Helper
}
// NewGreeterUsecase new a Greeter usecase.
func
NewGreeterUsecase
(
repo
GreeterRepo
)
*
GreeterUsecase
{
return
&
GreeterUsecase
{
repo
:
repo
}
}
// CreateGreeter creates a Greeter, and returns the new Greeter.
func
(
uc
*
GreeterUsecase
)
CreateGreeter
(
ctx
context
.
Context
,
g
*
Greeter
)
(
*
Greeter
,
error
)
{
log
.
Infof
(
"CreateGreeter: %v"
,
g
.
Hello
)
return
uc
.
repo
.
Save
(
ctx
,
g
)
}
internal/data/greeter.go
deleted
100644 → 0
View file @
c72bd7a8
package
data
import
(
"context"
"github.com/go-kratos/kratos-layout/internal/biz"
)
type
greeterRepo
struct
{
data
*
Data
}
// NewGreeterRepo .
func
NewGreeterRepo
(
data
*
Data
)
biz
.
GreeterRepo
{
return
&
greeterRepo
{
data
:
data
,
}
}
func
(
r
*
greeterRepo
)
Save
(
ctx
context
.
Context
,
g
*
biz
.
Greeter
)
(
*
biz
.
Greeter
,
error
)
{
return
g
,
nil
}
func
(
r
*
greeterRepo
)
Update
(
ctx
context
.
Context
,
g
*
biz
.
Greeter
)
(
*
biz
.
Greeter
,
error
)
{
return
g
,
nil
}
func
(
r
*
greeterRepo
)
FindByID
(
context
.
Context
,
int64
)
(
*
biz
.
Greeter
,
error
)
{
return
nil
,
nil
}
func
(
r
*
greeterRepo
)
ListByHello
(
context
.
Context
,
string
)
([]
*
biz
.
Greeter
,
error
)
{
return
nil
,
nil
}
func
(
r
*
greeterRepo
)
ListAll
(
context
.
Context
)
([]
*
biz
.
Greeter
,
error
)
{
return
nil
,
nil
}
internal/service/greeter.go
deleted
100644 → 0
View file @
c72bd7a8
package
service
import
(
"context"
v1
"github.com/go-kratos/kratos-layout/api/helloworld/v1"
"github.com/go-kratos/kratos-layout/internal/biz"
)
// GreeterService is a greeter service.
type
GreeterService
struct
{
v1
.
UnimplementedGreeterServer
uc
*
biz
.
GreeterUsecase
}
// NewGreeterService new a greeter service.
func
NewGreeterService
(
uc
*
biz
.
GreeterUsecase
)
*
GreeterService
{
return
&
GreeterService
{
uc
:
uc
}
}
// SayHello implements helloworld.GreeterServer.
func
(
s
*
GreeterService
)
SayHello
(
ctx
context
.
Context
,
in
*
v1
.
HelloRequest
)
(
*
v1
.
HelloReply
,
error
)
{
g
,
err
:=
s
.
uc
.
CreateGreeter
(
ctx
,
&
biz
.
Greeter
{
Hello
:
in
.
Name
})
if
err
!=
nil
{
return
nil
,
err
}
return
&
v1
.
HelloReply
{
Message
:
"Hello "
+
g
.
Hello
},
nil
}
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