PcDecorateThemePageLogic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\logic\theme;
  20. use app\common\{enum\PcDecorateThemePageEnum, enum\ShopPageEnum, model\PcDecorateThemePage};
  21. /**
  22. * pc装修逻辑层
  23. * Class PcDecorateThemePageLogic
  24. * @package app\adminapi\logic\theme
  25. */
  26. class PcDecorateThemePageLogic
  27. {
  28. /**
  29. * @notes 获取首页
  30. * @return array
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\DbException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. * @author cjhao
  35. * @date 2021/11/30 11:59
  36. */
  37. public function index()
  38. {
  39. $index = PcDecorateThemePage::where(['type'=>PcDecorateThemePageEnum::TYPE_HOME])->field('id,name,create_time,update_time')
  40. ->find()
  41. ->toArray();
  42. //todo 暂时拿当前域名
  43. $uri = request()->domain().'/pc';
  44. return [
  45. 'home' => $index,
  46. 'uri' => $uri
  47. ];
  48. }
  49. /**
  50. * @notes 获取页面
  51. * @param int $type 页面类型
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. * @author cjhao
  57. * @date 2021/11/30 12:00
  58. */
  59. public function getPage(int $type)
  60. {
  61. $page = PcDecorateThemePage::where(['type' => $type])
  62. ->field('id,name,type,content,common')
  63. ->find()
  64. ->toArray();
  65. return $page;
  66. }
  67. /**
  68. * @notes 设置页面
  69. * @param array $param
  70. * @return PcDecorateThemePage
  71. * @author cjhao
  72. * @date 2021/11/30 14:44
  73. */
  74. public function setPage(array $param)
  75. {
  76. return PcDecorateThemePage::where(['type'=>$param['type']])
  77. ->update($param);
  78. }
  79. /**
  80. * @notes 获取pc页面
  81. * @param string $type
  82. * @return array
  83. * @author cjhao
  84. * @date 2021/12/6 16:57
  85. */
  86. public function getPcPage(string $type):array
  87. {
  88. $pageList = ShopPageEnum::PC_SHOP_PAGE;
  89. $list = [];
  90. foreach ($pageList as $page){
  91. if($type === $page['type']){
  92. $list[] = $page;
  93. }
  94. }
  95. return $list;
  96. }
  97. }