UserService.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\common\service;
  3. use app\common\constant\CommonConstant;
  4. use app\common\model\ApproveMaintainUser;
  5. use app\common\model\Department;
  6. use app\common\model\User;
  7. /**
  8. * 用户服务类
  9. */
  10. class UserService
  11. {
  12. /**
  13. * 列表
  14. *
  15. * @param integer $type
  16. * @param integer $offset 起始位置
  17. * @param integer $length 查询数量
  18. **/
  19. public static function get_list($type = 0,$offset = 0, $length = 1000)
  20. {
  21. $list = User::field('userid,name')
  22. ->when($type == 0,function ($query){
  23. $query->where('status', CommonConstant::IS_WHO_1);
  24. })
  25. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  26. ->limit($offset, $length)
  27. ->select();
  28. return $list;
  29. }
  30. /**
  31. * 维修人员列表
  32. *
  33. * @param integer $type 类型:1=物业主管,2=信息负责人
  34. **/
  35. public static function get_maintain_user($type){
  36. $list = ApproveMaintainUser::field('is_deleted',true)
  37. ->where('is_deleted',CommonConstant::IS_DELETED_0)
  38. ->where('type',$type)
  39. ->select();
  40. return $list;
  41. }
  42. /**
  43. * 部门列表
  44. **/
  45. public static function get_department_column(){
  46. $list = Department::where('is_deleted',CommonConstant::IS_DELETED_0)
  47. ->column('dept_id,name');
  48. return $list;
  49. }
  50. /**
  51. * 根据用户的所属部门获取部门列表
  52. *
  53. * @param string $dept_ids 部门ids
  54. **/
  55. public static function get_user_department_list($dept_ids){
  56. $list = Department::field('dept_id,name')
  57. ->where('dept_id', 'in', $dept_ids)
  58. ->where('is_deleted',CommonConstant::IS_DELETED_0)
  59. ->select();
  60. return $list;
  61. }
  62. }