feat(warehouse): 编辑仓库商品存储功能

- 移除了 WarehouseProductStoregeController 中的注释代码
- 实现了 edit 方法,用于编辑仓库商品存储
- 在 WarehouseProductStoregeLogic 中添加了 edit 方法的逻辑实现
- 使用 Db::startTrans() 开启事务,确保数据一致性
- 引入 BusinessException 异常处理,提高错误处理能力
This commit is contained in:
mkm 2024-12-20 11:46:50 +08:00
parent 195d71519b
commit 94b42547fc
2 changed files with 28 additions and 17 deletions

View File

@ -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());
// }
// /** // /**

View File

@ -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;
} }