User.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\admin\model\dao;
  3. use app\common\model\UserModel;
  4. use think\facade\Db;
  5. class User extends BaseDao
  6. {
  7. protected $model;
  8. public static $table = "db_user";
  9. public function __construct()
  10. {
  11. $this->model = new UserModel();
  12. }
  13. public static function getUserById($uid)
  14. {
  15. return Db::table(self::$table)->where(['id' => $uid])->find();
  16. }
  17. public static function getUserByMobile($mobile)
  18. {
  19. return Db::table(self::$table)->where('mobile', $mobile)->find();
  20. }
  21. public static function ModifyMobile($uid, $phone)
  22. {
  23. return Db::table(self::$table)
  24. ->where(['id' => $uid])
  25. ->update([
  26. 'mobile' => $phone,
  27. 'update_time' => date('Y-m-d H:i:s')
  28. ]);
  29. }
  30. public static function modifyUserPidAndPath($uid, $pid, $newPathPrefix)
  31. {
  32. return Db::table(self::$table)
  33. ->where(['id' => $uid])
  34. ->update([
  35. 'pid' => $pid,
  36. 'path' => $newPathPrefix,
  37. 'update_time' => date('Y-m-d H:i:s')
  38. ]);
  39. }
  40. public static function modifyUserPath($id, $newPath)
  41. {
  42. return Db::table(self::$table)
  43. ->where(['id' => $id])
  44. ->update([
  45. 'path' => $newPath,
  46. 'update_time' => date('Y-m-d H:i:s')
  47. ]);
  48. }
  49. public function getCount($where, $userMap)
  50. {
  51. return $this->model
  52. ->withJoin('userData', 'INNER')
  53. ->where($where)
  54. ->where($userMap)
  55. ->count();
  56. }
  57. public function getPageList($page, $limit, $where, $sort, $userMap)
  58. {
  59. return $this->model
  60. ->withJoin('userData', 'INNER')
  61. ->where($where)
  62. ->where($userMap)
  63. ->page($page, $limit)
  64. ->order($sort)
  65. ->select();
  66. }
  67. }