代码优化

This commit is contained in:
wong
2025-12-20 10:34:09 +08:00
parent 36d6f94177
commit 3f5a2189ce

View File

@@ -559,6 +559,7 @@ class ContentLibraryController extends Controller
['companyId', '=', $companyId],
['isDel', '=', 0]
];
if (!$isAdmin) {
$libraryWhere[] = ['userId', '=', $userId];
@@ -586,8 +587,9 @@ class ContentLibraryController extends Controller
// 查询数据
$list = ContentItem::where($where)
->field('id,libraryId,type,title,content,contentAi,contentType,resUrls,urls,friendId,wechatId,wechatChatroomId,createTime,createMomentTime,createMessageTime,coverImage')
->field('id,libraryId,type,title,content,contentAi,contentType,resUrls,urls,friendId,wechatId,wechatChatroomId,createTime,createMomentTime,createMessageTime,coverImage,ossUrls')
->order('createMomentTime DESC,createTime DESC')
->group('snsId')
->page($page, $limit)
->select();
@@ -643,6 +645,12 @@ class ContentLibraryController extends Controller
// 处理JSON字段
$item['resUrls'] = json_decode($item['resUrls'] ?: [], true);
$item['urls'] = json_decode($item['urls'] ?: [], true);
$item['ossUrls'] = json_decode($item['ossUrls'] ?: [], true);
if(!empty($item['ossUrls']) && count($item['ossUrls']) > 0){
$item['resUrls'] = $item['ossUrls'];
}
// 格式化时间
if (!empty($item['createMomentTime']) && is_numeric($item['createMomentTime'])) {
@@ -674,7 +682,7 @@ class ContentLibraryController extends Controller
}
}
unset($item['contentAi']);
unset($item['contentAi'],$item['ossUrls']);
}
return json([
@@ -1314,7 +1322,7 @@ class ContentLibraryController extends Controller
}*/
// 获取最近20条朋友圈
$moments = $query->page(1, 20)->select();
$moments = $query->page(1, 100)->select();
if (empty($moments)) {
continue;
}