AyrReleaseLogic.php 2.1 KB
<?php

namespace App\Http\Logic\Bside\AyrShare;

use App\Http\Logic\Bside\BaseLogic;
use App\Models\AyrShare\AyrRelease;
use App\Models\File\File;
use App\Models\File\Image;

class AyrReleaseLogic extends BaseLogic
{


    public function __construct()
    {
        parent::__construct();
        $this->model = new AyrRelease();
        $this->param = $this->requestAll;
    }

    /**
     * @name   :(获取详情)release_info
     * @author :lyh
     * @method :post
     * @time   :2023/5/9 16:27
     */
    public function release_info(){
        $info = $this->model->read($this->param);
        if($info === false){
            $this->fail('error');
        }
        return $this->success($info);
    }
    /**
     * @name   :(发布社交写入数据库)release_add
     * @author :lyh
     * @method :post
     * @time   :2023/5/9 9:38
     */
    public function release_add(){
        $this->param['project_id'] = $this->user['project_id'];
        $this->param['operator_id'] = $this->user['id'];
        if(isset($this->param['images']) && !empty($this->param['images'])){
            $this->param['images'] = implode(',',$this->param['images']);
        }
        $this->param['platforms'] = json_encode($this->param['platforms']);
        $rs = $this->model->add($this->param);
        if($rs === false){
            $this->fail('error');
        }
        return $this->success();
    }
    /**
     * @name   :(上传第三方图片参数处理)get_param
     * @author :lyh
     * @method :post
     * @time   :2023/5/10 10:27
     */
    public function image_file_param($data) {
        $arr = [];
        foreach ($data as $k => $v){
            if($k == 'images'){
                $images = $v;
                $imageModel = new Image();
                $list = $imageModel->list(['path'=>['in',$images]],'id');
                foreach ($list as $v1){
                    $arr[] = getImageUrl($v1['path']);
                }
            }else{
                $fileModel = new File();
                $info = $fileModel->read(['path'=>$v]);
                $arr[] = getFileUrl($info['path']);
            }
        }
        return $this->success($arr);
    }

}