Good.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\attr\Permission;
  4. use app\common\util\Result;
  5. use think\annotation\route\Get;
  6. use think\annotation\route\Group;
  7. use app\common\model\Good as GoodModel;
  8. use app\admin\controller\BaseAuthorized;
  9. #[Permission('good')]
  10. #[Group('good')]
  11. class Good extends BaseAuthorized
  12. {
  13. public function page()
  14. {
  15. return $this->GoodService()->page();
  16. }
  17. #[Get(rule: 'get/name')]
  18. public function getByName($name)
  19. {
  20. return GoodModel::getByName($name) ?? Result::failed('不存在的商品');
  21. }
  22. #[Get(rule: 'get/no')]
  23. public function getByNo($no)
  24. {
  25. return GoodModel::getByNo($no) ?? Result::failed('不存在的商品');
  26. }
  27. public function create()
  28. {
  29. return $this->GoodService()->create();
  30. }
  31. public function delete()
  32. {
  33. return $this->GoodService()->delete();
  34. }
  35. public function update()
  36. {
  37. return $this->GoodService()->update();
  38. }
  39. public function template()
  40. {
  41. return download(public_path('static/execl') . 'GOOD_TEMPLATE.xlsx', '物品导入模板.xlsx');
  42. }
  43. public function import()
  44. {
  45. return $this->GoodService()->import();
  46. }
  47. public function export()
  48. {
  49. return $this->GoodService()->export();
  50. }
  51. }