弹幕、分类下拉、属性下拉、

This commit is contained in:
2025-12-11 16:11:38 +08:00
parent 18d29af70b
commit 291d06fd94
13 changed files with 363 additions and 9 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace app\common\service;
use app\common\validate\BarrageValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\Barrage;
use support\Redis;
use support\Request;
class BarrageService
{
use CrudServiceTrait;
/**
* 指定当前要操作的模型
*/
protected string $modelClass = Barrage::class;
/**
* 验证器
*/
protected $validator = BarrageValidate::class;
/**
* 获取验证器
*/
public function getValidator()
{
return new $this->validator;
}
/**
* 添加前置处理
*/
public function beforeServiceStore($data, Request $request)
{
$data['user_id'] = $request->user->uid;;
return $data;
}
}
@@ -39,6 +39,21 @@ class PostCategoryService
return new $this->validator;
}
/**
* 获取系统list
*/
public function preset($params)
{
$where = [];
if(isset($params['parent_id']) && $params['parent_id']) {
$where['parent_id'] = $params['parent_id'];
}else{
$where['parent_id'] = 0;
}
$result = $this->logic->getList($where)->toArray();
return $result;
}
/**
* 获取系统list
*/
@@ -2,6 +2,8 @@
namespace app\common\service;
use app\common\logic\PostCategoryLogic;
use app\common\logic\SkuAttributeLogic;
use app\common\validate\SkuAttributeValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\SkuAttribute;
@@ -12,6 +14,7 @@ class SkuAttributeService
use CrudServiceTrait;
protected $logic;
/**
* 指定当前要操作的模型
*/
@@ -22,6 +25,11 @@ class SkuAttributeService
*/
protected $validator = SkuAttributeValidate::class;
public function __construct()
{
$this->logic = (new SkuAttributeLogic());
}
/**
* 获取验证器
*/
@@ -58,4 +66,43 @@ class SkuAttributeService
return $config;
}
/**
* 添加前置处理
*/
public function beforeServiceStore($data, Request $request)
{
// $options = [];
// foreach ($data['options_json'] as $v){
// $options[] = $v['value'];
// }
// $data['options_json'] = json_encode($options, JSON_UNESCAPED_UNICODE);
return $data;
}
/**
* 添加前置处理
*/
public function beforeServiceUpdate($data, Request $request)
{
// $options = [];
// foreach ($data['options_json'] as $v){
// $options[] = $v['value'];
// }
// $data['options_json'] = json_encode($options, JSON_UNESCAPED_UNICODE);
return $data;
}
/**
* 获取系统list
*/
public function preset($params)
{
$where = [];
if(isset($params['category_id']) && $params['category_id']) {
$where['category_id'] = $params['category_id'];
}
$result = $this->logic->getList($where)->toArray();
return $result;
}
}