102 lines
3.1 KiB
PHP
Executable File
102 lines
3.1 KiB
PHP
Executable File
<?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\data\Pagination;
|
||
use yii\web\UploadedFile;
|
||
use common\models\CAttachment;
|
||
use backend\controllers\Common;
|
||
|
||
class ImageController extends Common
|
||
{
|
||
public function beforeAction($action)
|
||
{
|
||
if (!$this->pid) {
|
||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||
}
|
||
return parent::beforeAction($action);
|
||
}
|
||
|
||
public function actionIndex()
|
||
{
|
||
$apis = [
|
||
'list' => '图片列表',
|
||
];
|
||
$this->result('您正使用CMTS系统订单管理接口!', $apis, 200);
|
||
}
|
||
|
||
public function actionList()
|
||
{
|
||
$siteId = Yii::$app->params['siteId'];
|
||
$session = Yii::$app->session;
|
||
$pid = $this->pid;
|
||
$model = new CAttachment();
|
||
$search = $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');
|
||
}
|
||
if ($search) {
|
||
if ($search['create_m']) {
|
||
$start = strtotime($search['create_m']);
|
||
$s = date("Y-m-d H:i:s", $start);
|
||
$ldm = strtotime("last day of " . $s);
|
||
$m = date("Y-m-d", $ldm) . " 23:59:59";
|
||
$end = strtotime($m);
|
||
$where[] = ['between', 'create_at', $start, $end];
|
||
} else if (!empty($search['create_after']) && !empty($search['create_before'])) {
|
||
$start = strtotime($search['create_after']);
|
||
$end = strtotime($search['create_before']);
|
||
$where[] = ['between', 'create_at', $start, $end];
|
||
} else if (!empty($search['create_after'])) {
|
||
$start = strtotime($search['create_after']);
|
||
$where[] = ['>=', 'create_at', $start];
|
||
} else if (!empty($search['create_before'])) {
|
||
$end = strtotime($search['create_before']);
|
||
$where[] = ['<=', 'create_at', $end];
|
||
}
|
||
if ($search['title']) {
|
||
$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'];
|
||
}
|
||
|
||
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
|
||
$data = [
|
||
'list' => $list,
|
||
'pager' => $pager,
|
||
'src' => $src,
|
||
'callback' => $callback
|
||
];
|
||
$this->result('', $data, 200);
|
||
}
|
||
}
|