优化ctms-api语法、修复已知BUG;

主要修复ctms-api、dacms对PHP新版本的支持问题
This commit is contained in:
2025-07-13 19:37:42 +08:00
parent 65bbd06981
commit 037f274ec5
413 changed files with 107271 additions and 72326 deletions
@@ -1,15 +1,23 @@
<?php
namespace backend\controllers\client\v1;
use addons\models\AcNotice;use yii\data\Pagination;
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2024-08-02T01:08:31+08:00
# @Email: 1280880631@qq.com
# @Last modified by: fm453
# @Last modified time: 2024-08-09T09:00:06+08:00
# @Copyright: www.hiluker.cn
namespace api\controllers\client\v1;
use addons\models\AcNotice;
use yii\data\Pagination;
class NoticeController extends Common
{
public function beforeAction($action)
{
if (!$this->pid) {
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
}
return parent::beforeAction($action);
}
@@ -29,18 +37,18 @@ class NoticeController extends Common
// $s = $this->search(['is_show'=>1]);
$s = $this->search();
$res = $s['res'];
if(!$res){
$this->result('没有查询到相应的数据!',[],0);
if (!$res) {
$this->result('没有查询到相应的数据!', [], 0);
}
$data = $s['data'];
$list = $this->formatList($res);
$return = [
$return = [
'total'=>$data->count(),
'notices' => $list,
'page'=>$this->page
];
$this->result('通知查询成功!',$return,200);
$this->result('通知查询成功!', $return, 200);
}
public function actionDetail()
@@ -54,7 +62,7 @@ class NoticeController extends Common
}
$model = new AcNotice();
$detail = $model->findOne($id);
$s = $this->formatDetail($detail->toArray());
$s = $this->formatDetail($detail->toArray());
$this->result('查询成功!', $s, 200);
}
@@ -66,31 +74,31 @@ class NoticeController extends Common
$params = [':pid'=>$pid];
$post = $this->postdata;
$search = isset($post['search']) ? $post['search'] : [];
// 优先处理$ops传参,并同时删除$search中相应元素
if($ops){
foreach ($ops as $key => $value) {
$where .= ' & '.$key.' = :'.$key;
$params[':'.$key] = $value;
if(isset($search[$key])){
unset($search[$key]);
}
}
}
// 优先处理$ops传参,并同时删除$search中相应元素
if ($ops) {
foreach ($ops as $key => $value) {
$where .= ' & ' . $key . ' = :' . $key;
$params[':' . $key] = $value;
if (isset($search[$key])) {
unset($search[$key]);
}
}
}
if (isset($search['title']) && !empty($search['title'])) {
$search['title'] = trim($search['title']);
$where .= ' & title like :title';
$params[':title'] = $search['title'];
$params[':title'] = $search['title'];
}
if(!isset($params[':deleted'])){
$params[':deleted'] = 0;
$where .= ' & deleted = :deleted';
}
if (!isset($params[':deleted'])) {
$params[':deleted'] = 0;
$where .= ' & deleted = :deleted';
}
$page = $this->page;
$pageSize = $this->pageSize;
$data = $model->find()->where($where,$params);
$data = $model->find()->where($where, $params);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
$pages->setPage($page-1, true); //设置分页的当前页面值
$_orderby = 'update_at DESC,id DESC';
@@ -101,15 +109,14 @@ class NoticeController extends Common
private function formatList($res)
{
$unsets = ['pid','create_at','deleted'];
$list = [];
$list = [];
foreach ($res as $s) {
$s = $s->toArray();
foreach ($unsets as $us) {
unset($s[$us]);
}
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
$wk = date('w', $s['update_at']);
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
@@ -120,16 +127,15 @@ class NoticeController extends Common
return $list;
}
private function formatDetail($s=[])
private function formatDetail($s = [])
{
$unsets = ['pid','create_at','deleted','is_show'];
foreach ($unsets as $us) {
unset($s[$us]);
}
$weekdays = [0=>'日',1=>'一',2=>'二',3=>'三',4=>'四',5=>'五',6=>'六'];
$wk = date('w', $s['update_at']);
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期'.$weekdays[$wk];
return $s;
foreach ($unsets as $us) {
unset($s[$us]);
}
$weekdays = [0 => '日', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六'];
$wk = date('w', $s['update_at']);
$s['updateTime'] = date('Y-m-d ', $s['update_at']) . '星期' . $weekdays[$wk];
return $s;
}
}
}