<?php
|
|
namespace app\shop\controller\branch;
|
|
use app\shop\controller\Controller;
|
use app\shop\model\branch\Position as PositionModel;
|
|
/**
|
* 职务管理控制器
|
*/
|
class Position extends Controller
|
{
|
/**
|
* 获取列表
|
*/
|
public function index()
|
{
|
// 列表
|
$model = new PositionModel;
|
$list = $model->getAll();
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
/**
|
* 添加
|
*/
|
public function add()
|
{
|
$model = new PositionModel;
|
// 新增记录
|
if ($model->add($this->postData())) {
|
return $this->renderSuccess('添加成功');
|
}
|
return $this->renderError($model->getError() ?: '添加失败');
|
}
|
|
/**
|
* 编辑
|
*/
|
public function edit($position_id)
|
{
|
// 分类详情
|
$model = PositionModel::detail($position_id);
|
// 更新记录
|
if ($model->edit($this->postData())) {
|
return $this->renderSuccess('更新成功');
|
}
|
return $this->renderError($model->getError() ?: '更新失败');
|
}
|
|
/**
|
* 删除
|
*/
|
public function delete($position_id)
|
{
|
$model = PositionModel::detail($position_id);
|
if (!$model->remove()) {
|
return $this->renderError('该职务使用中,删除失败');
|
}
|
return $this->renderSuccess('删除成功');
|
}
|
|
/**
|
* 开启禁止
|
*/
|
public function status($position_id, $status)
|
{
|
// 商品详情
|
$model = PositionModel::detail($position_id);
|
if (!$model->setStatus($status)) {
|
return $this->renderError('操作失败');
|
}
|
return $this->renderSuccess('操作成功');
|
}
|
}
|