Gridperson.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. namespace app\controller;
  3. use app\BaseController;
  4. use app\service\EnterprisesService;
  5. use app\service\UserService;
  6. use app\validate\Page;
  7. use think\db\exception\DataNotFoundException;
  8. use think\db\exception\DbException;
  9. use think\db\exception\ModelNotFoundException;
  10. use think\exception\ValidateException;
  11. use think\response\Json;
  12. use think\annotation\Route;
  13. use think\annotation\route\Middleware;
  14. use hg\apidoc\annotation as Apidoc;
  15. /**
  16. * @Apidoc\Title("网格监管人员信息")
  17. * @Apidoc\Group("gridperson")
  18. * @Apidoc\Sort(2)
  19. */
  20. class Gridperson extends BaseController
  21. {
  22. use ResponseJson;
  23. /**
  24. * @Apidoc\Author("yang")
  25. * @throws ModelNotFoundException
  26. * @throws DataNotFoundException
  27. * @throws DbException
  28. * @Apidoc\Title("获取网格人员信息")
  29. * @Apidoc\Tag("网格人员查询")
  30. * @Apidoc\Method ("POST")
  31. * @Route("/getgridpersoninfolist",method="POST")
  32. * @Middleware({"jwt"})
  33. */
  34. public function getGridPersonInfoList(): Json{
  35. $page = $this->request->post();
  36. try {
  37. validate(Page::class)->check($page);
  38. }catch (ValidateException $e){
  39. $page["page"]=1;
  40. $page["size"] = 10;
  41. }
  42. try {
  43. return $this->JsonSucess(UserService::getUserInfoList($page, getXzqdmSub()));
  44. } catch (DataNotFoundException|ModelNotFoundException|DbException $dbE) {
  45. return $this->JsonError($dbE);
  46. }
  47. }
  48. /**
  49. * @Apidoc\Author("yang")
  50. * @throws ModelNotFoundException
  51. * @throws DataNotFoundException
  52. * @throws DbException
  53. * @Apidoc\Title("网格人员信息添加")
  54. * @Apidoc\Tag("网格人员")
  55. * @Apidoc\Method ("POST")
  56. * @Route("/addgridperson",method="POST")
  57. * @Middleware({"jwt"})
  58. */
  59. public function addGridPerson(): Json{
  60. $data = $this->request->post();
  61. try {
  62. //validate(gridPersonInfo::class)->check($data);
  63. $data['creation_time'] = date('Y-m-d h:i:s', time());
  64. return $this->JsonSucess(UserService::saveUserInfo($data));
  65. }catch (ValidateException $e){
  66. return $this->JsonError($e->getError());
  67. }
  68. }
  69. /**
  70. * @Apidoc\Author("yang")
  71. * @throws ModelNotFoundException
  72. * @throws DataNotFoundException
  73. * @throws DbException
  74. * @Apidoc\Title("通过id获取网格人员信息")
  75. * @Apidoc\Tag("网格人员")
  76. * @Apidoc\Method ("GET")
  77. * @Route("/getgridpersonbyid",method="GET")
  78. * @Middleware({"jwt"})
  79. */
  80. public function getGridPersoninfoById(): Json{
  81. $data = $this->request->get();
  82. try {
  83. //validate(gridPersonInfo::class)->check($data);
  84. return $this->JsonSucess(UserService::getgridpersonInfoById($data['id']));
  85. }catch (ValidateException $e){
  86. return $this->JsonError($e->getError());
  87. }
  88. }
  89. /**
  90. * @Apidoc\Author("yang")
  91. * @throws ModelNotFoundException
  92. * @throws DataNotFoundException
  93. * @throws DbException
  94. * @Apidoc\Title("网格人员信息修改")
  95. * @Apidoc\Tag("网格人员")
  96. * @Apidoc\Method ("POST")
  97. * @Route("/editgridperson",method="POST")
  98. * @Middleware({"jwt"})
  99. */
  100. public function editGridPersoninfoById(): Json{
  101. $data = $this->request->post();
  102. try {
  103. //validate(gridPersonInfo::class)->check($data);
  104. $data['last_update_time'] = date('Y-m-d h:i:s', time());
  105. return $this->JsonSucess(UserService::editUserInfoById($data['id'],$data));
  106. }catch (ValidateException $e){
  107. return $this->JsonError($e->getError());
  108. }
  109. }
  110. /**
  111. * @Apidoc\Author("yang")
  112. * @throws ModelNotFoundException
  113. * @throws DataNotFoundException
  114. * @throws DbException
  115. * @Apidoc\Title("通过id删除网格人员信息")
  116. * @Apidoc\Tag("网格人员")
  117. * @Apidoc\Method ("GET")
  118. * @Route("/deletegridperson",method="GET")
  119. * @Middleware({"jwt"})
  120. */
  121. public function deleteGridPersoninfoById(): Json{
  122. $data = $this->request->get();
  123. try {
  124. //validate(gridPersonInfo::class)->check($data);
  125. $data['last_update_time'] = date('Y-m-d h:i:s', time());
  126. return $this->JsonSucess(UserService::deleteUserInfoById($data['id']));
  127. }catch (ValidateException $e){
  128. return $this->JsonError($e->getError());
  129. }
  130. }
  131. }