StudioApi.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\UserInfo;
  4. use Illuminate\Support\Facades\Storage;
  5. use Illuminate\Support\Facades\App;
  6. class StudioApi{
  7. public static function getIdByName($name){
  8. /**
  9. * 获取 uuid
  10. */
  11. //TODO 改为studio table
  12. if(empty($name)){
  13. return false;
  14. }
  15. $userInfo = UserInfo::where('username',$name)->first();
  16. if(!$userInfo){
  17. return false;
  18. }else{
  19. return $userInfo->userid;
  20. }
  21. }
  22. public static function getById($id){
  23. //TODO 改为studio table
  24. if(empty($id)){
  25. return false;
  26. }
  27. $userInfo = UserInfo::where('userid',$id)->first();
  28. if(!$userInfo){
  29. return false;
  30. }
  31. $data = [
  32. 'id'=>$id,
  33. 'nickName'=>$userInfo->nickname,
  34. 'realName'=>$userInfo->username,
  35. 'studioName'=>$userInfo->username,
  36. ];
  37. if($userInfo->avatar){
  38. $img = str_replace('.jpg','_s.jpg',$userInfo->avatar);
  39. $data['avatar'] = Storage::url($img);
  40. }
  41. return $data;
  42. }
  43. public static function getByIntId($id){
  44. //TODO 改为studio table
  45. if(empty($id)){
  46. return false;
  47. }
  48. $userInfo = UserInfo::where('id',$id)->first();
  49. if(!$userInfo){
  50. return false;
  51. }
  52. return [
  53. 'id'=>$userInfo['userid'],
  54. 'nickName'=>$userInfo['nickname'],
  55. 'realName'=>$userInfo['username'],
  56. 'studioName'=>$userInfo['username'],
  57. 'avatar'=>'',
  58. ];
  59. }
  60. }