School.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\county\controller;
  15. use think\admin\Controller;
  16. /**
  17. * 学校管理
  18. * Class User
  19. * @package app\admin\controller
  20. */
  21. class School extends Controller
  22. {
  23. /**
  24. * 绑定数据表
  25. * @var string
  26. */
  27. private $table = 'School2';
  28. /**
  29. * 学校管理
  30. * @auth true
  31. * @menu true
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\DbException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. */
  36. public function index()
  37. {
  38. $this->title = '学校信息管理';
  39. $county_id = session('user.county_id');
  40. $query = $this->_query($this->table)->where('county_id',$county_id)->where('is_deleted',0)->like('name')->equal('school_code,office_phone,type');
  41. $query->order('id desc')->page();
  42. }
  43. /**
  44. * 数据列表处理
  45. * @param array $data
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @throws \think\exception\DbException
  49. */
  50. protected function _index_page_filter(&$data)
  51. {
  52. foreach ($data as &$value){
  53. }
  54. $this->type_arr = array('1'=>'幼儿园','2'=>'小学','3'=>'初中','4'=>'高中','5'=>'特教','6'=>'工读','7'=>'中职');
  55. $this->county_list = $this->app->db->name('county_list')->column('name','id');
  56. }
  57. protected function _form_filter(&$data){
  58. if($this->request->isGet()) {
  59. }elseif ($this->request->isPost()){
  60. if (isset($data['id']) && $data['id'] > 0) {
  61. $is_set = $this->app->db->name('school2')->where('username',$data['username'])->where('id','<>',$data['id'])->find();
  62. if($is_set){
  63. $this->error('不能设置重复的账号');
  64. }
  65. $data['password'] = md5($data['visible_password']);
  66. }
  67. }
  68. }
  69. /**
  70. * 编辑学校
  71. * @auth true
  72. * @throws \think\Exception
  73. * @throws \think\db\exception\DataNotFoundException
  74. * @throws \think\db\exception\ModelNotFoundException
  75. * @throws \think\exception\DbException
  76. * @throws \think\exception\PDOException
  77. */
  78. public function edit()
  79. {
  80. $this->title = '编辑';
  81. $this->_form($this->table, 'form');
  82. }
  83. /**
  84. * 删除学校
  85. * @auth true
  86. * @throws \think\Exception
  87. * @throws \think\exception\PDOException
  88. */
  89. public function remove()
  90. {
  91. $this->_save($this->table, ['is_deleted' => '1']);
  92. }
  93. /**
  94. * 禁用学校
  95. * @auth true
  96. * @throws \think\Exception
  97. * @throws \think\exception\PDOException
  98. */
  99. public function forbid()
  100. {
  101. $this->_save($this->table, ['status' => '0']);
  102. }
  103. /**
  104. * 启用学校
  105. * @auth true
  106. * @throws \think\Exception
  107. * @throws \think\exception\PDOException
  108. */
  109. public function resume()
  110. {
  111. $this->_save($this->table, ['status' => '1']);
  112. }
  113. }