H5ConfigServer.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\admin\server\index;
  3. use app\admin\model\H5config;
  4. class H5ConfigServer
  5. {
  6. public static function getConfig()
  7. {
  8. $data = H5Config::getConfig();
  9. return $data;
  10. }
  11. /**
  12. * Notes:修改设置
  13. * @param string $package_name
  14. * @param int $package_id
  15. * @return int
  16. * User: YCP
  17. * Date: 2023/2/15
  18. */
  19. public static function updateConfig(array $params)
  20. {
  21. H5Config::affairBegin();
  22. try {
  23. $info = H5Config::where('config_name','h5')->first();
  24. if(empty($info) || $info === false)
  25. {
  26. $params['config_name'] = 'h5';
  27. $result = H5Config::insertGetId($params);
  28. H5Config::affairCommit();
  29. return true;
  30. }else{
  31. $result = H5Config::where('config_name','h5')->update($params);
  32. H5Config::affairCommit();
  33. return true;
  34. }
  35. throw new \Exception('操作失败!');
  36. }catch (\Exception $exception){
  37. H5Config::affairRollback();
  38. throw new \Exception($exception->getMessage(), 500);
  39. }
  40. }
  41. }