AdminModel.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. ['is_delete', '=',0]
  24. ])->find();
  25. }
  26. public function refreshToken($adminId,$token) {
  27. return $this->where([
  28. ['id', '=',$adminId],
  29. ['is_delete', '=',0]
  30. ])->update(['token' => $token]);
  31. }
  32. /**
  33. * @return \think\Paginator
  34. * @throws \think\db\exception\DbException
  35. */
  36. public function findByPaginate() {
  37. return $this->where('is_delete',0)->paginate(10);
  38. }
  39. }