|
|
|
@ -30,4 +30,45 @@ class Source extends Controller |
|
|
|
|
$list = $modal->getList($this->request->param()); |
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 货源新增 |
|
|
|
|
* return Json |
|
|
|
|
*/ |
|
|
|
|
public function add(): Json |
|
|
|
|
{ |
|
|
|
|
$modal = new GoodsSourceModel; |
|
|
|
|
if ($modal->add($this->postForm())) { |
|
|
|
|
return $this->renderSuccess('添加成功'); |
|
|
|
|
} |
|
|
|
|
return $this->renderError($modal->getError() ?: '添加失败'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 货源编辑 |
|
|
|
|
* @param int $sourceId |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function edit(int $sourceId): Json |
|
|
|
|
{ |
|
|
|
|
$modal = GoodsSourceModel::detail($sourceId); |
|
|
|
|
if ($modal->edit($this->postForm())) { |
|
|
|
|
return $this->renderSuccess('更新成功'); |
|
|
|
|
} |
|
|
|
|
return $this->renderError($modal->getError() ?: '更新失败'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 货源删除 |
|
|
|
|
* @param int $sourceId |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function delete(int $sourceId): Json |
|
|
|
|
{ |
|
|
|
|
$modal = GoodsSourceModel::detail($sourceId); |
|
|
|
|
if ($modal->setDelete()) { |
|
|
|
|
return $this->renderSuccess('删除成功'); |
|
|
|
|
} |
|
|
|
|
return $this->renderError($modal->getError() ?: '删除失败'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|