BTemplateLabelLogic.php 1.6 KB
<?php
/**
 * @remark :
 * @name   :BTemplateLabelLogic.php
 * @author :lyh
 * @method :post
 * @time   :2024/5/16 9:54
 */

namespace App\Http\Logic\Bside\BTemplate;

use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\TemplateLabel;

/**
 * @remark :模版标签
 * @name   :BTemplateLabelLogic
 * @author :lyh
 * @method :post
 * @time   :2024/5/16 9:54
 */
class BTemplateLabelLogic extends BaseLogic
{
    /**
     * 初始化数据
     */
    public function __construct()
    {
        parent::__construct();
        $this->model = new TemplateLabel();
        $this->param = $this->requestAll;
    }


    /**
     * @remark :保存标签
     * @name   :saveLabel
     * @author :lyh
     * @method :post
     * @time   :2024/5/16 9:55
     */
    public function saveLabel(){
        try {
            if(isset($this->param['id']) && !empty($this->param['id'])){
                $id = $this->param['id'];
                $this->model->edit($this->param,['id'=>$id]);
            }else{
                $this->param['user_id'] = $this->user['id'];
                $id = $this->model->addReturnId($this->param);
            }
        }catch (\Exception $e){
            $this->fail('保存失败,请联系管理员');
        }
        return $this->success(['id'=>$id]);
    }

    /**
     * @remark :删除标签
     * @name   :delLabel
     * @author :lyh
     * @method :post
     * @time   :2024/5/16 10:03
     */
    public function delLabel(){
        $rs = $this->model->del($this->param);
        if($rs === false){
            $this->fail('删除失败,请联系管理员');
        }
        return $this->success();
    }
}