OaNoticeLogic.php 2.4 KB
<?php
/**
 * @remark :
 * @name   :OaNoticeLogic.php
 * @author :lyh
 * @method :post
 * @time   :2024/6/20 10:48
 */

namespace App\Http\Logic\Aside\Com;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Manage\Manage;
use App\Models\OaNotice\OaNotice;
use App\Models\Project\Project;

class OaNoticeLogic extends BaseLogic
{
    /**
     * 初始数据
     */
    public function __construct()
    {
        parent::__construct();
        $this->model = new OaNotice();
        $this->param = $this->requestAll;
    }

    /**
     * @remark :保存数据
     * @name   :saveOaNotice
     * @author :lyh
     * @method :post
     * @time   :2024/6/20 15:03
     */
    public function saveOaNotice(){
        $this->param['operator_id'] = $this->manager['id'];
        $project_str = trim($this->param['project_str'],',');
        if($project_str != 'all'){
            $this->param['project_str'] = ','.$project_str.',';
        }
        if(isset($this->param['id']) && !empty($this->param['id'])){
            $id = $this->param['id'];
            $this->model->edit($this->param,['id'=>$id]);
        }else{
            $id = $this->model->addReturnId($this->param);
        }
        return $this->success(['id'=>$id]);
    }

    /**
     * @remark :修改状态
     * @name   :statusOaNotice
     * @author :lyh
     * @method :post
     * @time   :2024/6/20 15:44
     */
    public function statusOaNotice(){
        $id = $this->param['id'];
        $this->model->edit(['status'=>$this->param['status']],['id'=>$id]);
        return $this->success(['id'=>$id]);
    }

    /**
     * @remark :获取详情
     * @name   :infoOaNotice
     * @author :lyh
     * @method :post
     * @time   :2024/6/20 16:04
     */
    public function infoOaNotice(){
        $info = $this->model->read($this->param);
        if($info == false){
            $this->fail('当前数据不存在或已被删除');
        }
        $info['project_str'] = trim($info['project_str'],',');
        if(strtolower($info['project_str']) != 'all'){
            $projectModel = new Project();
            $info['project_title'] = $projectModel->formatQuery(['id'=>['in',explode(',',$info['project_str'])]])->pluck('title')->toArray();
        }else{
            $info['project_title'] = '所有';
        }
        $info['operator_name'] = (new Manage())->getName($info['operator_id']);
        return $this->success($info);
    }
}