BlogLabelController.php 2.2 KB
<?php

namespace App\Http\Controllers\Bside\Blog;

use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Blog\BlogLabelLogic;
use App\Http\Requests\Bside\Blog\BlogLabelRequest;
use App\Models\Blog\BlogLabel as BlogLabelModel;
use Illuminate\Http\Request;

class BlogLabelController extends BaseController
{
    /**
     * @name :博客标签列表
     * @author :liyuhang
     * @method
     */
    public function lists(BlogLabelModel $blogLabelModel){
        $this->map['project_id'] = $this->user['project_id'];
        $lists = $blogLabelModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','created_at','updated_at']);
        $this->response('success',Code::SUCCESS,$lists);
    }

    /**
     * @name :添加标签
     * @return void
     * @author :liyuhang
     * @method
     */
    public function add(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){
        $request->validated();
        $blogLabelLogic->add_blog_label();
        $this->response('success');
    }

    /**
     * @name :编辑标签
     * @author :liyuhang
     * @method
     */
    public function edit(BlogLabelRequest $request,BlogLabelLogic $blogLabelLogic){
        $request->validate([
            'id'=>['required']
        ],[
            'id.required' => 'ID不能为空'
        ]);
        $blogLabelLogic->edit_blog_label();
        $this->response('success');
    }

    /**
     * @name :编辑标签状态/排序
     * @author :liyuhang
     * @method
     */
    public function status(BlogLabelLogic $blogLabelLogic){
        $this->request->validate([
            'id'=>['required'],
        ],[
            'id.required' => 'ID不能为空',
        ]);
        $blogLabelLogic->status_blog_label();
        $this->response('success');
    }

    /**
     * @name :删除标签(批量删除)
     * @author :liyuhang
     * @method
     */
    public function del(BlogLabelLogic $blogLabelLogic){
        $this->request->validate([
            'id'=>['required','array'],
        ],[
            'id.required' => 'ID不能为空',
            'id.array' => 'ID为数组',
        ]);
        $blogLabelLogic->del_blog_label();
        $this->response('success');
    }
}