更新界面详情
This commit is contained in:
@@ -11,6 +11,8 @@ use think\facade\Request;
|
||||
use app\index\model\Resources\Resources;
|
||||
use app\index\model\Resources\ResourcesCategory;
|
||||
use app\index\model\Attachments;
|
||||
use app\index\model\Users;
|
||||
use app\index\model\Articles\Articles;
|
||||
|
||||
class ProgramController extends BaseController
|
||||
{
|
||||
@@ -236,16 +238,43 @@ class ProgramController extends BaseController
|
||||
$cateName = ResourcesCategory::where('id', $program['cate'])
|
||||
->value('name');
|
||||
|
||||
// 获取作者信息
|
||||
$authorInfo = Users::where('name', $program['uploader'])->find();
|
||||
if ($authorInfo) {
|
||||
// 统计作者的文章数
|
||||
$articleCount = Articles::where('author', $program['uploader'])->count();
|
||||
// 统计作者的资源数
|
||||
$resourceCount = Resources::where('uploader', $program['uploader'])->count();
|
||||
|
||||
$authorData = [
|
||||
'avatar' => $authorInfo['avatar'] ?: '/static/images/avatar.png',
|
||||
'name' => $authorInfo['name'],
|
||||
'resource_count' => $resourceCount,
|
||||
'article_count' => $articleCount
|
||||
];
|
||||
} else {
|
||||
$authorData = [
|
||||
'avatar' => '/static/images/avatar.png',
|
||||
'name' => $program['uploader'],
|
||||
'resource_count' => 0,
|
||||
'article_count' => 0
|
||||
];
|
||||
}
|
||||
|
||||
// 获取上一个和下一个程序
|
||||
$prevProgram = Resources::where('id', '<', $id)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->where('cate', $program['cate'])
|
||||
->field(['id', 'title'])
|
||||
->order('id DESC')
|
||||
->find();
|
||||
|
||||
$nextProgram = Resources::where('id', '>', $id)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->where('cate', $program['cate'])
|
||||
->field(['id', 'title'])
|
||||
->order('id ASC')
|
||||
->find();
|
||||
|
||||
@@ -259,7 +288,6 @@ class ProgramController extends BaseController
|
||||
->field([
|
||||
'p.id',
|
||||
'p.title',
|
||||
'p.desc',
|
||||
'COALESCE(p.icon, c.icon) as icon'
|
||||
])
|
||||
->order('p.id DESC')
|
||||
@@ -273,6 +301,7 @@ class ProgramController extends BaseController
|
||||
'code' => 1,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'authorInfo' => $authorData,
|
||||
'program' => $program,
|
||||
'cateName' => $cateName,
|
||||
'prevProgram' => $prevProgram,
|
||||
@@ -284,6 +313,7 @@ class ProgramController extends BaseController
|
||||
|
||||
// 非 AJAX 请求返回视图
|
||||
View::assign([
|
||||
'authorInfo' => $authorData,
|
||||
'program' => $program,
|
||||
'cateName' => $cateName,
|
||||
'prevProgram' => $prevProgram,
|
||||
|
||||
Reference in New Issue
Block a user