123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\admin\controller;
- use AlibabaCloud\DBFS\DBFS;
- use library\Controller;
- use think\Db;
- /**
- * 乡镇管理
- * Class help_center
- */
- class Towns extends Controller
- {
-
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'system_towns';
- /**
- * 乡镇管理
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $this->title = '乡镇管理';
- sysoplog('乡镇管理', '访问乡镇管理页面');
- $query = $this->_query($this->table)->like('name');
- $query->where('is_del',1)->order('id desc')->page();
- }
- /**
- * 添加乡镇
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function add()
- {
- $this->create_at = date('Y-m-d H:i:s');
- $this->_form($this->table, 'form');
- }
- /**
- * 编辑乡镇
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function edit()
- {
- $this->_form($this->table, 'form');
- }
- /**
- * 表单数据处理
- * @param array $vo
- * @throws \ReflectionException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _form_filter(&$vo)
- {
- if ($this->request->isGet()) {
- }elseif ($this->request->isPost()){
- $qu = Db::name($this->table)->where('is_del',1)->where('name',$vo['name']);
- if (isset($vo['id']) && $vo['id']!=''){
- $qu->where('id','neq',$vo['id']);
- }
- $name = $qu->find();
- if ($name){
- $this->error('乡镇已存在');
- }
- }
- }
- /**
- * 处理成功回调
- */
- public function _form_result($result,$data){
- $name = isset($data['id']) ? '编辑' : '新增';
- if ($result) {
- sysoplog('乡镇管理', $name.'成功'.json_encode($data,true));
- }else{
- sysoplog('乡镇管理', $name.'失败'.json_encode($data,true));
- }
- }
- /**
- * 删除乡镇
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function del()
- {
- $log = ['action'=>'乡镇管理','content'=>'删除'];
- $this->_save($this->table, ['is_del' => '0'],$log);
- }
- }
|