AppSetting.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace app\adminall\controller;
  3. use think\facade\View;
  4. use think\facade\Db;
  5. use app\model\Employee;
  6. use think\facade\Request;
  7. use app\model\AppSetting as AppSettingModel;
  8. class AppSetting
  9. {
  10. public function index()
  11. {
  12. //系统设置
  13. $list = AppSettingModel::where([['code','in',['cutImgSize','ossImgSetting','iosVersion','androidVersion']]])->column('content');
  14. $data = [];
  15. foreach ($list as $key => $value) {
  16. if($value) $data = array_merge($data,json_decode($value,true));
  17. }
  18. $fields = ['size','measurement','accesskey','secretkey','endpoint','bucket','url','version','appUrl','content','updateType','android_version','android_appUrl','android_content','android_updateType'];
  19. foreach ($fields as $key1 => $value1) {
  20. if(!isset($data[$value1])) $data[$value1] = '';
  21. }
  22. View::assign('data',$data);
  23. return View::fetch();
  24. }
  25. /**
  26. * 系统设置
  27. */
  28. public function updateSystemSetting()
  29. {
  30. $param = Request::only(['size'=>'','measurement'=>'','accesskey'=>'','secretkey'=>'','endpoint'=>'','bucket'=>'','url'=>'']);
  31. $where1 = [['code','=','cutImgSize']];
  32. $img_size = AppSettingModel::where($where1)->findOrEmpty();
  33. $data['size'] = $param['size'];
  34. $data['measurement'] = $param['measurement'];
  35. if ($img_size->isEmpty()) {
  36. AppSettingModel::insertGetId([
  37. 'code'=>'cutImgSize',
  38. 'content'=>json_encode($data),
  39. 'type'=>'json',
  40. 'remark'=>'切图压缩大小和尺寸'
  41. ]);
  42. }else{
  43. $img_size->content = json_encode($data);
  44. $img_size->save();
  45. }
  46. $where2 = [['code','=','ossImgSetting']];
  47. $oss = AppSettingModel::where($where2)->findOrEmpty();
  48. unset($param['size']);
  49. unset($param['measurement']);
  50. if ($oss->isEmpty()) {
  51. AppSettingModel::insertGetId([
  52. 'code'=>'ossImgSetting',
  53. 'content'=>json_encode($param),
  54. 'type'=>'json',
  55. 'remark'=>'oss配置'
  56. ]);
  57. }else{
  58. $oss->content = json_encode($param);
  59. $oss->save();
  60. }
  61. return json(['code'=>0,'data'=>'保存成功']);
  62. }
  63. /**
  64. * 苹果设置
  65. *
  66. */
  67. public function updateAppleSetting()
  68. {
  69. $param = Request::only(['version'=>'','appUrl'=>'','content'=>'','updateType'=>0]);
  70. $where2 = [['code','=','iosVersion']];
  71. $oss = AppSettingModel::where($where2)->findOrEmpty();
  72. if ($oss->isEmpty()) {
  73. AppSettingModel::insertGetId([
  74. 'code'=>'iosVersion',
  75. 'content'=>json_encode($param),
  76. 'type'=>'json',
  77. 'remark'=>'苹果版本设置'
  78. ]);
  79. }else{
  80. $oss->content = json_encode($param);
  81. $oss->save();
  82. }
  83. return json(['code'=>0,'data'=>'保存成功']);
  84. }
  85. /**
  86. * 安卓设置
  87. *
  88. */
  89. public function updateAndroidSetting()
  90. {
  91. $param = Request::only(['android_version'=>'','android_appUrl'=>'','android_content'=>'','android_updateType'=>0]);
  92. $where2 = [['code','=','androidVersion']];
  93. $oss = AppSettingModel::where($where2)->findOrEmpty();
  94. if ($oss->isEmpty()) {
  95. AppSettingModel::insertGetId([
  96. 'code'=>'androidVersion',
  97. 'content'=>json_encode($param),
  98. 'type'=>'json',
  99. 'remark'=>'安卓版本设置'
  100. ]);
  101. }else{
  102. $oss->content = json_encode($param);
  103. $oss->save();
  104. }
  105. return json(['code'=>0,'data'=>'保存成功']);
  106. }
  107. }