Keywords.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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\Keywords as KeywordsService;
  15. class Keywords 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 = KeywordsService::getList(Request::param());
  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. KeywordsService::save(Request::param());
  38. return Response::returnArray("操作成功!");
  39. }
  40. return View::fetch("",KeywordsService::detail(Request::param("id","0","intval")));
  41. }catch (\Exception $ex){
  42. return Response::returnArray("操作失败,请重试。",0);
  43. }
  44. }
  45. /**
  46. * 删除
  47. * @return \think\response\Json
  48. */
  49. public function delete(){
  50. try {
  51. KeywordsService::delete(Request::get("id","0","intval"));
  52. return Response::returnArray("删除成功");
  53. }catch (\Exception $ex){
  54. return Response::returnArray("操作失败,请稍候在试。",0);
  55. }
  56. }
  57. /**
  58. * 编辑字段
  59. * @return \think\response\Json
  60. */
  61. public function field(){
  62. try {
  63. KeywordsService::setFields();
  64. return Response::returnArray("操作成功");
  65. }catch (\Exception $ex){
  66. return Response::returnArray($ex->getMessage(),0);
  67. }
  68. }
  69. }