使用系统(版本 v2.3.2.240525)新增的API接口功能,在获取内容分页列表,发生错误:

Argument 2 passed to app\common\dao\cms\ArchivesDao::listSearchJoin() must be of the type int, object given, called in D:\HkCms\Web\app\common\services\cms\ArchivesService.php on line 56

修改相关文件 ArchivesService.php

$modelId = app()->make(CategoryService::class)->getOne($catid,'model_id');

后添加代码:

$modelId = $modelId->model_id;


又出现新的错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'B.' in 'field list'

继续修改文件 ArchivesService.php

把原代码:

        $lists = $query->page($page, $limit)
            ->with(['category'])
            ->order($this->dao->buildOrder($where['sort_by']??['weigh'=>'asc', 'publish_time'=>'desc'], $where['sort_type']??''))
            ->field('A.*,B.'.implode(',B.', $newFields))
            ->select();

修改为:

        $fieldStr = 'A.*';
        if(!empty($newFields)){
            $fieldStr = 'A.*,B.'.implode(',B.', $newFields);
        }
        $lists = $query->page($page, $limit)
            ->with(['category'])
            ->order($this->dao->buildOrder($where['sort_by']??['weigh'=>'asc', 'publish_time'=>'desc'], $where['sort_type']??''))
            ->field($fieldStr)
            ->select();


修改后BUG解决