Category.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\controller\platform;
  10. use app\admin\controller\Auth;
  11. use mall\response\Response;
  12. use think\facade\Request;
  13. use think\facade\View;
  14. use app\admin\service\platform\Category as CategoryService;
  15. class Category extends Auth {
  16. /**
  17. * 列表
  18. * @return string|\think\response\Json
  19. * @throws \think\db\exception\DataNotFoundException
  20. * @throws \think\db\exception\DbException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. */
  23. public function index(){
  24. if(Request::isAjax()) {
  25. $list = CategoryService::getList(Request::param(),["pid"=>0,"module"=>"article"]);
  26. return Response::returnArray("ok",0,$list['data'],$list['count']);
  27. }
  28. return View::fetch();
  29. }
  30. /**
  31. * 编辑
  32. * @return string|\think\response\Json
  33. */
  34. public function editor(){
  35. try {
  36. if(Request::isAjax()){
  37. $data = Request::post();
  38. $data["module"] = "article";
  39. CategoryService::save($data);
  40. return Response::returnArray("操作成功!");
  41. }
  42. return View::fetch("",CategoryService::detail(Request::param("id","0","intval"),["status"=>0,"module"=>"article"]));
  43. }catch (\Exception $ex){
  44. return Response::returnArray($ex->getMessage(),0);
  45. }
  46. }
  47. /**
  48. * 删除
  49. * @return \think\response\Json
  50. */
  51. public function delete(){
  52. try{
  53. CategoryService::deleteArchives(Request::param("id"));
  54. return Response::returnArray("删除成功");
  55. }catch (\Exception $ex){
  56. return Response::returnArray("操作失败,请稍候在试。",0);
  57. }
  58. }
  59. /**
  60. * 编辑字段
  61. * @return \think\response\Json
  62. */
  63. public function field(){
  64. try {
  65. CategoryService::setFields();
  66. return Response::returnArray("操作成功");
  67. } catch (\Exception $ex) {
  68. return Response::returnArray($ex->getMessage(),0);
  69. }
  70. }
  71. }