multi-store/app/api/controller/user/UserVisitController.php
2024-06-05 14:54:25 +08:00

35 lines
1.1 KiB
PHP

<?php
namespace app\api\controller\user;
use app\api\controller\BaseApiController;
use app\api\logic\user\UserVisitLogic;
use app\api\validate\VisitValidate;
use hg\apidoc\annotation as ApiDoc;
#[ApiDoc\title('用户访问')]
class UserVisitController extends BaseApiController
{
#[
ApiDoc\Title('添加访问商品记录'),
ApiDoc\url('/api/user/UserVisit/productLog'),
ApiDoc\Method('POST'),
ApiDoc\Param(name: "product_id", type: "int", require: true, desc: "product_id商品id"),
ApiDoc\Param(name: "cate_id", type: "int", require: true, desc: "分类id"),
ApiDoc\NotHeaders(),
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
ApiDoc\ResponseSuccess("data", type: "array"),
]
public function productLog()
{
$params = (new VisitValidate())->post()->goCheck('add');
$result = UserVisitLogic::add($params,$this->userId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(UserVisitLogic::getError());
}
}