| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\common\model;
- class AdminModel extends BaseModel
- {
- protected $table = 'erp_admin';
- public function genSchema(array $schema)
- {
- $this->schema = [
- 'id' => 'number',
- 'account' => 'string',
- 'nickname' => 'string',
- 'password' => 'string',
- 'token' => 'string',
- 'delete_time' => 'number',
- 'create_time' => 'number',
- 'update_time' => 'number'
- ];
- }
- public function loadByLogin($username, $password) {
- return $this->where([
- ['account', '=', $username],
- ['password', '=', $password],
- ['is_delete', '=',0]
- ])->find();
- }
- public function refreshToken($adminId,$token) {
- return $this->where([
- ['id', '=',$adminId],
- ['is_delete', '=',0]
- ])->update(['token' => $token]);
- }
- /**
- * @return \think\Paginator
- * @throws \think\db\exception\DbException
- */
- public function findByPaginate() {
- return $this->where('is_delete',0)->paginate(10);
- }
- }
|