UserModel.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | RXThinkCMF框架 [ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 南京RXThinkCMF研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.rxthink.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: 牧羊人 <1175401194@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. use App\Services\UserRoleService;
  13. /**
  14. * 人员管理-模型
  15. * @author 牧羊人
  16. * @since 2020/11/10
  17. * Class AdminModel
  18. * @package App\Models
  19. */
  20. class UserModel extends BaseModel
  21. {
  22. // 设置数据表
  23. protected $table = 'user';
  24. /**
  25. * 获取数据信息
  26. * @param int $id 用户ID
  27. * @return array|string
  28. * @author 牧羊人
  29. * @since 2020/11/10
  30. */
  31. public function getInfo($id)
  32. {
  33. $info = parent::getInfo($id); // TODO: Change the autogenerated stub
  34. if ($info) {
  35. // 头像
  36. if ($info['avatar']) {
  37. $info['avatar'] = get_image_url($info['avatar']);
  38. }
  39. // 性别
  40. if ($info['gender']) {
  41. $info['gender_name'] = config('admin.gender_list')[$info['gender']];
  42. }
  43. // 岗位
  44. if ($info['position_id']) {
  45. $positionModel = new PositionModel();
  46. $positionInfo = $positionModel->getInfo($info['position_id']);
  47. $info['position_name'] = $positionInfo['name'];
  48. }
  49. // 职级
  50. if ($info['level_id']) {
  51. $levelMod = new LevelModel();
  52. $levelInfo = $levelMod->getInfo($info['level_id']);
  53. $info['level_name'] = $levelInfo['name'];
  54. }
  55. // 获取用户角色列表
  56. $userRoleService = new UserRoleService();
  57. $roleList = $userRoleService->getUserRoleList($id);
  58. $info['roles'] = $roleList;
  59. }
  60. return $info;
  61. }
  62. }