DecorateDataLogic.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\adminapi\logic\decorate;
  15. use app\common\logic\BaseLogic;
  16. use app\common\model\article\Article;
  17. use app\common\model\decorate\DecoratePage;
  18. /**
  19. * 装修页-数据
  20. * Class DecorateDataLogic
  21. * @package app\adminapi\logic\decorate
  22. */
  23. class DecorateDataLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 获取文章列表
  27. * @param $limit
  28. * @return array
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\DbException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. * @author 段誉
  33. * @date 2022/9/22 16:49
  34. */
  35. public static function getArticleLists($limit): array
  36. {
  37. $field = 'id,title,desc,abstract,image,author,content,
  38. click_virtual,click_actual,create_time';
  39. return Article::where(['is_show' => 1])
  40. ->field($field)
  41. ->order(['id' => 'desc'])
  42. ->limit($limit)
  43. ->append(['click'])
  44. ->hidden(['click_virtual', 'click_actual'])
  45. ->select()->toArray();
  46. }
  47. /**
  48. * @notes pc设置
  49. * @return array
  50. * @author mjf
  51. * @date 2024/3/14 18:13
  52. */
  53. public static function pc(): array
  54. {
  55. $pcPage = DecoratePage::findOrEmpty(4)->toArray();
  56. $updateTime = !empty($pcPage['update_time']) ? $pcPage['update_time'] : date('Y-m-d H:i:s');
  57. return [
  58. 'update_time' => $updateTime,
  59. 'pc_url' => request()->domain() . '/pc'
  60. ];
  61. }
  62. }