BannerLogic.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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\banner;
  20. use app\common\enum\DefaultEnum;
  21. use app\common\enum\YesNoEnum;
  22. use app\common\model\GoodsBrand;
  23. use app\common\model\Banner;
  24. class BannerLogic
  25. {
  26. /**
  27. * @notes 添加轮播图
  28. * @param $params
  29. * @return bool
  30. * @author ljj
  31. * @date 2021/7/14 5:00
  32. */
  33. public function add($params)
  34. {
  35. $banner = new Banner;
  36. $banner->type = $params['type'];
  37. $banner->image = $params['image'] ?? '';
  38. $banner->sort = (isset($params['sort']) && !empty($params['sort'])) ? $params['sort'] : 1;
  39. $banner->status = $params['status'] ?? YesNoEnum::YES;
  40. return $banner->save();
  41. }
  42. /**
  43. * @notes 删除轮播图
  44. * @param $params
  45. * @return bool
  46. * @author ljj
  47. * @date 2021/7/15 10:37
  48. */
  49. public function del($params)
  50. {
  51. return Banner::destroy($params['id']);
  52. }
  53. /**
  54. * @notes 编辑轮播图
  55. * @param $params
  56. * @return bool
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\DbException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. * @author ljj
  61. * @date 2021/7/15 11:05
  62. */
  63. public function edit($params)
  64. {
  65. $banner = Banner::find($params['id']);
  66. $banner->type = $params['type'];
  67. $banner->image = $params['image'] ?? '';
  68. $banner->sort = (isset($params['sort']) && !empty($params['sort'])) ? $params['sort'] : 1;
  69. $banner->status = $params['status'] ?? YesNoEnum::YES;
  70. return $banner->save();
  71. }
  72. /**
  73. * @notes 修改轮播图状态
  74. * @param $params
  75. * @return bool
  76. * @throws \think\db\exception\DataNotFoundException
  77. * @throws \think\db\exception\DbException
  78. * @throws \think\db\exception\ModelNotFoundException
  79. * @author ljj
  80. * @date 2021/7/15 11:41
  81. */
  82. public function status($params)
  83. {
  84. $Banner = Banner::find($params['id']);
  85. $Banner->status = $params['status'];
  86. return $Banner->save();
  87. }
  88. /**
  89. * @notes 查看轮播图详情
  90. * @param $params
  91. * @return array
  92. * @throws \think\db\exception\DataNotFoundException
  93. * @throws \think\db\exception\DbException
  94. * @throws \think\db\exception\ModelNotFoundException
  95. * @author ljj
  96. * @date 2021/7/19 4:45 下午
  97. */
  98. public function detail($params)
  99. {
  100. return Banner::find($params['id'])->toArray();
  101. }
  102. }