|
...
|
...
|
@@ -11,6 +11,7 @@ use App\Models\Template\BTemplate; |
|
|
|
use App\Rules\Ids;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CategoryController
|
|
|
|
* @package App\Http\Controllers\Bside
|
|
...
|
...
|
@@ -19,6 +20,15 @@ use Illuminate\Http\Request; |
|
|
|
*/
|
|
|
|
class CategoryController extends BaseController
|
|
|
|
{
|
|
|
|
public $model;
|
|
|
|
public $logic;
|
|
|
|
|
|
|
|
public function __construct(Request $request)
|
|
|
|
{
|
|
|
|
parent::__construct($request);
|
|
|
|
$this->model = new Category();
|
|
|
|
$this->logic = new CategoryLogic();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :分类列表
|
|
...
|
...
|
@@ -27,16 +37,16 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/17 10:59
|
|
|
|
*/
|
|
|
|
public function index(Category $category)
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$this->map = $this->searchParam();
|
|
|
|
$filed = ['id', 'project_id', 'pid', 'title', 'image', 'route', 'status','created_at','sort'];
|
|
|
|
$this->map['deleted_at'] = null;
|
|
|
|
if($this->user['project_id'] == 3283){//分类太多加载失败
|
|
|
|
$list = $this->get3283Lists($category,$filed);
|
|
|
|
$list = $this->get3283Lists($filed);
|
|
|
|
return $this->response('success',Code::SUCCESS,$list);
|
|
|
|
}else{
|
|
|
|
$data = $this->getList($category,$filed);
|
|
|
|
$data = $this->getList($filed);
|
|
|
|
return $this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -48,14 +58,14 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/19 14:41
|
|
|
|
*/
|
|
|
|
public function getList(&$category,$filed){
|
|
|
|
$list = $category->list($this->map,['sort','id'],$filed);
|
|
|
|
public function getList($filed){
|
|
|
|
$list = $this->model->list($this->map,['sort','id'],$filed);
|
|
|
|
$data = [];
|
|
|
|
if(!empty($list)){
|
|
|
|
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
|
|
|
|
foreach ($list as $k =>$v){
|
|
|
|
$v['url'] = $this->user['domain'] . $v['route'].'/';
|
|
|
|
$v['product_num'] = $category->getProductNum($list,$v['id']);
|
|
|
|
$v['product_num'] = $this->model->getProductNum($list,$v['id']);
|
|
|
|
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
|
|
|
|
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
|
|
|
|
$list[$k] = $v;
|
|
...
|
...
|
@@ -76,16 +86,16 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/19 14:38
|
|
|
|
*/
|
|
|
|
public function get3283Lists(&$category,$filed){
|
|
|
|
public function get3283Lists($filed){
|
|
|
|
if(!isset($this->map['title'])){
|
|
|
|
$this->map['pid'] = $this->map['pid'] ?? 0;
|
|
|
|
}
|
|
|
|
$list = $category->list($this->map,['sort','id'],$filed);
|
|
|
|
$list = $this->model->list($this->map,['sort','id'],$filed);
|
|
|
|
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
|
|
|
|
foreach ($list as $k =>$v){
|
|
|
|
$v['url'] = $this->user['domain'] . $v['route'].'/';
|
|
|
|
$v['product_num'] = $category->getProductNum($list,$v['id']);
|
|
|
|
$v['hasChildren'] = $this->getCategoryHasChildren($category,$v['id']);
|
|
|
|
$v['product_num'] = $this->model->getProductNum($list,$v['id']);
|
|
|
|
$v['hasChildren'] = $this->getCategoryHasChildren($v['id']);
|
|
|
|
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
|
|
|
|
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
|
|
|
|
$list[$k] = $v;
|
|
...
|
...
|
@@ -100,8 +110,8 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/20 9:18
|
|
|
|
*/
|
|
|
|
public function getCategoryHasChildren(&$category,$id){
|
|
|
|
$count = $category->counts(['pid'=>$id]);
|
|
|
|
public function getCategoryHasChildren($id){
|
|
|
|
$count = $this->model->counts(['pid'=>$id]);
|
|
|
|
if($count != 0){
|
|
|
|
return true;
|
|
|
|
}
|
|
...
|
...
|
@@ -147,8 +157,8 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 9:03
|
|
|
|
*/
|
|
|
|
public function categoryTopList(CategoryLogic $logic){
|
|
|
|
$list = $logic->categoryTopList();
|
|
|
|
public function categoryTopList(){
|
|
|
|
$list = $this->logic->categoryTopList();
|
|
|
|
$this->response('success',Code::SUCCESS,$list);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -159,13 +169,13 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/21 17:12
|
|
|
|
*/
|
|
|
|
public function info(CategoryLogic $logic){
|
|
|
|
public function info(){
|
|
|
|
$this->request->validate([
|
|
|
|
'id'=>'required'
|
|
|
|
],[
|
|
|
|
'id.required' => 'ID不能为空'
|
|
|
|
]);
|
|
|
|
$data = $logic->getCateInfo($this->param['id']);
|
|
|
|
$data = $this->logic->getCateInfo($this->param['id']);
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -176,10 +186,10 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/21 17:13
|
|
|
|
*/
|
|
|
|
public function save(CategoryRequest $request, CategoryLogic $logic)
|
|
|
|
public function save(CategoryRequest $request)
|
|
|
|
{
|
|
|
|
$request->validated();
|
|
|
|
$data = $logic->categorySave();
|
|
|
|
$data = $this->logic->categorySave();
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -190,7 +200,7 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/26 17:35
|
|
|
|
*/
|
|
|
|
public function sort(CategoryLogic $logic){
|
|
|
|
public function sort(){
|
|
|
|
$this->request->validate([
|
|
|
|
'id'=>'required',
|
|
|
|
'sort'=>'numeric|min:0',
|
|
...
|
...
|
@@ -199,7 +209,7 @@ class CategoryController extends BaseController |
|
|
|
'sort.numeric' => 'sort位数字',
|
|
|
|
'sort.min' => 'sort最小值为0',
|
|
|
|
]);
|
|
|
|
$logic->categorySort();
|
|
|
|
$this->logic->categorySort();
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -210,14 +220,14 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/21 17:20
|
|
|
|
*/
|
|
|
|
public function delete(Request $request, CategoryLogic $logic)
|
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
$request->validate([
|
|
|
|
$this->request->validate([
|
|
|
|
'ids'=>['required', new Ids()]
|
|
|
|
],[
|
|
|
|
'ids.required' => 'ID不能为空'
|
|
|
|
]);
|
|
|
|
$data = $logic->categoryDelete();
|
|
|
|
$data = $this->logic->categoryDelete();
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -229,8 +239,8 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/10 15:34
|
|
|
|
*/
|
|
|
|
public function allSort(CategoryLogic $logic){
|
|
|
|
$logic->setAllSort();
|
|
|
|
public function allSort(){
|
|
|
|
$this->logic->setAllSort();
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -241,13 +251,13 @@ class CategoryController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/8 17:49
|
|
|
|
*/
|
|
|
|
public function copyCategory(CategoryLogic $logic){
|
|
|
|
public function copyCategory(){
|
|
|
|
$this->request->validate([
|
|
|
|
'id'=>['required'],
|
|
|
|
],[
|
|
|
|
'id.required' => 'ID不能为空',
|
|
|
|
]);
|
|
|
|
$logic->copyCategoryInfo();
|
|
|
|
$this->logic->copyCategoryInfo();
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|