chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
126
app/controller/api/v1/user/UserCollect.php
Normal file
126
app/controller/api/v1/user/UserCollect.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\v1\user;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\UserRelationServices;
|
||||
use crmeb\services\CacheService;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 用户收藏
|
||||
* Class UserCollect
|
||||
* @package app\api\controller\v1\user
|
||||
*/
|
||||
class UserCollect
|
||||
{
|
||||
|
||||
/**
|
||||
* @var UserRelationServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserRelationServices $services;
|
||||
|
||||
/**
|
||||
* 获取收藏列表
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_user(Request $request)
|
||||
{
|
||||
[$category] = $request->postMore([
|
||||
['category', 'product']
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$list = $this->services->getUserRelationList($uid, $category);
|
||||
foreach ($list as &$item) {
|
||||
$item['promotions'] = !isset($item['promotions']) || !$item['promotions'] ? (object)[] : $item['promotions'];
|
||||
}
|
||||
$count = $this->services->getUserCount($uid,0, UserRelationServices::TYPE_COLLECT, $category);
|
||||
return app('json')->successful(compact('list', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加收藏
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @param $category
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_add(Request $request)
|
||||
{
|
||||
[$id, $category] = $request->postMore([
|
||||
['id', 0],
|
||||
['category', 'product']
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if(!is_array($id)) $id = [$id];
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->productRelation($uid, $id, 'collect', $category);
|
||||
if (!$res) {
|
||||
return app('json')->fail('添加收藏失败');
|
||||
} else {
|
||||
CacheService::clearTokenAll('relation_' . fmod((float)$request->uid(), (float)10));
|
||||
return app('json')->successful('收藏成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消收藏
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_del(Request $request)
|
||||
{
|
||||
[$id, $category] = $request->postMore([
|
||||
['id', 0],
|
||||
['category', 'product']
|
||||
], true);
|
||||
if (!$id) return app('json')->fail('参数错误');
|
||||
if (!is_array($id)) $id = [$id];
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->productRelation($uid, $id, 'collect', $category, true);
|
||||
if (!$res) {
|
||||
return app('json')->fail('取消收藏失败');
|
||||
} else {
|
||||
CacheService::clearTokenAll('relation_' . fmod((float)$request->uid(), (float)10));
|
||||
return app('json')->successful('取消收藏成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量收藏
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function collect_all(Request $request)
|
||||
{
|
||||
$collectInfo = $request->postMore([
|
||||
['id', ''],
|
||||
['category', 'product'],
|
||||
]);
|
||||
$collectInfo['id'] = stringToIntArray($collectInfo['id']);
|
||||
if (!count($collectInfo['id'])) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$uid = (int)$request->uid();
|
||||
$productIdS = $collectInfo['id'];
|
||||
$res = $this->services->productRelation($uid, $productIdS, 'collect', $collectInfo['category']);
|
||||
if (!$res) {
|
||||
return app('json')->fail('收藏失败');
|
||||
} else {
|
||||
CacheService::clearTokenAll('relation_' . fmod((float)$request->uid(), (float)10));
|
||||
return app('json')->successful('收藏成功');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user