feat(warehouse): 编辑仓库商品存储功能
- 移除了 WarehouseProductStoregeController 中的注释代码 - 实现了 edit 方法,用于编辑仓库商品存储 - 在 WarehouseProductStoregeLogic 中添加了 edit 方法的逻辑实现 - 使用 Db::startTrans() 开启事务,确保数据一致性 - 引入 BusinessException 异常处理,提高错误处理能力
This commit is contained in:
parent
195d71519b
commit
94b42547fc
@ -47,21 +47,19 @@ class WarehouseProductStoregeController extends BaseAdminController
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @notes 编辑仓库商品存储
|
* @notes 编辑仓库商品存储
|
||||||
// * @return \think\response\Json
|
* @return \think\response\Json
|
||||||
// * @author admin
|
* @author admin
|
||||||
// * @date 2024/08/01 10:22
|
* @date 2024/08/01 10:22
|
||||||
// */
|
*/
|
||||||
// public function edit()
|
public function edit()
|
||||||
// {
|
{
|
||||||
// $params = (new WarehouseProductStoregeValidate())->post()->goCheck('edit');
|
$params = $this->request->post();
|
||||||
// $result = WarehouseProductStoregeLogic::edit($params);
|
$result = WarehouseProductStoregeLogic::edit($params);
|
||||||
// if (true === $result) {
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
// return $this->success('编辑成功', [], 1, 1);
|
|
||||||
// }
|
}
|
||||||
// return $this->fail(WarehouseProductStoregeLogic::getError());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
@ -6,7 +6,7 @@ namespace app\admin\logic\warehouse_product_storege;
|
|||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
use Webman\Exception\BusinessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库商品存储逻辑
|
* 仓库商品存储逻辑
|
||||||
@ -39,7 +39,20 @@ class WarehouseProductStoregeLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function edit(array $params): bool
|
public static function edit(array $params): bool
|
||||||
{
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$find=WarehouseProductStorege::where('id',$params['id'])->find();
|
||||||
|
if($find){
|
||||||
|
$find->save(['nums'=>$params['nums']]);
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new BusinessException($th->getMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user