StaffDepartment.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use app\admin\model\AuthGroup;
  4. use think\Model;
  5. use traits\model\SoftDelete;
  6. /**
  7. *员工部门表
  8. */
  9. class StaffDepartment Extends Model {
  10. use SoftDelete;
  11. // 表名,不含前缀
  12. protected $name = 'qingdongams_staff_department';
  13. // 开启自动写入时间戳字段
  14. protected $autoWriteTimestamp = 'int';
  15. // 定义时间戳字段名
  16. protected $createTime = 'createtime';
  17. protected $updateTime = 'updatetime';
  18. protected $deleteTime = 'deletetime';
  19. //员工业绩
  20. public function achievement() {
  21. return $this->belongsTo(Achievement::class, 'id', 'obj_id')->where(['type' => 2]);
  22. }
  23. //获取部门列表
  24. public static function getDepartmentList() {
  25. }
  26. //获取部门及所有下级部门
  27. public static function getDepartmentLowerId($l_ids,$top=true){
  28. $ids=self::where(['pid' =>['in',$l_ids]])->column('id');
  29. if ($ids) {
  30. $w_ids = self::getDepartmentLowerId($ids,false);
  31. $ids = array_merge($ids, $w_ids);
  32. }else{
  33. $ids=[];
  34. }
  35. if($top){
  36. $ids=array_merge($ids,$l_ids);
  37. }
  38. return $ids;
  39. }
  40. //获取部门列表
  41. public static function getList()
  42. {
  43. return self::where([])->field('id,name')->select();
  44. }
  45. }