批量更新租户规则

This commit is contained in:
2026-03-09 23:00:20 +08:00
parent e09b4c639c
commit e27cc8f457
45 changed files with 579 additions and 314 deletions
@@ -11,6 +11,7 @@ use think\facade\Session;
use think\response\Json;
use think\db\exception\DbException;
use app\model\Cms\Articles;
use app\model\System\AdminUser;
class ArticleController extends BaseController
{
@@ -22,18 +23,20 @@ class ArticleController extends BaseController
* @param int $pageSize 每页条数(默认10
* @return Json
*/
public function getArticlesList(string $keyword = '', string $cate = '', int $page = 1, int $pageSize = 10): Json
public function getArticlesList(string $author = '', string $keyword = '', string $cate = '', int $page = 1, int $pageSize = 10): Json
{
try {
// 安全处理参数(防止非法参数)
$page = max(1, $page); // 页码最小为1
$pageSize = max(1, min(100, $pageSize)); // 每页条数限制1-100条
$author = trim($author);
$keyword = trim($keyword);
$cate = trim($cate);
// 输出参数值
trace('查询参数:', 'debug');
trace([
'author' => $author,
'keyword' => $keyword,
'cate' => $cate,
'page' => $page,
@@ -51,6 +54,11 @@ class ArticleController extends BaseController
if ($keyword) {
$query->where('a.title', 'like', '%' . $keyword . '%');
}
// 作者筛选
if ($author) {
$query->where('a.publisher', 'like', '%' . $author . '%');
}
// 分类筛选
if ($cate) {
@@ -208,10 +216,17 @@ class ArticleController extends BaseController
public function getArticle(int $id): Json
{
try {
$article = Articles::where('id', $id)
->where('tid', $this->getTenantId())
->field('id,title,cate,image,desc,author,content,is_trans,transurl,views,likes,publisher,create_time,publish_date,update_time')
->find();
$article = Articles::alias('a')
->where('a.id', $id)
->where('a.tid', $this->getTenantId())
->leftJoin('mete_admin_user u', 'a.publisher = u.id')
->field('a.id,a.title,a.cate,a.image,a.desc,a.author,a.content,a.is_trans,a.transurl,a.views,a.likes,u.name as publisher_name,a.create_time,a.publish_date,a.update_time')
->find()
->toArray();
// 将 publisher_name 赋值给 publisher
$article['publisher'] = $article['publisher_name'] ?? '';
unset($article['publisher_name']);
if (!$article) {
return json(['code' => 404, 'msg' => '文章不存在', 'data' => null]);