AllProjectController.php 2.5 KB
<?php
/**
 * @remark :
 * @name   :AllProjectController.php
 * @author :lyh
 * @method :post
 * @time   :2024/11/12 9:34
 */

namespace App\Http\Controllers\Aside\Project;

use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Domain\DomainInfo;
use App\Models\Project\CountAllProject;
use Illuminate\Support\Facades\DB;

/**
 * @remark :统计所有项目(4.0,5.0,6.0)
 * @name   :AllProjectController
 * @author :lyh
 * @method :post
 * @time   :2024/11/12 9:34
 */
class AllProjectController extends BaseController
{
    /**
     * @remark :统计所有项目列表
     * @name   :lists
     * @author :lyh
     * @method :post
     * @time   :2024/11/12 9:35
     */
    public function lists(CountAllProject $allProject){
        if(isset($this->map['product_domain']) && !empty($this->map['product_domain'])){
            $parsedUrl = parse_url($this->map['product_domain']);
            $this->map['product_domain'] = $parsedUrl['host'] ?? $this->map['product_domain'];
            $this->map['product_domain'] = ['like','%'.$this->map['product_domain'].'%'];
        }
        if(isset($this->map['test_domain']) && !empty($this->map['test_domain'])){
            $this->map['test_domain'] = ['like','%'.$this->map['test_domain'].'%'];
        }
        if(isset($this->map['title']) && !empty($this->map['title'])){
            $this->map['title'] = ['like','%'.$this->map['title'].'%'];
        }
        if(isset($this->map['company']) && !empty($this->map['company'])){
            $this->map['company'] = ['like','%'.$this->map['company'].'%'];
        }
        $data = $allProject->lists($this->map,$this->page,$this->row);

        if (!empty($data['data'])) {
            foreach ($data['data'] as $key => $value) {
                $ticketProject = null;
                if ($value['version'] == 1) {
                    // version 为 1:6.0
                    $ticketProject = DB::table('gl_ticket_projects')
                        ->where('table_id', $value['project_id'])
                        ->where('project_cate', 2)
                        ->first();
                } else {
                    // version 不为 1
                    $ticketProject = DB::table('gl_ticket_projects')
                        ->where('post_id', $value['project_id'])
                        ->where('project_cate', 1)
                        ->first();
                }
                $data['data'][$key]['uuid'] = $ticketProject ? $ticketProject->uuid : null;
            }
        }

        $this->response('success',Code::SUCCESS,$data);
    }
}