Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
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
1
Merge Requests
1
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
without authentication
meibuyu-micro
Commits
7c2f9315
Commit
7c2f9315
authored
May 12, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新用户RPC服务方法
parent
eb59e625
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
BaseService.php
src/Service/BaseService.php
+11
-11
UserServiceInterface.php
src/Service/Interfaces/UserServiceInterface.php
+12
-2
No files found.
src/Service/BaseService.php
View file @
7c2f9315
...
...
@@ -27,24 +27,24 @@ class BaseService
protected
function
find
(
$id
)
{
$model
=
$this
->
model
->
find
(
$id
);
// if (!$model) {
// return Helper::fail('', '数据不存在', 404);
// }
return
$model
;
}
public
function
all
(
array
$columns
=
[
'*'
],
array
$relations
=
[])
:
array
{
return
$this
->
model
->
with
(
$relations
)
->
get
(
$columns
)
->
toArray
();
}
/**
* 获取一条数据
* @param $id
* @return array
* @param int $id
* @param array $columns
* @param array $relations
* @return mixed
*/
public
function
get
(
$id
)
public
function
get
(
int
$id
,
array
$columns
=
[
'*'
],
array
$relations
=
[]
)
{
$model
=
$this
->
find
(
$id
);
if
(
!
$model
)
{
return
Helper
::
fail
(
''
,
'数据不存在'
,
404
);
}
return
Helper
::
success
(
$model
);
return
$this
->
model
->
with
(
$relations
)
->
find
(
$id
,
$columns
);
}
/**
...
...
src/Service/Interfaces/UserServiceInterface.php
View file @
7c2f9315
...
...
@@ -13,10 +13,20 @@ interface UserServiceInterface
/**
* 获取单个数据
* @param $id
* @param int $id
* @param array $columns
* @param array $relations
* @return mixed
*/
public
function
get
(
$id
);
public
function
get
(
int
$id
,
array
$columns
=
[
'*'
],
array
$relations
=
[]);
/**
* 获取全部数据
* @param array $columns
* @param array $relations
* @return array
*/
public
function
all
(
array
$columns
=
[
'*'
],
array
$relations
=
[])
:
array
;
/**
* 通过id列表获取用户数组
...
...
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