Example #1
0
 /**
  * @access Guest
  */
 public function infoAction()
 {
     $modelName = $this->request->get('model');
     $tableName = $this->request->get('table');
     $a = $this->db->fetchAll("SHOW FULL COLUMNS FROM {$tableName}");
     $data = array();
     $fields = array();
     foreach ($a as $i) {
         array_push($fields, $i);
     }
     $data['fields'] = $fields;
     parent::result($data);
 }
 public function updateAction()
 {
     $name = $this->request->getPost('name');
     $enums = $this->request->getPost('enums');
     if (!$name) {
         parent::error(1, array('msg' => 'None name error'));
         return;
     }
     $classNamePath = self::getEnumPath();
     $jsonName = "{$classNamePath}/const/{$name}.json";
     file_put_contents($jsonName, json_encode($enums));
     $cmdLine = "--json={$jsonName}";
     $results = Python3::run('build_enum.py', $cmdLine);
     parent::result(array('file' => $jsonName, 'results' => $results));
 }
 public function previewAction()
 {
     $p = $this->request->getPost();
     $prefix = $p['prefix'];
     $tableName = $p['table_name'];
     if ($prefix) {
         $tableName = "{$prefix}_{$tableName}";
     }
     $modelName = Strings::tableNameToModelName($tableName);
     $path = ApplicationConfig::getConfig('product')['path'] . '\\www';
     $this->createModelConfigFile($path, $modelName, $p);
     $configPath = ApplicationConfig::getConfigPath('config.json');
     $cmdLine = "--prefix={$prefix} --table={$tableName} --config=\"{$configPath}\"";
     $c = Python3::run("build_mvc.py", $cmdLine);
     $targetHost = ApplicationConfig::getConfig('product')['host'];
     $testListUrl = "{$targetHost}/{$modelName}";
     parent::result(array('model' => $modelName, 'files' => json_decode($c), 'cmd_line' => $cmdLine, 'test_list_url' => $testListUrl, 'build' => $c));
 }
 /**
  * Test code for convertFileName from pattern
  */
 public function refreshAction()
 {
     parent::result(self::getAllUpload());
 }
 public function logoutAction()
 {
     // TODO:
     parent::result(array('auth' => $this->request->getPost()));
 }
 public function syncAction()
 {
     $entries = $_POST['entries'];
     $now = date('Y-m-d H:i:s');
     foreach ($entries as $entry) {
         $nodeId = $entry['node_id'];
         $name = trim($entry['name']);
         if ($nodeId == 0) {
             if (!empty($name)) {
                 $node = new KxAdminNode();
                 $node->controller = trim($entry['controller']);
                 $node->action = trim($entry['action']);
                 $node->name = $name;
                 $node->status = 1;
                 $node->create_time = $now;
                 $node->update_time = $now;
                 $node->save();
             }
         } else {
             $node = KxAdminNode::findFirst($nodeId);
             if ($node->name != $name) {
                 $node->name = $name;
                 $node->update_time = $now;
                 $node->save();
             }
         }
     }
     parent::result(array('post' => $entries));
 }
 /**
  * @param $id
  * @ajax
  * @comment: 删除角色 access_status = 0;
  */
 public function deleteAction($id)
 {
     $item = KxAdminRole::findFirst($id);
     $item->access_status = 0;
     $deleted = $item->save();
     parent::result(array('id' => $id, 'deleted' => $deleted));
 }