SysConfigController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. class SysConfigController extends AdminController{
  3. public function actionIndex()
  4. {
  5. $this->render('index');
  6. }
  7. public function actionList(){
  8. $cursor = Variable::model()->findAll();
  9. $rows = CommonFn::getRowsFromCursor($cursor);
  10. $parsedRows = Variable::model()->parse($rows);
  11. $admin_view_config = Yii::app()->params['admin_view_config'];
  12. foreach ($parsedRows as $key => $value) {
  13. if(!array_key_exists($value['key'],$admin_view_config)){
  14. unset($parsedRows[$key]);
  15. continue;
  16. }
  17. $parsedRows[$key]['name'] = $admin_view_config[$value['key']];
  18. }
  19. $parsedRows = array_values($parsedRows);
  20. echo CommonFn::composeDatagridData($parsedRows, count($parsedRows));
  21. }
  22. public function actionSet(){
  23. $key = Yii::app()->request->getParam('key', '');
  24. $value = Yii::app()->request->getParam('value', '');
  25. if($key == ''||$value == ''){
  26. CommonFn::requestAjax(false, "缺少必须参数");
  27. }
  28. $value = str_replace(',', ',',$value);
  29. $success = Service::factory('VariableService')->setVariable($key,$value);
  30. CommonFn::requestAjax($success);
  31. }
  32. public function actionDelete(){
  33. $key = Yii::app()->request->getParam('key');
  34. if (!$key) {
  35. CommonFn::requestAjax(false, "缺少必须参数");
  36. }
  37. $success = Service::factory('VariableService')->delVariable($key);
  38. CommonFn::requestAjax($success);
  39. }
  40. public function actionSetCounter(){
  41. $key = Yii::app()->request->getParam('key');
  42. $value = intval(Yii::app()->request->getParam('value'));
  43. $counter = new ARedisCounter($key);
  44. $counter->increment($value);
  45. echo "counter($key):".$counter->getValue();
  46. }
  47. }