123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: https://thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\county\controller;
- use think\admin\Controller;
- /**
- * 学校管理
- * Class User
- * @package app\admin\controller
- */
- class School extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- private $table = 'School2';
- /**
- * 学校管理
- * @auth true
- * @menu true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function index()
- {
- $this->title = '学校信息管理';
- $county_id = session('user.county_id');
- $query = $this->_query($this->table)->where('county_id',$county_id)->where('is_deleted',0)->like('name')->equal('school_code,office_phone,type');
- $query->order('id desc')->page();
- }
- /**
- * 数据列表处理
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(&$data)
- {
- foreach ($data as &$value){
- }
- $this->type_arr = array('1'=>'幼儿园','2'=>'小学','3'=>'初中','4'=>'高中','5'=>'特教','6'=>'工读','7'=>'中职');
- $this->county_list = $this->app->db->name('county_list')->column('name','id');
- }
- protected function _form_filter(&$data){
- if($this->request->isGet()) {
- }elseif ($this->request->isPost()){
- if (isset($data['id']) && $data['id'] > 0) {
- $is_set = $this->app->db->name('school2')->where('username',$data['username'])->where('id','<>',$data['id'])->find();
- if($is_set){
- $this->error('不能设置重复的账号');
- }
- $data['password'] = md5($data['visible_password']);
- }
- }
- }
- /**
- * 编辑学校
- * @auth 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->title = '编辑';
- $this->_form($this->table, 'form');
- }
- /**
- * 删除学校
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function remove()
- {
- $this->_save($this->table, ['is_deleted' => '1']);
- }
- /**
- * 禁用学校
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function forbid()
- {
- $this->_save($this->table, ['status' => '0']);
- }
- /**
- * 启用学校
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function resume()
- {
- $this->_save($this->table, ['status' => '1']);
- }
- }
|