ADD:添加后台管理端接口;

DEL:删除不必要的头部注释;
FIX:修正若干已知错误;
This commit is contained in:
2025-07-13 19:40:10 +08:00
parent 0a45e55cca
commit 270b881437
66 changed files with 8618 additions and 8129 deletions
+35 -38
View File
@@ -1,19 +1,12 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-10T01:13:34+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-08-09T09:18:41+08:00
# @Copyright: www.hiluker.cn
namespace api\controllers\gm\v1;
use Yii;
use yii\helpers\Url;
use yii\data\Pagination;
use yii\web\UploadedFile;
use common\models\CAttachment;
use backend\controllers\Common;
class ImageController extends Common
{
@@ -30,29 +23,47 @@
$apis = [
'list' => '图片列表',
];
$this->result('您正使用CMTS系统订单管理接口!', $apis, 200);
$this->result('您正使用CMTS-GM系统图库管理接口!', $apis, 200);
}
public function actionList()
{
$siteId = Yii::$app->params['siteId'];
$session = Yii::$app->session;
$s = $this->search();
$res = $s['res'];
if (!$res) {
$this->result('没有查询到相应的数据!', [], 0);
}
//附件网址前缀
$src = Url::base(TRUE) . "/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
if ($_SERVER['DOCUMENT_ROOT'] . '/upload' != Yii::getAlias("@upload")) {
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
$src = Yii::$app->params['attachSrc'] . Yii::$app->params['attachDir'];
}
$data= [
'total'=>$s['query']->count(),
'images' => $res,
'src' => $src,
'page'=>$this->page
];
$this->result('图片查询成功', $data, 200);
}
private function search(){
$pid = $this->pid;
$siteId = Yii::$app->params['siteId'];
$return = [];
$model = new CAttachment();
$search = $where = [];
$where = [];
$where[] = 'and';
$where[] = ['=', 'status_code', 1];
$where[] = ['=', 'type', 0];
$where[] = ['=', 'siteid', $siteId];
$where[] = ['=', 'pid', $pid];
$post = $this->postdata;
if (isset($post['search'])) {
$search = $post['search'];
$session->set('images::search', $search);
} else if ($session->get('images::search')) {
$search = $session->get('images::search');
}
$post = $this->postdata;
$search = $post['search'] ?? [];
if ($search) {
if ($search['create_m']) {
$start = strtotime($search['create_m']);
@@ -76,26 +87,12 @@
$where[] = ['LIKE', 'title', $search['title']];
}
}
//分页
$orderby = ['id' => SORT_DESC];
$Attachment = new Attachment();
$list = $Attachment->getData($model, $where, $orderby);
$pager = $Attachment->getPagination();
//附件网址前缀
$src = Url::base(TRUE) . "/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
if ($_SERVER['DOCUMENT_ROOT'] . '/upload' != Yii::getAlias("@upload")) {
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
$src = Yii::$app->params['attachSrc'] . Yii::$app->params['attachDir'];
}
$data = $model->find()->where($where);
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
$data = [
'list' => $list,
'pager' => $pager,
'src' => $src,
'callback' => $callback
];
$this->result('', $data, 200);
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $this->pageSize]);
$_orderby = 'id DESC';
$res = $data->offset($pages->offset)->limit($pages->limit)->orderBy($_orderby)->all();
return ['res'=>$res,'query'=>$data];
}
}