Merge pull request 'feat(warehouse): 编辑仓库商品存储功能' (#400) from dev into main

Reviewed-on: #400
This commit is contained in:
mkm 2024-12-20 11:47:17 +08:00
commit b6d41470c5
2 changed files with 28 additions and 17 deletions

View File

@ -47,21 +47,19 @@ class WarehouseProductStoregeController extends BaseAdminController
// }
// /**
// * @notes 编辑仓库商品存储
// * @return \think\response\Json
// * @author admin
// * @date 2024/08/01 10:22
// */
// public function edit()
// {
// $params = (new WarehouseProductStoregeValidate())->post()->goCheck('edit');
// $result = WarehouseProductStoregeLogic::edit($params);
// if (true === $result) {
// return $this->success('编辑成功', [], 1, 1);
// }
// return $this->fail(WarehouseProductStoregeLogic::getError());
// }
/**
* @notes 编辑仓库商品存储
* @return \think\response\Json
* @author admin
* @date 2024/08/01 10:22
*/
public function edit()
{
$params = $this->request->post();
$result = WarehouseProductStoregeLogic::edit($params);
return $this->success('编辑成功', [], 1, 1);
}
// /**

View File

@ -6,7 +6,7 @@ namespace app\admin\logic\warehouse_product_storege;
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
use app\common\logic\BaseLogic;
use think\facade\Db;
use Webman\Exception\BusinessException;
/**
* 仓库商品存储逻辑
@ -39,7 +39,20 @@ class WarehouseProductStoregeLogic extends BaseLogic
*/
public static function edit(array $params): bool
{
return true;
Db::startTrans();
try {
$find=WarehouseProductStorege::where('id',$params['id'])->find();
if($find){
$find->save(['nums'=>$params['nums']]);
}
Db::commit();
return true;
} catch (\Throwable $th) {
Db::rollback();
throw new BusinessException($th->getMessage());
}
return false;
}