diff --git a/.env b/.env index 2e712da..e99162b 100644 --- a/.env +++ b/.env @@ -5,11 +5,11 @@ DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql -HOSTNAME = 212.64.112.158 +HOSTNAME = 192.168.31.10 DATABASE = yunzertest USERNAME = yunzertest PASSWORD = zKMDMEs7YP3SLDEF -HOSTPORT = 3388 +HOSTPORT = 3306 CHARSET = utf8 DEBUG = true diff --git a/.gitignore b/.gitignore index 625fcdf..2ac3502 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ runtime *.log config/database.php +.env diff --git a/app/admin/controller/ResourcesController.php b/app/admin/controller/ResourcesController.php index 1c32770..fe276f7 100644 --- a/app/admin/controller/ResourcesController.php +++ b/app/admin/controller/ResourcesController.php @@ -156,9 +156,6 @@ class ResourcesController extends BaseController ]); return View::fetch(); - } catch (\Exception $e) { - Log::record('添加资源页面加载', 0, $e->getMessage(), '资源管理'); - $this->error('页面加载失败:' . $e->getMessage()); } } diff --git a/app/index/controller/ArticlesController.php b/app/index/controller/ArticlesController.php index 6d1e769..a4e5134 100644 --- a/app/index/controller/ArticlesController.php +++ b/app/index/controller/ArticlesController.php @@ -308,6 +308,65 @@ class ArticlesController extends BaseController } } + // 获取articleDetail详情 + public function getArticleDetail() + { + 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() + ]); + } + } + //文章中心 public function index() { diff --git a/app/index/controller/ProgramController.php b/app/index/controller/ProgramController.php index 2014f53..a92fd70 100644 --- a/app/index/controller/ProgramController.php +++ b/app/index/controller/ProgramController.php @@ -516,65 +516,6 @@ class ProgramController extends BaseController } } - // 获取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() { diff --git a/app/index/controller/ResourcesController.php b/app/index/controller/ResourcesController.php index cf2ab8a..1438ac8 100644 --- a/app/index/controller/ResourcesController.php +++ b/app/index/controller/ResourcesController.php @@ -32,6 +32,66 @@ use app\index\model\Articles\Articles; class ResourcesController extends BaseController { + + // 获取resourceDetail详情 + public function getResourceDetail() + { + 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() + ]); + } + } + //资源中心 public function index() { diff --git a/runtime/admin/temp/060aaf82e6a412e1d93b52eb2415c06f.php b/runtime/admin/temp/060aaf82e6a412e1d93b52eb2415c06f.php index 4f5dad4..bfa2451 100644 --- a/runtime/admin/temp/060aaf82e6a412e1d93b52eb2415c06f.php +++ b/runtime/admin/temp/060aaf82e6a412e1d93b52eb2415c06f.php @@ -1,4 +1,4 @@ - +
diff --git a/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php b/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php index 7ca37af..3c214ab 100644 --- a/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php +++ b/runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php @@ -1,4 +1,4 @@ - + @@ -106,138 +106,205 @@