예제 #1
0
 /**
  * 更新学校
  */
 public function updateAction()
 {
     list($update, $add, $areaid, $typeid) = $this->getInput(array('update', 'add', 'areaid', 'typeid'), 'post');
     foreach ($update as $id => $name) {
         $dm = new WindidSchoolDm();
         $dm->setSchoolid($id)->setName($name)->setFirstChar($this->_getService()->getFirstChar($name));
         $r = $this->_getDs()->updateSchool($dm);
         if ($r instanceof WindidError) {
             $this->showError('ADMIN:school.error.' . $r->getCode());
         }
     }
     $addDms = array();
     foreach ($add as $name) {
         $dm = new WindidSchoolDm();
         $dm->setName($name)->setTypeid($typeid)->setAreaid($areaid)->setFirstChar($this->_getService()->getFirstChar($name));
         $addDms[] = $dm;
     }
     $r = $this->_getDs()->batchAddSchool($addDms);
     if ($r instanceof WindidError) {
         $this->showError('ADMIN:school.error.' . $r->getCode());
     }
     $this->showMessage('success', 'windid/schooldata/run?type=' . $typeid . '&areaid=' . $areaid);
 }
예제 #2
0
 /**
  * 更新学校
  */
 public function updateAction()
 {
     list($update, $add, $areaid, $typeid) = $this->getInput(array('update', 'add', 'areaid', 'typeid'), 'post');
     is_array($update) || ($update = array());
     is_array($add) || ($add = array());
     foreach ($update as $id => $name) {
         $dm = new WindidSchoolDm();
         $dm->setSchoolid($id)->setName($name)->setFirstChar($this->_getDs()->getFirstChar($name));
         $r = $this->_getDs()->updateSchool($dm);
         if ($r < 1) {
             $this->showError('WINDID:code.' . $r);
         }
     }
     if ($add) {
         $addDms = array();
         foreach ($add as $name) {
             $dm = new WindidSchoolDm();
             $dm->setName($name)->setTypeid($typeid)->setAreaid($areaid)->setFirstChar($this->_getDs()->getFirstChar($name));
             $addDms[] = $dm;
         }
         $r = $this->_getDs()->batchAddSchool($addDms);
         if ($r < 1) {
             $this->showError('WINDID:code.' . $r);
         }
     }
     $this->showMessage('success', 'windidclient/schooldata/run?type=' . $typeid . '&areaid=' . $areaid);
 }
예제 #3
0
 public function updateSchool(WindidSchoolDm $dm)
 {
     $params = array('id' => $dm->schoolid);
     return WindidApi::open('school/update', $params, $dm->getData());
 }
예제 #4
0
 protected function buildData($id, $type)
 {
     $url = 'http://api.pengyou.com/json.php?cb=__i_5&mod=school&act=selector&schooltype=' . $type . '&district=' . $id;
     $content = file_get_contents($url);
     preg_match('/{(.*)}/is', $content, $matches);
     $content = WindJson::decode($matches[0]);
     $result = $content['result'];
     preg_match_all('/javascript:choose_school\\((\\d+),\'(.*)\'\\);/iUs', $result, $matches);
     $addDms = array();
     foreach ($matches[1] as $k => $v) {
         $dm = new WindidSchoolDm();
         $dm->setName($matches[2][$k])->setTypeid($this->getSchoolType($type))->setAreaid($id)->setFirstChar($this->_getService()->getFirstChar($matches[2][$k]));
         $addDms[] = $dm;
     }
     return $this->_getSchoolDs()->batchAddSchool($addDms);
 }
예제 #5
0
 public function updateAction()
 {
     $ids = $this->getInput('id', 'get');
     list($name, $firstchar, $typeid, $areaid) = $this->getInput(array('name', 'first_char', 'typeid', 'areaid'), 'post');
     Wind::import('WSRV:school.dm.WindidSchoolDm');
     foreach ($name as $k => $id) {
         $dm = new WindidSchoolDm();
         $dm->setSchoolid($id);
         isset($name[$k]) && $dm->setName($name[$k]);
         isset($firstchar[$k]) && $dm->setFirstChar($firstchar[$k]);
         isset($typeid[$k]) && $dm->setTypeid($typeid[$k]);
         isset($areaid[$k]) && $dm->setAreaid($areaid[$k]);
         $dms[] = $dm;
     }
     $result = $this->_getSchoolDs()->batchAddSchool($dms);
     $this->output(WindidUtility::result($result));
 }
예제 #6
0
 /**
  * 更新学校数据
  *
  * @param WindidSchoolDm $schooldm
  * @return int
  */
 public function updateSchool(WindidSchoolDm $schooldm)
 {
     if (true !== ($r = $schooldm->beforeUpdate())) {
         return $r;
     }
     return $this->_getDao()->updateSchool($schooldm->getSchoolid(), $schooldm->getData());
 }