feat: 添加产品购买链接添加接口

This commit is contained in:
2025-03-26 18:08:26 +08:00
committed by jsasg
parent 6efd309160
commit 4c2ea0e11a
3 changed files with 65 additions and 12 deletions

View File

@@ -261,6 +261,34 @@ class ProductPurchaseLink
->select();
}
/**
* 添加购买链接
*/
public function save()
{
$post = request()->post([
'link',
'product_id',
'platform_id'
]);
$data = [
'link' => $post['link'],
'language_id' => request()->lang_id,
'product_id' => $post['product_id'],
'platform_id' => $post['platform_id']
];
$validate = new ProductPurchaseLinkValidate;
if (!$validate->scene('add')->check($data)) {
return error($validate->getError());
}
$link = ProductPurchaseLinkModel::create($data);
if ($link->isEmpty()) {
return error('操作失败');
}
return success('操作成功');
}
/**
* 更新购买链接
*/
@@ -279,7 +307,7 @@ class ProductPurchaseLink
'platform_id' => $put['platform_id']
];
$validate = new ProductPurchaseLinkValidate;
if (!$validate->scene('update')->check($data)) {
if (!$validate->scene('edit')->check($data)) {
return error($validate->getError());
}