Api.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <?php
  2. namespace app\common\controller;
  3. use app\BaseController;
  4. use app\common\api\EnterpriseApi;
  5. use app\common\middleware\Auth;
  6. use app\common\model\TalentChecklog;
  7. use app\common\validate\Enterprise;
  8. use think\exception\ValidateException;
  9. use think\facade\Db;
  10. use app\enterprise\api\TalentApi;
  11. use app\common\api\TalentLogApi;
  12. use app\common\api\DictApi;
  13. use app\common\model\CurrentcyFileType;
  14. use app\common\model\TalentCommonFile;
  15. use app\common\api\UploadApi;
  16. use app\common\api\TalentConditionApi;
  17. use app\common\api\CompanyApi;
  18. use app\common\api\TalentState;
  19. /**
  20. * 需要权限的公共方法放这
  21. * Description of Tool
  22. *
  23. * @author sgq
  24. */
  25. class Api extends BaseController {
  26. protected $middleware = [Auth::class];
  27. protected $user;
  28. public function __construct(\think\App $app) {
  29. parent::__construct($app);
  30. $this->user = session("user");
  31. }
  32. public function findIdentifyConditionByLevel() {
  33. $params = $this->request->param();
  34. $id = $params["id"];
  35. if ($this->user["usertype"] == 2) {
  36. $type = $this->user["type"];
  37. } else {
  38. $talentInfo = TalentApi::getOne($id);
  39. $enterprise = \app\common\model\Enterprise::findOrEmpty($talentInfo["enterprise_id"]);
  40. $type = $enterprise["type"];
  41. }
  42. $list = TalentConditionApi::getList($params["level"], $type);
  43. return json($list, 200);
  44. }
  45. public function getTalentCondtionUploadFile() {
  46. $param = $this->request->param();
  47. $id = $param["mainId"];
  48. $order = $param["order"];
  49. $project = $param["project"];
  50. $type = $param["type"];
  51. $talent_condition = $param["talent_condition"];
  52. $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
  53. if (!$condition_info["bindFileTypes"])
  54. return json(["rows" => null]);
  55. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  56. $rows = Db::table("new_common_filetype")->where($whr)->order("sn " . $order)->select()->toArray();
  57. if ($id) {
  58. foreach ($rows as $key => $row) {
  59. $where = [];
  60. $where[] = ["mainId", "=", $id];
  61. $where[] = ["typeId", "=", $row["id"]];
  62. $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
  63. foreach ($files as &$file) {
  64. $file["url"] = "/storage/" . $file["url"];
  65. }
  66. $rows[$key]["files"] = $files;
  67. }
  68. }
  69. return json(["rows" => $rows]);
  70. }
  71. public function getCheckLog() {
  72. $params = $this->request->param();
  73. $mainId = $params["mainId"];
  74. $type = $params["type"];
  75. /* $talentInfo = TalentApi::getOne($mainId);
  76. $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  77. $needDeptVerify = false;
  78. if ($condition["companyIds"] && $talentInfo["pass_dept_check"] != 1)
  79. $needDeptVerify = true; */
  80. $list = TalentLogApi::getList($type, $mainId);
  81. $new_list = [];
  82. foreach ($list as $key => $item) {
  83. switch ($item['category']) {
  84. case 'enterprise_change':
  85. switch ($item['step']) {
  86. case 100:
  87. $new_item["stepName"] = "<span class='label'>用户操作</span>";
  88. break;
  89. case 101:
  90. $new_item["stepName"] = "<span class='label label-primary'>审核</span>";
  91. break;
  92. case 102:
  93. $new_item["stepName"] = "<span class='label label-danger'>设置冻结</span>";
  94. break;
  95. case 103:
  96. $new_item["stepName"] = "<span class='label label-info'>重置密码</span>";
  97. break;
  98. }
  99. switch ($item['state']) {
  100. case 1:
  101. $new_item["stateName"] = "<span class='label label-success'>待提交</span>";
  102. break;
  103. case 2:
  104. $new_item["stateName"] = "<span class='label label-success'>待审核</span>";
  105. break;
  106. case 3:
  107. $new_item["stateName"] = "<span class='label label-danger'>审核驳回</span>";
  108. break;
  109. case 4:
  110. $new_item["stateName"] = "<span class='label label-primary'>审核通过</span>";
  111. break;
  112. case 5:
  113. $new_item["stateName"] = "<span class='label label-warm'>重新提交</span>";
  114. break;
  115. }
  116. $new_item["stateChange"] = $item['stateChange'];
  117. break;
  118. default:
  119. $new_item["stepName"] = DictApi::getCheckLogStepName($item["state"], $item["step"]);
  120. if ($item["state"] == TalentState::REVERIFY_FAIL) {
  121. $new_item["stateName"] = '<span class="label label-success">审核不通过</span>';
  122. } else if (in_array($item["state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  123. if ($item["step"] == 3) {
  124. if ($item["new_state"] == TalentState::SCND_SUBMIT) {
  125. $new_item["stateName"] = '<span class="label label-danger">审核驳回</span>';
  126. } else if ($item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  127. $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
  128. } else {
  129. $new_item["stateName"] = '<span class="label label-success">待审核</span>';
  130. }
  131. } else {
  132. $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
  133. }
  134. } else if (in_array($item["state"], [4, 8, 10, 12])) {
  135. $new_item["stateName"] = '<span class="label label-danger">审核驳回</span>';
  136. } else {
  137. $new_item["stateName"] = '<span class="label label-success">待审核</span>';
  138. }
  139. if ($item["step"] == 3) {
  140. $company = CompanyApi::getOne($item["companyId"]);
  141. if ($item["active"] == 0) {
  142. $new_item["stateChange"] = str_replace("部门", '"' . $company["name"] . '"', DictApi::getTalentInfoStateName($item["state"], $item["step"]));
  143. } else {
  144. $new_item["stateChange"] = sprintf("%s -> %s", str_replace("部门", '"' . $company["name"] . '"', DictApi::getTalentInfoStateName($item["state"], $item["step"])), DictApi::getTalentInfoStateName($item["new_state"], $item["step"]));
  145. }
  146. } else {
  147. if ($item["last_state"] && $item["new_state"]) {
  148. $new_item["stateChange"] = sprintf("%s -> %s", DictApi::getTalentInfoStateName($item["last_state"], $list[$key + 1]["step"]), DictApi::getTalentInfoStateName($item["new_state"], $list[$key - 1]["step"], $item["last_state"]));
  149. } else {
  150. $new_item["stateChange"] = "";
  151. }
  152. }
  153. break;
  154. }
  155. $new_item["description"] = $item["description"];
  156. $new_item["createUser"] = $item["updateUser"] ?: $item["createUser"];
  157. $new_item["createTime"] = $item["updateTime"] ?: $item["createTime"];
  158. $new_list[] = $new_item;
  159. }
  160. return json(["rows" => $new_list]);
  161. }
  162. public function findCommonFileType() {
  163. $param = $this->request->param();
  164. $id = $param["mainId"];
  165. $order = $param["order"];
  166. $project = $param["project"];
  167. $type = $param["type"];
  168. $checkState = $param["checkState"];
  169. $talent_condition = $param["talent_condition"];
  170. if (in_array($checkState, [-1, 0, 1, 2])) {
  171. $where[] = ["step", "=", 1]; //只查找人才第一步所需文件
  172. } else {
  173. $where[] = ["isConditionFile", "=", 0]; //排除人才条件上传文件
  174. }
  175. $where[] = ["project", "=", $project];
  176. $where[] = ["type", "=", $type];
  177. if ($talent_condition) {
  178. $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
  179. if ($condition_info["bindFileTypes"]) {
  180. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  181. }
  182. }
  183. if ($whr) {
  184. $rows = Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn " . $order)->select()->toArray();
  185. } else {
  186. $rows = Db::table("new_common_filetype")->where($where)->order("sn " . $order)->select()->toArray();
  187. }
  188. if ($id) {
  189. foreach ($rows as $key => $row) {
  190. $where = [];
  191. $where[] = ["mainId", "=", $id];
  192. $where[] = ["typeId", "=", $row["id"]];
  193. $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
  194. foreach ($files as &$file) {
  195. $file["url"] = "/storage/" . $file["url"];
  196. }
  197. $rows[$key]["files"] = $files;
  198. }
  199. }
  200. return json(["rows" => $rows]);
  201. }
  202. public function listTalentFile() {
  203. $param = $this->request->param();
  204. $mainId = $param["mainId"];
  205. $typeId = $param["fileTypeId"];
  206. $where = [["mainId", "=", $mainId], ["typeId", "=", $typeId]];
  207. $list = Db::table("new_talent_file")->where($where)->select()->toArray();
  208. foreach ($list as $key => $item) {
  209. $list[$key]["url"] = "/storage/" . $item["url"]; //获取系统配置无效,暂时这样
  210. }
  211. return json($list);
  212. }
  213. public function addTalentFile() {
  214. $backName = $this->request->param("backName");
  215. $fileId = $this->request->param("fileId");
  216. $mainId = $this->request->param("mainId");
  217. $fileTypeId = $this->request->param("fileTypeId");
  218. $index = $this->request->param("index");
  219. $type = $this->request->param("type");
  220. $upload = new \app\common\api\UploadApi();
  221. $file = $this->request->file("fileUrl");
  222. if (!TalentApi::checkIsEditable($mainId)) {
  223. $res = ["msg" => "当前状态不能修改附件", "obj" => $index];
  224. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  225. exit();
  226. }
  227. $mime = $file->getMime();
  228. switch ($mime) {
  229. case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"://xlsx
  230. case "application/pdf"://pdf
  231. case "application/vnd.ms-excel"://xls
  232. $filestd = $upload->uploadOne($file, "file", "talent_files");
  233. break;
  234. case "image/jpg":
  235. case "image/jpeg":
  236. case "image/png":
  237. case "image/gif":
  238. $filestd = $upload->uploadOne($file, "image", "talent_files");
  239. break;
  240. default:
  241. $res = ["msg" => "不支持的附件类型", "obj" => $index];
  242. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  243. exit();
  244. break;
  245. }
  246. $change = false;
  247. if ($fileId) {
  248. if (!$this->chkIsFileOwner($mainId, $type)) {
  249. $res = ["msg" => "删除失败", "obj" => $index];
  250. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  251. exit();
  252. }
  253. $old = Db::table("new_talent_file")->findOrEmpty($fileId);
  254. $old_filepath = "storage/" . $old["url"];
  255. if (file_exists($old_filepath))
  256. unlink($old_filepath);
  257. $data["id"] = $fileId;
  258. $change = true;
  259. }
  260. $data["mainId"] = $mainId;
  261. $data["type"] = $type;
  262. $data["typeId"] = $fileTypeId;
  263. $data["orignName"] = $file->getOriginalName();
  264. $data["url"] = $filestd->filepath;
  265. $data["sn"] = $index;
  266. $data["createTime"] = time();
  267. if ($fileId) {
  268. Db::table("new_talent_file")->save($data);
  269. } else {
  270. $fileId = Db::table("new_talent_file")->insertGetId($data);
  271. }
  272. TalentLogApi::write($type, $mainId, 0, sprintf("%s附件,附件名为:%s", $change ? "修改" : "添加", $data["orignName"]), 1, $fileTypeId, $fileId);
  273. $res = ["code" => 200, "msg" => "上传附件成功", "obj" => $index, "info" => "/storage/" . $filestd->filepath, "typeId" => $fileTypeId, "id" => $fileId, "orignName" => $data["orignName"]];
  274. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  275. }
  276. public function deleteFile() {
  277. $param = $this->request->param();
  278. $where = [["id", "=", $param["id"]]];
  279. $file = Db::table("new_talent_file")->where($where)->findOrEmpty();
  280. if (!TalentApi::checkIsEditable($file["mainId"]))
  281. return json(["msg" => "当前状态不能删除"]);
  282. if ($this->chkIsFileOwner($file["mainId"], $file["type"])) {
  283. $filepath = "storage/" . $file["url"];
  284. if (file_exists($filepath)) {
  285. unlink($filepath);
  286. }
  287. Db::table("new_talent_file")->delete($file["id"]);
  288. TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
  289. return json(["code" => 200, "msg" => "删除成功"]);
  290. }
  291. return json(["msg" => "不能删除"]);
  292. }
  293. /**
  294. * 下载文件
  295. */
  296. public function downloadFile() {
  297. $param = $this->request->param();
  298. $type = $param["type"];
  299. $id = $param["id"];
  300. $where = [];
  301. $where[] = ["id", "=", $id];
  302. $where[] = ["type", "=", $type];
  303. $fileinfo = Db::table("new_talent_file")->where($where)->findOrEmpty();
  304. $filename = $fileinfo["orignName"];
  305. $filepath = "storage/" . $fileinfo["url"]; // 下载文件名
  306. if (!file_exists($filepath)) {
  307. header('HTTP/1.1 404 NOT FOUND');
  308. } else {
  309. $file = fopen($filepath, "rb");
  310. Header("Content-type: application/octet-stream");
  311. Header("Accept-Ranges: bytes");
  312. Header("Accept-Length: " . filesize($filepath));
  313. Header("Content-Disposition: attachment; filename=" . $filename);
  314. echo fread($file, filesize($filepath));
  315. fclose($file);
  316. exit();
  317. }
  318. }
  319. /**
  320. * 打包下载人才申请附件
  321. */
  322. public function downloadZip() {
  323. $param = $this->request->param();
  324. $type = $param["type"];
  325. $id = $param["id"];
  326. $where = [];
  327. $where[] = ["mainId", "=", $id];
  328. $where[] = ["type", "=", $type];
  329. $files = Db::table("new_talent_file")->where($where)->select()->toArray();
  330. if (!$files)
  331. die("没有附件不能打包下载");
  332. $talent_info = \app\enterprise\model\Talent::findOrEmpty($id);
  333. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  334. $zip_filename = sprintf("%s(%s)人才申报材料.zip", $talent_info["name"], $enterprise_info["name"]);
  335. $tmp_path = "storage/temp/";
  336. $tmp_file_path = $tmp_path . $zip_filename;
  337. if (!file_exists($tmp_path)) {
  338. mkdir($tmp_path);
  339. }
  340. $zip = new \ZipArchive();
  341. if (!$zip->open($tmp_file_path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
  342. header('HTTP/1.1 404 NOT FOUND');
  343. }
  344. foreach ($files as $file) {
  345. $filepath = "storage/" . $file["url"];
  346. $filename = $file["orignName"];
  347. $zip->addFile($filepath, $filename);
  348. }
  349. $zip->close();
  350. if (file_exists($tmp_file_path)) {
  351. header("Cache-Control: public");
  352. header("Content-Description: File Transfer");
  353. header('Content-disposition: attachment; filename=' . $zip_filename); //文件名
  354. header("Content-Type: application/octet-stream;charset=utf-8"); //zip格式的
  355. header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
  356. header('Content-Length: ' . filesize($tmp_file_path)); //告诉浏览器,文件大小
  357. @readfile($tmp_file_path);
  358. }
  359. //删除临时文件
  360. @unlink($tmp_file_path);
  361. }
  362. private function chkIsFileOwner($mainId, $type) {
  363. if (!$mainId)
  364. return true;
  365. switch ($type) {
  366. case 1:
  367. if ($this->user["usertype"] == 2) {
  368. $user_id = $this->user["uid"];
  369. $talent_info = Db::table("new_talent_info")->findOrEmpty($mainId);
  370. if ($user_id == $talent_info["enterprise_id"])
  371. return true;
  372. }
  373. break;
  374. }
  375. return false;
  376. }
  377. public function getCompanyKvs() {
  378. $companys = \app\common\model\Company::field("name,id")->select();
  379. return json($companys);
  380. }
  381. /**
  382. * 通过人才类别查找人才认定第二步骤支持的所有文件类型
  383. * 默认人才认定第二步骤,当前只有人才认定分了两步,所以此方法目前默认参数高度匹配人才认定第二阶段附件的查找
  384. */
  385. public function getConditionFileTypesByType() {
  386. $params = $this->request->param();
  387. $type = $params["type"]; //人才类型不默认,需要传
  388. $declare_type = $params["project"] ?: 1; //默认人才认定
  389. $active = $params["active"] ?: 1; //默认查找启用的附件
  390. $where[] = ["type", "=", $type];
  391. $where[] = ["project", "=", $declare_type];
  392. $where[] = ["active", "=", $active];
  393. $where[] = ["isConditionFile", "=", 1];
  394. $list = Db::table("new_common_filetype")->where($where)->order("sn " . $order)->select()->toArray();
  395. return json($list);
  396. }
  397. public function listCurrencyFileType() {
  398. $where = [
  399. 'type' => $this->request['type'],
  400. 'active' => 1
  401. ];
  402. $rows = CurrentcyFileType::where($where)->select();
  403. return json(["rows" => $rows, 'total' => count($rows)]);
  404. }
  405. public function listTalentCommonFile() {
  406. $where = [];
  407. if (\StrUtil::isNotEmpAndNull($this->request['mainId'])) {
  408. $where[] = ['mainId', '=', $this->request['mainId']];
  409. }
  410. if (\StrUtil::isNotEmpAndNull($this->request['typeId'])) {
  411. $where[] = ['typeId', '=', $this->request['typeId']];
  412. }
  413. $res = TalentCommonFile::where($where)->order('sn')->select();
  414. if ($res) {
  415. foreach ($res as $k => &$v) {
  416. $v['url'] = "/storage/" . $v['url'];
  417. }
  418. }
  419. return json($res);
  420. }
  421. public function addTalentCommonFile() {
  422. $backName = \StrUtil::getRequestDecodeParam($this->request, 'backName');
  423. $id = \StrUtil::getRequestDecodeParam($this->request, "fileId");
  424. $mainId = \StrUtil::getRequestDecodeParam($this->request, "mainId");
  425. $typeId = \StrUtil::getRequestDecodeParam($this->request, "typeId");
  426. $index = \StrUtil::getRequestDecodeParam($this->request, "index");
  427. if ($backName == "EpChangeEdit.callBack") {
  428. $type = 1;
  429. $error = "文件格式不正确,只能上传图片";
  430. } else {
  431. $type = 4;
  432. $error = "文件格式不正确,只能上传pdf和图片";
  433. }
  434. $uploadapi = new UploadApi();
  435. $file_check_res = $uploadapi->uploadOne($this->request->file('fileUrl'), 'system');
  436. if ($file_check_res->code == 500) {
  437. return \StrUtil::back($file_check_res, "Register.epCallBack");
  438. }
  439. $file_data = [
  440. 'id' => getStringId(),
  441. 'mainId' => $mainId,
  442. 'typeId' => $typeId,
  443. 'orignName' => $this->request->file('fileUrl')->getOriginalName(),
  444. 'url' => $file_check_res->filepath
  445. ];
  446. if (\StrUtil::isEmpOrNull($id)) {
  447. $tc = TalentCommonFile::where('mainId', $mainId)->where('typeId', $typeId)->order('sn', 'desc')->findOrEmpty();
  448. if ($tc) {
  449. $file_data['sn'] = $tc['sn'] + 1;
  450. } else {
  451. $file_data['sn'] = 1;
  452. }
  453. $file_data['createTime'] = date("Y-m-d H:i:s");
  454. TalentCommonFile::create($file_data);
  455. $response_object = new \StdClass();
  456. $response_object->code = 200;
  457. $response_object->msg = "附件上传成功!";
  458. $response_object->obj = $index;
  459. return \StrUtil::back($response_object, $backName);
  460. } else {
  461. $tf = TalentCommonFile::findOrEmpty($id);
  462. $tf->originalName = $file_data['orignName'];
  463. $tf->updateTime = date("Y-m-d H:i:s");
  464. $tf->url = $file_check_res->filepath;
  465. $tf->save();
  466. $response_object = new \StdClass();
  467. $response_object->code = 200;
  468. $response_object->msg = "附件修改成功!";
  469. $response_object->obj = $index;
  470. return \StrUtil::back($response_object, $backName);
  471. }
  472. }
  473. public function changePwd() {
  474. $password = \StrUtil::getRequestDecodeParam($this->request, 'password');
  475. $newPassword = \StrUtil::getRequestDecodeParam($this->request, 'newPassword');
  476. //数据校验(原密码与新密码不能为空)
  477. if (\StrUtil::isEmpOrNull($password)) {
  478. return json(['code' => 500, 'msg' => "请填写原密码!"]);
  479. }
  480. if (\StrUtil::isEmpOrNull($newPassword)) {
  481. return json(['code' => 500, 'msg' => "请填写新密码!"]);
  482. }
  483. try {
  484. validate(Enterprise::class)->batch(true)->scene('changePwd')->check(['password' => $password, 'password' => $newPassword]);
  485. $ep = EnterpriseApi::getOne(session("user")['uid']);
  486. if (!$ep) {
  487. return json(['code' => 500, 'msg' => "请刷新页面后重试!"]);
  488. }
  489. if ($ep->password != hash('md5', $password)) {
  490. return json(['code' => 500, 'msg' => "旧密码不正确!"]);
  491. }
  492. $ep->password = hash('md5', $newPassword);
  493. $ep->updateUser = session("user")['uid'];
  494. $ep->updateTime = date("Y-m-d H:i:s");
  495. $ep->save();
  496. TalentChecklog::create([
  497. 'id' => getStringId(),
  498. 'category' => 'enterprise_change',
  499. 'mainId' => $ep->id,
  500. 'type' => 10,
  501. 'typeField' => null,
  502. 'active' => 1,
  503. 'state' => 1,
  504. 'step' => 100,
  505. 'stateChange' => null,
  506. 'description' => '用户修改密码',
  507. 'createTime' => date("Y-m-d H:i:s", time()),
  508. 'createUser' => '用户'
  509. ]);
  510. return json(['code' => 200, 'msg' => "修改成功!"]);
  511. } catch (ValidateException $e) {
  512. $error = $e->getError();
  513. return json(['code' => 500, 'msg' => array_pop($error)]);
  514. }
  515. }
  516. }