截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NoticeSetting.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\admin\controller\setting;
  20. use app\admin\logic\NoticeSettingLogic;
  21. use app\common\basics\AdminBase;
  22. use app\common\enum\NoticeEnum;
  23. use app\common\server\JsonServer;
  24. use think\Db;
  25. /**
  26. * 通知设置
  27. * Class NoticeSetting
  28. * @package app\admin\controller\setting
  29. */
  30. class NoticeSetting extends AdminBase
  31. {
  32. /**
  33. * Notes: 消息设置列表
  34. * @author 段誉(2021/4/27 17:17)
  35. * @return mixed
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. * @throws \think\exception\DbException
  39. */
  40. public function index()
  41. {
  42. if ($this->request->isAjax()) {
  43. $get = $this->request->get();
  44. $type = $get['type'] ?? NoticeEnum::NOTICE_USER;
  45. return JsonServer::success('获取成功', NoticeSettingLogic::lists($type));
  46. }
  47. return view();
  48. }
  49. /**
  50. * Notes: 设置系统通知模板
  51. * @author 段誉(2021/4/27 17:18)
  52. * @return mixed
  53. * @throws \think\Exception
  54. * @throws \think\exception\PDOException
  55. */
  56. public function set()
  57. {
  58. $id = $this->request->get('id');
  59. $type = $this->request->get('type');
  60. if ($this->request->isAjax()) {
  61. $post = $this->request->post();
  62. NoticeSettingLogic::set($post);
  63. return JsonServer::success('操作成功');
  64. }
  65. return view('set_'.$type, [
  66. 'info' => NoticeSettingLogic::info($id, $type),
  67. 'type' => $type
  68. ]);
  69. }
  70. /**
  71. * 通知记录
  72. */
  73. public function record()
  74. {
  75. if($this->request->isAjax()) {
  76. $get = $this->request->get();
  77. $data = NoticeSettingLogic::record($get);
  78. return JsonServer::success('', $data);
  79. }
  80. $param = $this->request->get();
  81. return view('', ['param' => $param]);
  82. }
  83. /**
  84. * 删除记录,直接删除(非软删除)
  85. */
  86. public function delRecord()
  87. {
  88. $id = $this->request->post('id', '', 'intval');
  89. if(empty($id)) {
  90. return JsonServer::error('参数缺失,删除失败');
  91. }
  92. $res = Db::name('notice')->delete($id);
  93. if(!$res) {
  94. return JsonServer::error('删除失败');
  95. }
  96. return JsonServer::success('删除成功');
  97. }
  98. }