PcController.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\controller;
  15. use app\api\logic\PcLogic;
  16. use think\response\Json;
  17. /**
  18. * PC
  19. * Class PcController
  20. * @package app\api\controller
  21. */
  22. class PcController extends BaseApiController
  23. {
  24. public array $notNeedLogin = ['index', 'config', 'infoCenter', 'articleDetail'];
  25. /**
  26. * @notes 首页数据
  27. * @return Json
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @author 段誉
  32. * @date 2022/9/21 19:15
  33. */
  34. public function index()
  35. {
  36. $result = PcLogic::getIndexData();
  37. return $this->data($result);
  38. }
  39. /**
  40. * @notes 全局配置
  41. * @return Json
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @author 段誉
  46. * @date 2022/9/21 19:41
  47. */
  48. public function config()
  49. {
  50. $result = PcLogic::getConfigData();
  51. return $this->data($result);
  52. }
  53. /**
  54. * @notes 资讯中心
  55. * @return Json
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\DbException
  58. * @throws \think\db\exception\ModelNotFoundException
  59. * @author 段誉
  60. * @date 2022/10/19 16:55
  61. */
  62. public function infoCenter()
  63. {
  64. $result = PcLogic::getInfoCenter();
  65. return $this->data($result);
  66. }
  67. /**
  68. * @notes 获取文章详情
  69. * @return Json
  70. * @author 段誉
  71. * @date 2022/10/20 15:18
  72. */
  73. public function articleDetail()
  74. {
  75. $id = $this->request->get('id/d', 0);
  76. $source = $this->request->get('source/s', 'default');
  77. $result = PcLogic::getArticleDetail($this->userId, $id, $source);
  78. return $this->data($result);
  79. }
  80. }