Commit 86ed5dc1 authored by 王源's avatar 王源 🎧

调整基础代码

parent eca88d2a
...@@ -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) {
......
...@@ -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);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment