public function batchaddAction() { $dms = array(); list($ids, $name, $parentid, $joinname) = $this->getInput(array('id', 'name', 'parentid', 'joinname'), 'post'); Wind::import('WSRV:area.dm.WindidAreaDm'); foreach ($ids as $k => $id) { $dm = new WindidAreaDm(); $dm->setAreaid($id); isset($name[$k]) && $dm->setName($name[$k]); isset($parentid[$k]) && $dm->setParentid($parentid[$k]); isset($joinname[$k]) && $dm->setJoinname($joinname[$k]); $dms[] = $dm; } $result = $this->_getAreaDs()->batchAddArea($dms); $this->output(WindidUtility::result($result)); }
/** * 更新地区 */ public function updateAction() { list($update, $add, $parentid) = $this->getInput(array('update', 'add', 'parentid'), 'post'); $joinname = ''; if ($parentid) { $rout = $this->_loadAreaService()->getAreaRout($parentid); switch (count($rout)) { case 0: $this->showError('ADMIN:area.parentid.error'); break; case 3: $this->showError('ADMIN:area.level.limit'); break; } $joinnames = array(); foreach ($rout as $i) { $joinnames[] = $i['name']; } $joinname = implode('|', $joinnames); } foreach ($update as $id => $name) { $dm = new WindidAreaDm(); $dm->setAreaid($id)->setName($name)->setJoinname($joinname ? $joinname . '|' . $name : $name); if (true !== ($r = $this->_loadAreaDs()->updateArea($dm))) { $this->showError(array('ADMIN:area.error.' . $r->getCode(), array('{flag}' => "“& \" ' < > \\ / ”"))); } } $addDms = array(); foreach ($add as $name) { $dm = new WindidAreaDm(); $dm->setName($name)->setParentid($parentid)->setJoinname($joinname ? $joinname . '|' . $name : $name); if (true !== ($r = $dm->beforeAdd())) { $this->showError(array('ADMIN:area.error.' . $r->getCode(), array('{flag}' => "“& \" ' < > \\ / ”"))); } $addDms[] = $dm; } $this->_loadAreaDs()->batchAddArea($addDms); $this->_loadAreaService()->updateCache(); $this->showMessage('success', 'admin/windid/areadata/run?parentid=' . $parentid); }
/** * 根据地区ID更新一个地区信息 * * @param WindidAreaDm $dm 地区Dm * @return boolean */ public function updateArea(WindidAreaDm $dm) { if (($r = $dm->beforeUpdate()) !== true) { return $r; } return $this->_getDao()->updateArea($dm->areaid, $dm->getData()); }
public function updateArea(WindidAreaDm $dm) { $params = array('id' => $dm->areaid); return WindidApi::open('area/update', $params, $dm->getData()); }