截流自动化的商城平台
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.

Level.php 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\common\basics\AdminBase;
  4. use app\common\server\ConfigServer;
  5. use app\common\server\JsonServer;
  6. use think\exception\ValidateException;
  7. use app\admin\validate\user\LevelValidate;
  8. use app\admin\logic\user\LevelLogic;
  9. class Level extends AdminBase
  10. {
  11. public function lists()
  12. {
  13. if($this->request->isAjax()){
  14. $get = $this->request->get();
  15. $lists = LevelLogic::lists($get);
  16. return JsonServer::success('', $lists);
  17. }
  18. return view();
  19. }
  20. public function add()
  21. {
  22. if($this->request->isAjax()) {
  23. try{
  24. $post = $this->request->post();
  25. validate(LevelValidate::class)->scene('add')->check($post);
  26. }catch(ValidateException $e) {
  27. return JsonServer::error($e->getError());
  28. }
  29. $result = LevelLogic::add($post);
  30. if($result === true) {
  31. return JsonServer::success('添加成功');
  32. }
  33. return JsonServer::error(LevelLogic::getError());
  34. }
  35. return view();
  36. }
  37. public function edit(){
  38. if($this->request->isAjax()){
  39. try{
  40. $post = $this->request->post();
  41. validate(LevelValidate::class)->scene('edit')->check($post);
  42. }catch(ValidateException $e) {
  43. return JsonServer::error($e->getError());
  44. }
  45. $result = LevelLogic::edit($post);
  46. if($result === true) {
  47. return JsonServer::success('编辑成功');
  48. }
  49. return JsonServer::error(LevelLogic::getError());
  50. }
  51. $id = $this->request->get('id', '', 'intval');
  52. $detail = LevelLogic::getUserLevel($id);
  53. return view('', [
  54. 'detail' => $detail
  55. ]);
  56. }
  57. public function del()
  58. {
  59. $id = $this->request->post('id', '', 'intval');
  60. $result = LevelLogic::del($id);
  61. if($result === true) {
  62. return JsonServer::success('删除成功');
  63. }
  64. return JsonServer::error(LevelLogic::getError());
  65. }
  66. public function set()
  67. {
  68. if($this->request->isAjax()) {
  69. $post = $this->request->post();
  70. ConfigServer::set('user_level', 'intro', $post['intro']);
  71. return JsonServer::success('设置成功');
  72. }
  73. $intro = ConfigServer::get('user_level', 'intro');
  74. $intro_default = config('default.user_level.intro');
  75. return view('', [
  76. 'intro' => $intro,
  77. 'intro_default' => $intro_default
  78. ]);
  79. }
  80. }