controller.stub 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. {NAMESPACE}
  15. {USE}
  16. /**
  17. * {CLASS_COMMENT}
  18. * Class {UPPER_CAMEL_NAME}Controller
  19. * @package app\{MODULE_NAME}\controller{PACKAGE_NAME}
  20. */
  21. class {UPPER_CAMEL_NAME}Controller extends {EXTENDS_CONTROLLER}
  22. {
  23. /**
  24. * @notes 获取{NOTES}列表
  25. * @return \think\response\Json
  26. * @author {AUTHOR}
  27. * @date {DATE}
  28. */
  29. public function lists()
  30. {
  31. return $this->dataLists(new {UPPER_CAMEL_NAME}Lists());
  32. }
  33. /**
  34. * @notes 添加{NOTES}
  35. * @return \think\response\Json
  36. * @author {AUTHOR}
  37. * @date {DATE}
  38. */
  39. public function add()
  40. {
  41. $params = (new {UPPER_CAMEL_NAME}Validate())->post()->goCheck('add');
  42. $result = {UPPER_CAMEL_NAME}Logic::add($params);
  43. if (true === $result) {
  44. return $this->success('添加成功', [], 1, 1);
  45. }
  46. return $this->fail({UPPER_CAMEL_NAME}Logic::getError());
  47. }
  48. /**
  49. * @notes 编辑{NOTES}
  50. * @return \think\response\Json
  51. * @author {AUTHOR}
  52. * @date {DATE}
  53. */
  54. public function edit()
  55. {
  56. $params = (new {UPPER_CAMEL_NAME}Validate())->post()->goCheck('edit');
  57. $result = {UPPER_CAMEL_NAME}Logic::edit($params);
  58. if (true === $result) {
  59. return $this->success('编辑成功', [], 1, 1);
  60. }
  61. return $this->fail({UPPER_CAMEL_NAME}Logic::getError());
  62. }
  63. /**
  64. * @notes 删除{NOTES}
  65. * @return \think\response\Json
  66. * @author {AUTHOR}
  67. * @date {DATE}
  68. */
  69. public function delete()
  70. {
  71. $params = (new {UPPER_CAMEL_NAME}Validate())->post()->goCheck('delete');
  72. {UPPER_CAMEL_NAME}Logic::delete($params);
  73. return $this->success('删除成功', [], 1, 1);
  74. }
  75. /**
  76. * @notes 获取{NOTES}详情
  77. * @return \think\response\Json
  78. * @author {AUTHOR}
  79. * @date {DATE}
  80. */
  81. public function detail()
  82. {
  83. $params = (new {UPPER_CAMEL_NAME}Validate())->goCheck('detail');
  84. $result = {UPPER_CAMEL_NAME}Logic::detail($params);
  85. return $this->data($result);
  86. }
  87. }