ATemplateLogic.php 2.3 KB
<?php

namespace App\Http\Logic\Aside\Template;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Template\ATemplate;
use App\Models\Template\BSetting;

class ATemplateLogic extends BaseLogic
{
    public function __construct()
    {
        parent::__construct();
        $this->model = new ATemplate();
        $this->param = $this->requestAll;
    }

    /**
     * @remark :公共模块模板
     * @name   :aTemplateList
     * @author :lyh
     * @method :post
     * @time   :2023/6/28 17:03
     */
    public function aTemplateList($map,$page,$row,$order = ['created_at'],$filed = ['*']){
        $lists = $this->model->lists($map,$page,$row,$order,$filed);
        return $this->success($lists);
    }

    /**
     * @remark :添加或编辑模块
     * @name   :aTemplateSave
     * @author :lyh
     * @method :post
     * @time   :2023/6/28 17:13
     */
    public function aTemplateSave(){
        if(isset($this->param['id'])){
            $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
        }else{
            $rs = $this->model->add($this->param);
        }
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }

    /**
     * @remark :修改模块状态
     * @name   :aTemplateStatus
     * @author :lyh
     * @method :post
     * @time   :2023/6/28 17:15
     */
    public function aTemplateStatus(){
        $rs = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }


    /**
     * @remark :逻辑删除模板数据
     * @name   :aTemplateDel
     * @author :lyh
     * @method :post
     * @time   :2023/6/28 17:17
     */
    public function aTemplateDel(){
        //查看当前模板是否有模板在使用
        $BSettingModel = new BSetting();
        $info = $BSettingModel->read(['template_id'=>$this->param['id']]);
        if($info !== false){
            $this->fail('当前模板有项目在使用,不允许删除');
        }
        $rs = $this->model->edit(['deleted_status'=>$this->param['deleted_status'],'deleted_at'=>date('Y-m-d H:i:s')],['id'=>$this->param['id']]);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }
}