versionlogic.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-10-29 16:16:29
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-12-25 13:02:19
  7. */
  8. namespace app\index\logic;
  9. use app\index\model\versionmodel;
  10. class versionlogic
  11. {
  12. /**
  13. * 获取最新根据版本号
  14. * 20211224
  15. * wj
  16. */
  17. public function getinfobyversion($arr)
  18. {
  19. if (!isset($arr['version']) || empty($arr['version']) || !is_string($arr['version'])) {
  20. return backarr(0, "请求失败");
  21. }
  22. if (!preg_match('/\d{1,2}.{1}\d{1,2}.{1}\d{1,2}/', $arr['version'])) {
  23. return backarr(0, "格式错误");
  24. }
  25. $type = 1;
  26. if (isset($arr['type']) && !empty($arr['type'])) {
  27. $type = $arr['type'];
  28. }
  29. $version = $arr['version'];
  30. $m_v = new versionmodel();
  31. $where = ['version' => ['>', $version], 'type' => $type];
  32. $cinfo = $m_v->getList($where, '*', 1, 1, 'id desc', '', true);
  33. if (empty($cinfo)) {
  34. return backarr(0, "无数据");
  35. }
  36. return backarr(1, "操作成功", $cinfo);
  37. }
  38. /**
  39. * 获取最新根据code
  40. * 20211224
  41. * wj
  42. */
  43. public function getinfobycode($arr)
  44. {
  45. $type = 1;
  46. if (isset($arr['type']) && !empty($arr['type'])) {
  47. $type = $arr['type'];
  48. }
  49. $m_v = new versionmodel();
  50. $where = ['type' => $type];
  51. $cinfo = $m_v->getList($where, '*', 1, 1, 'id desc', '', true);
  52. if (empty($cinfo)) {
  53. return backarr(0, "无数据");
  54. }
  55. return backarr(1, "操作成功", $cinfo);
  56. }
  57. }