ProPch.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\service\GridService;
  5. use app\service\ProPchService;
  6. use app\validate\GridAdd;
  7. use app\validate\Id;
  8. use app\validate\ProPchAdd;
  9. use think\db\exception\DataNotFoundException;
  10. use think\db\exception\DbException;
  11. use think\db\exception\ModelNotFoundException;
  12. use think\annotation\Route;
  13. use think\annotation\route\Middleware;
  14. use hg\apidoc\annotation as Apidoc;
  15. use think\exception\ValidateException;
  16. use think\response\Json;
  17. /**
  18. * @Apidoc\Title("批次号信息")
  19. * @Apidoc\Group("pch")
  20. * @Apidoc\Sort(16)
  21. */
  22. class ProPch extends BaseController
  23. {
  24. use ResponseJson;
  25. //新增方法
  26. /**
  27. * @Apidoc\Author("ruicu")
  28. * @throws ModelNotFoundException
  29. * @throws DataNotFoundException
  30. * @throws DbException
  31. * @Apidoc\Title("生成批次号信息")
  32. * @Apidoc\Tag("生成批次号信息")
  33. * @Apidoc\Method ("POST")
  34. * @Route("/addpch",method="POST")
  35. * @Middleware({"jwt"})
  36. */
  37. public function addGrid(): Json
  38. {
  39. $info = $this->request->post();
  40. try {
  41. validate(ProPchAdd::class)->check($info);
  42. $info['creation_time'] = date('Y-m-d h:i:s', time());
  43. $info['last_update_time'] = date('Y-m-d h:i:s', time());
  44. $result = ProPchService::addProPch($info,$this->uuid());
  45. if (!$result){
  46. return $this->JsonError(1002);
  47. }
  48. }catch (ValidateException $e){
  49. return $this->JsonError($e->getError(),0);
  50. }
  51. return $this->JsonResponse(200,"success","");
  52. }
  53. }