1、修复栏目管理内生成导航bug
2、修复api接口bug
This commit is contained in:
@@ -12,6 +12,7 @@ namespace app\controller\admin;
|
||||
use app\model\Category as CategoryM;
|
||||
use app\model\Attribute;
|
||||
use app\model\Model;
|
||||
use app\model\Channel;
|
||||
|
||||
/**
|
||||
* @title 栏目管理
|
||||
@@ -269,40 +270,34 @@ class Category extends Base {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function add_channel() {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->param();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
if ($id) {
|
||||
$map['id'] = array('IN', $data['mid']);
|
||||
$result = db('Category')->where($map)->setField('ismenu',$Channel->id);
|
||||
return $this->success('生成成功',url('index'));
|
||||
//记录行为
|
||||
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
|
||||
} else {
|
||||
return $this->error('生成失败');
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->param();
|
||||
if ($data) {
|
||||
$mid = $data['id'];
|
||||
$data['status'] = 1;
|
||||
unset($data['id']);
|
||||
$channel = Channel::create($data);
|
||||
if ($channel->id) {
|
||||
$result = CategoryM::update(['ismenu'=>$channel->id], ['id' => $mid]);
|
||||
return $this->success('生成成功',url('/admin/category/index'));
|
||||
} else {
|
||||
$this->error($Channel->getError());
|
||||
return $this->error('生成失败');
|
||||
}
|
||||
} else {
|
||||
$data = $this->request->param();
|
||||
$modelname = db('Model')->where( array('id' => $data['model_id']) )->field('id,name')->find();
|
||||
$data['url'] = $modelname['name'].'/list/'.$data['mid'];
|
||||
$pid = input('pid', 0);
|
||||
//获取父导航
|
||||
if (!empty($pid)) {
|
||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||
$this->assign('parent', $parent);
|
||||
}
|
||||
$pnav = db('Channel')->where(array('pid' => '0'))->select();
|
||||
$this->assign('pnav', $pnav);
|
||||
$this->assign('pid', $pid);
|
||||
$this->assign('info', $data);
|
||||
$this->assign('data',null );
|
||||
$this->setMeta('生成导航');
|
||||
return $this->fetch('edit_channel');
|
||||
$this->error($Channel->getError());
|
||||
}
|
||||
} else {
|
||||
$data = $this->request->param();
|
||||
$info = CategoryM::where('id', $data['id'])->field('id, title,model_id,pid')->find()->toArray();
|
||||
$modelname = Model::where('id', $data['model_id'])->value('name');
|
||||
$info['url'] = '/' . $modelname.'/list/'.$data['id'];
|
||||
$data['pid'] = CategoryM::where('id', $info['pid'])->value('ismenu');
|
||||
$data['pid'] = isset($data['pid']) ? $data['pid'] : 0;
|
||||
|
||||
$this->data = [
|
||||
'info' => $info
|
||||
];
|
||||
return $this->fetch('admin/channel/edit');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user