AdminModel.php 997 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\common\model;
  3. class AdminModel extends BaseModel
  4. {
  5. protected $table = 'erp_admin';
  6. public function genSchema(array $schema)
  7. {
  8. $this->schema = [
  9. 'id' => 'number',
  10. 'account' => 'string',
  11. 'nickname' => 'string',
  12. 'password' => 'string',
  13. 'token' => 'string',
  14. 'delete_time' => 'number',
  15. 'create_time' => 'number',
  16. 'update_time' => 'number'
  17. ];
  18. }
  19. public function loadByLogin($username, $password) {
  20. return $this->where([
  21. ['account', '=', $username],
  22. ['password', '=', $password],
  23. ])->find();
  24. }
  25. public function refreshToken($adminId,$token) {
  26. return $this->where('id',$adminId)->update(['token' => $token]);
  27. }
  28. /**
  29. * @return \think\Paginator
  30. * @throws \think\db\exception\DbException
  31. */
  32. public function findAdmins() {
  33. return $this->paginate(10);
  34. }
  35. }