增加程序详情相关接口
This commit is contained in:
parent
2e89705815
commit
acf9bc0952
@ -65,7 +65,7 @@ class ProgramController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取officeResources内容,传参
|
||||
// 获取officeResources内容
|
||||
public function getOfficeResourcesLists()
|
||||
{
|
||||
try {
|
||||
@ -136,7 +136,112 @@ class ProgramController extends BaseController
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
//$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
|
||||
// 获取分类名称
|
||||
$resourceCategory = ResourcesCategory::where('id', $resource['cate'])->find();
|
||||
$resource['category_name'] = $resourceCategory ? $resourceCategory['name'] : '';
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'category' => [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'desc' => $category['desc'],
|
||||
'image' => $category['image']
|
||||
],
|
||||
'resources' => $resources,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'total_pages' => ceil($total / $limit)
|
||||
]
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '获取失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取officeResources内容
|
||||
public function getOfficeResourcesSimpleLists()
|
||||
{
|
||||
try {
|
||||
// 获取前端传递的分类ID
|
||||
$cateid = input('cateid/d', 0);
|
||||
|
||||
// 验证分类ID
|
||||
if ($cateid <= 0) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '分类ID不能为空'
|
||||
]);
|
||||
}
|
||||
|
||||
// 检查分类是否存在且有效
|
||||
$category = ResourcesCategory::where('id', $cateid)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->find();
|
||||
|
||||
if (!$category) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '分类不存在或已禁用'
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取分页参数
|
||||
$page = input('page/d', 1);
|
||||
$limit = input('limit/d', 10);
|
||||
|
||||
// 获取该分类下的所有子分类ID(包括自身)
|
||||
$subCategoryIds = [$cateid];
|
||||
|
||||
// 查找所有子分类
|
||||
$subCategories = ResourcesCategory::where('cid', $cateid)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->column('id');
|
||||
|
||||
if (!empty($subCategories)) {
|
||||
$subCategoryIds = array_merge($subCategoryIds, $subCategories);
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
$where = [
|
||||
['delete_time', '=', null],
|
||||
['status', '=', 1], // 已发布的文章
|
||||
['cate', 'in', $subCategoryIds]
|
||||
];
|
||||
|
||||
// 查询文章总数
|
||||
$total = Resources::where($where)->count();
|
||||
|
||||
// 查询文章列表
|
||||
$resources = Resources::where($where)
|
||||
->field('id,title,cate,icon,views,downloads,create_time')
|
||||
->order('sort DESC, id DESC')
|
||||
->page($page, $limit)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理文章数据
|
||||
foreach ($resources as &$resource) {
|
||||
// 如果文章没有封面图,使用分类封面图
|
||||
if (empty($resource['icon'])) {
|
||||
$resource['icon'] = $category['icon'] ?? '';
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
|
||||
// 获取分类名称
|
||||
$resourceCategory = ResourcesCategory::where('id', $resource['cate'])->find();
|
||||
@ -202,7 +307,7 @@ class ProgramController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取downloadPrograms内容,传参
|
||||
// 获取downloadPrograms内容
|
||||
public function getDownloadProgramsLists()
|
||||
{
|
||||
try {
|
||||
@ -273,7 +378,7 @@ class ProgramController extends BaseController
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
//$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
|
||||
// 获取分类名称
|
||||
$resourceCategory = ResourcesCategory::where('id', $resource['cate'])->find();
|
||||
@ -307,6 +412,169 @@ class ProgramController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 获取downloadPrograms内容
|
||||
public function getDownloadProgramsSimpleLists()
|
||||
{
|
||||
try {
|
||||
// 获取前端传递的分类ID
|
||||
$cateid = input('cateid/d', 0);
|
||||
|
||||
// 验证分类ID
|
||||
if ($cateid <= 0) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '分类ID不能为空'
|
||||
]);
|
||||
}
|
||||
|
||||
// 检查分类是否存在且有效
|
||||
$category = ResourcesCategory::where('id', $cateid)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->find();
|
||||
|
||||
if (!$category) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '分类不存在或已禁用'
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取分页参数
|
||||
$page = input('page/d', 1);
|
||||
$limit = input('limit/d', 10);
|
||||
|
||||
// 获取该分类下的所有子分类ID(包括自身)
|
||||
$subCategoryIds = [$cateid];
|
||||
|
||||
// 查找所有子分类
|
||||
$subCategories = ResourcesCategory::where('cid', $cateid)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->column('id');
|
||||
|
||||
if (!empty($subCategories)) {
|
||||
$subCategoryIds = array_merge($subCategoryIds, $subCategories);
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
$where = [
|
||||
['delete_time', '=', null],
|
||||
['status', '=', 1], // 已发布的文章
|
||||
['cate', 'in', $subCategoryIds]
|
||||
];
|
||||
|
||||
// 查询文章总数
|
||||
$total = Resources::where($where)->count();
|
||||
|
||||
// 查询文章列表
|
||||
$resources = Resources::where($where)
|
||||
->field('id,title,cate,icon,views,downloads,create_time')
|
||||
->order('sort DESC, id DESC')
|
||||
->page($page, $limit)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理文章数据
|
||||
foreach ($resources as &$resource) {
|
||||
// 如果文章没有封面图,使用分类封面图
|
||||
if (empty($resource['icon'])) {
|
||||
$resource['icon'] = $category['icon'] ?? '';
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
|
||||
// 获取分类名称
|
||||
$resourceCategory = ResourcesCategory::where('id', $resource['cate'])->find();
|
||||
$resource['category_name'] = $resourceCategory ? $resourceCategory['name'] : '';
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'category' => [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'image' => $category['image']
|
||||
],
|
||||
'resources' => $resources,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'total_pages' => ceil($total / $limit)
|
||||
]
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '获取失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取downloadPrograms详情
|
||||
public function getDownloadProgramsDetail()
|
||||
{
|
||||
try {
|
||||
// 获取前端传递的ID
|
||||
$id = input('id/d', 0);
|
||||
|
||||
// 验证ID
|
||||
if ($id <= 0) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => 'ID参数错误'
|
||||
]);
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
$where = [
|
||||
['r.id', '=', $id],
|
||||
['r.delete_time', '=', null],
|
||||
['r.status', '=', 1], // 已审核的资源
|
||||
['r.push', '=', 1], // 已推送的资源
|
||||
];
|
||||
|
||||
// 查询资源详情,联查分类名称
|
||||
$resource = Resources::where($where)
|
||||
->field('r.id,r.title,r.cate,r.icon,r.price,r.code,r.desc,r.number,r.content,r.views,r.downloads,r.create_time,r.update_time,r.url,r.fileurl,c.name as cate_name')
|
||||
->alias('r')
|
||||
->join('resources_category c', 'r.cate = c.id')
|
||||
->find();
|
||||
|
||||
if (!$resource) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '资源不存在或已删除'
|
||||
]);
|
||||
}
|
||||
|
||||
// 转换为数组并处理数据
|
||||
$resource = $resource->toArray();
|
||||
|
||||
// 将cate字段替换为分类名称
|
||||
$resource['cate'] = $resource['cate_name'];
|
||||
unset($resource['cate_name']);
|
||||
|
||||
// 返回数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => $resource
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '获取失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取downloadGames分类
|
||||
public function getDownloadGamesCategory()
|
||||
{
|
||||
@ -339,7 +607,7 @@ class ProgramController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取downloadGames内容,传参
|
||||
// 获取downloadGames内容
|
||||
public function getDownloadGamesLists()
|
||||
{
|
||||
try {
|
||||
@ -410,7 +678,112 @@ class ProgramController extends BaseController
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
//$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
|
||||
// 获取分类名称
|
||||
$resourceCategory = ResourcesCategory::where('id', $resource['cate'])->find();
|
||||
$resource['category_name'] = $resourceCategory ? $resourceCategory['name'] : '';
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'category' => [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'desc' => $category['desc'],
|
||||
'image' => $category['image']
|
||||
],
|
||||
'resources' => $resources,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'total_pages' => ceil($total / $limit)
|
||||
]
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '获取失败:' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取downloadGames内容
|
||||
public function getDownloadGamesSimpleLists()
|
||||
{
|
||||
try {
|
||||
// 获取前端传递的分类ID
|
||||
$cateid = input('cateid/d', 0);
|
||||
|
||||
// 验证分类ID
|
||||
if ($cateid <= 0) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '分类ID不能为空'
|
||||
]);
|
||||
}
|
||||
|
||||
// 检查分类是否存在且有效
|
||||
$category = ResourcesCategory::where('id', $cateid)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->find();
|
||||
|
||||
if (!$category) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '分类不存在或已禁用'
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取分页参数
|
||||
$page = input('page/d', 1);
|
||||
$limit = input('limit/d', 10);
|
||||
|
||||
// 获取该分类下的所有子分类ID(包括自身)
|
||||
$subCategoryIds = [$cateid];
|
||||
|
||||
// 查找所有子分类
|
||||
$subCategories = ResourcesCategory::where('cid', $cateid)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->column('id');
|
||||
|
||||
if (!empty($subCategories)) {
|
||||
$subCategoryIds = array_merge($subCategoryIds, $subCategories);
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
$where = [
|
||||
['delete_time', '=', null],
|
||||
['status', '=', 1], // 已发布的文章
|
||||
['cate', 'in', $subCategoryIds]
|
||||
];
|
||||
|
||||
// 查询文章总数
|
||||
$total = Resources::where($where)->count();
|
||||
|
||||
// 查询文章列表
|
||||
$resources = Resources::where($where)
|
||||
->field('id,title,cate,icon,views,downloads,create_time')
|
||||
->order('sort DESC, id DESC')
|
||||
->page($page, $limit)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理文章数据
|
||||
foreach ($resources as &$resource) {
|
||||
// 如果文章没有封面图,使用分类封面图
|
||||
if (empty($resource['icon'])) {
|
||||
$resource['icon'] = $category['icon'] ?? '';
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
$resource['create_time'] = date('Y-m-d H:i:s', strtotime($resource['create_time']));
|
||||
|
||||
// 获取分类名称
|
||||
$resourceCategory = ResourcesCategory::where('id', $resource['cate'])->find();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:5:{s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\program\detail.php";i:1749891766;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\head.php";i:1747617129;s:71:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header-simple.php";i:1749258723;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1749170849;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\foot.php";i:1747616844;}*/ ?>
|
||||
<?php /*a:5:{s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\program\detail.php";i:1754754606;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\head.php";i:1754756468;s:71:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header-simple.php";i:1766456641;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1750323451;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\foot.php";i:1750323451;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@ -10,8 +10,10 @@
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/css/fontawesome.css">
|
||||
<link rel="stylesheet" href="/static/css/all.min.css">
|
||||
|
||||
<script src="/static/layui/layui.js" charset="utf-8"></script>
|
||||
<script src="/static/js/all.min.js"></script>
|
||||
<script src="/static/js/bootstrap.bundle.js"></script>
|
||||
<script charset="UTF-8" id="LA_COLLECT" src="//www.yunzer.cn/plugins/js-sdk-pro.min.js"></script>
|
||||
<script>LA.init({ id: "KoyzaWWEcLvPzkQn", ck: "KoyzaWWEcLvPzkQn", autoTrack: true, prefix: 'event' })</script>
|
||||
@ -1716,8 +1718,7 @@ $loginStatus = [
|
||||
|
||||
.disclaimers {
|
||||
color: #b1b1b1;
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
margin: 20px 0;
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user