12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace app\admins\model;
- use think\Db;
- use think\Model;
- //封装model工具类
- class Admin extends Common
- {
- public function initialize()
- {
- parent::initialize();
- }
- //添加,更改==
- public function addUpdate($table, $data = null, $id = null)
- {
- if ($id) {
- return Db::name($table)->where('id', $id)->update($data);
- }
- return Db::name($table)->insertGetId($data);
- }
- //返回管理员信息
- public function findOne($field, $value)
- {
- return Db::name('admin')->where($field, $value)->find();
- }
- //验证指定字段
- public function checkUserAdmin($field, $value)
- {
- return Db::name('admin')->field('id')->where($field, $value)->find();
- }
- //管理员列表
- public function getAllUserAdmins()
- {
- // return Db::name('admin')->field('user_name,password')->select();
- return Db::name('admin')->where('status != -1')->order('id desc')->paginate(1000);
- }
- //返回注册时间===
- public function getRegDate($admName)
- {
- return Db::name('admin')->field('add_time')->where('account', $admName)->find();
- }
- //登陆验证==
- public function getLoginResult($admName, $admPass)
- {
- return Db::name('admin')->field(['id','position_name','sto_id','identity','serve','code'])->where(['account' => $admName, 'password' => $admPass, 'status' => 1,'status_del'=>1])->find();
- }
- //删除
- public function del($table, $data, $ids = null, $opt = null)
- {
- //删除
- if ($opt) {
- return Db::name($table)->where("id in ({$ids})")->delete();
- }
- return Db::name($table)->where("id in ({$ids})")->update($data);
- }
- //获取日志
- public function getLogs($data)
- {
- return Db::name('admin_log')->alias('a')->join('admin b', 'a.adm_id = b.id')
- ->field('a.*, b.account')->where($data)->order('a.id desc')->paginate(15);
- }
- }
|