Archives.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 think\facade\Request;
  12. use mall\response\Response;
  13. use think\facade\View;
  14. use app\admin\service\platform\Archives as ArchivesService;
  15. use app\admin\service\platform\Category as CategoryService;
  16. class Archives extends Auth {
  17. /**
  18. * 列表
  19. * @return string|\think\response\Json
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\DbException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. */
  24. public function index(){
  25. if(Request::isAjax()){
  26. $result = ArchivesService::getList(Request::param());
  27. return Response::returnArray("ok",0,$result["data"],$result["count"]);
  28. }
  29. return View::fetch("",[ "cat"=>CategoryService::getTree(["status"=>0,"module"=>"article"]) ]);
  30. }
  31. /**
  32. * 编辑
  33. * @return string|\think\response\Json
  34. */
  35. public function editor(){
  36. try{
  37. if(Request::isAjax()){
  38. ArchivesService::save(Request::post());
  39. return Response::returnArray("操作成功!");
  40. }else{
  41. return View::fetch("",ArchivesService::detail(Request::param("id","0","intval")));
  42. }
  43. }catch (\Exception $ex){
  44. return Response::returnArray("操作失败,请重试。",0);
  45. }
  46. }
  47. /**
  48. * 删除
  49. * @return \think\response\Json
  50. */
  51. public function delete(){
  52. try {
  53. ArchivesService::delete(Request::get("id","0","intval"));
  54. return Response::returnArray("删除成功");
  55. }catch (\Exception $ex){
  56. return Response::returnArray($ex->getMessage(),0);
  57. }
  58. }
  59. /**
  60. * 更新字段
  61. * @return \think\response\Json
  62. */
  63. public function field(){
  64. try {
  65. ArchivesService::setFields();
  66. return Response::returnArray("操作成功");
  67. } catch (\Exception $ex) {
  68. return Response::returnArray($ex->getMessage(),0);
  69. }
  70. }
  71. }