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
86ed5dc1
Commit
86ed5dc1
authored
Jan 09, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整基础代码
parent
eca88d2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
9 deletions
+48
-9
BaseService.php
src/Service/BaseService.php
+9
-9
UserServiceInterface.php
src/Service/Interfaces/UserServiceInterface.php
+39
-0
No files found.
src/Service/BaseService.php
View file @
86ed5dc1
...
@@ -46,13 +46,13 @@ class BaseService
...
@@ -46,13 +46,13 @@ class BaseService
/**
/**
* 插入一条数据
* 插入一条数据
* @param array $
data
* @param array $
params
* @return array
* @return array
*/
*/
public
function
insert
(
array
$data
)
public
function
insert
(
$params
)
{
{
try
{
try
{
$res
=
$this
->
model
->
insert
(
$
data
);
$res
=
$this
->
model
->
insert
(
$
params
);
return
Helper
::
success
(
$res
);
return
Helper
::
success
(
$res
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
return
Helper
::
fail
(
''
,
$e
->
getMessage
());
return
Helper
::
fail
(
''
,
$e
->
getMessage
());
...
@@ -61,13 +61,13 @@ class BaseService
...
@@ -61,13 +61,13 @@ class BaseService
/**
/**
* 新增一条数据
* 新增一条数据
* @param array $
data
* @param array $
params
* @return array
* @return array
*/
*/
public
function
create
(
array
$data
)
public
function
create
(
$params
)
{
{
try
{
try
{
$model
=
$this
->
model
->
newInstance
(
$
data
);
$model
=
$this
->
model
->
newInstance
(
$
params
);
$model
->
save
();
$model
->
save
();
return
Helper
::
success
(
$model
);
return
Helper
::
success
(
$model
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
...
@@ -78,14 +78,14 @@ class BaseService
...
@@ -78,14 +78,14 @@ class BaseService
/**
/**
* 更新数据
* 更新数据
* @param $id
* @param $id
* @param array $
data
* @param array $
params
* @return array
* @return array
*/
*/
public
function
update
(
$id
,
array
$data
)
public
function
update
(
$id
,
$params
)
{
{
try
{
try
{
$model
=
$this
->
find
(
$id
);
$model
=
$this
->
find
(
$id
);
$model
->
fill
(
$
data
);
$model
->
fill
(
$
params
);
$model
->
save
();
$model
->
save
();
return
Helper
::
success
(
$model
);
return
Helper
::
success
(
$model
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
...
...
src/Service/Interfaces/UserServiceInterface.php
View file @
86ed5dc1
...
@@ -10,5 +10,44 @@ namespace Meibuyu\Micro\Service\Interfaces;
...
@@ -10,5 +10,44 @@ namespace Meibuyu\Micro\Service\Interfaces;
interface
UserServiceInterface
interface
UserServiceInterface
{
{
/**
* 获取列表数据
* @param array $params
* $params = [
* 'keyword' => '',
* 'page' => 1, 当前第几页
* 'page_size' => 10, 每页展示数,默认10
* ]
* @return mixed
*/
public
function
search
(
$params
);
/**
* 获取单个数据
* @param $id
* @return mixed
*/
public
function
get
(
$id
);
/**
* 新增数据
* @param array $params
* @return mixed
*/
public
function
create
(
array
$params
);
/**
* 更新数据
* @param $id
* @param array $params
* @return mixed
*/
public
function
update
(
$id
,
$params
);
/**
* 删除数据
* @param $id
* @return mixed
*/
public
function
delete
(
$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