作者 Your Name

gx

  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\User\DeptUserLogic;
  8 +use App\Models\User\DeptUser;
  9 +use App\Models\User\ViewDeptUser;
  10 +
  11 +class DeptUserController extends BaseController
  12 +{
  13 + /**
  14 + * @param ViewDeptUser $viewDeptUser
  15 + * @name :(列表)lists
  16 + * @author :lyh
  17 + * @method :post
  18 + * @time :2023/5/17 17:27
  19 + */
  20 + public function lists(ViewDeptUser $viewDeptUser){
  21 + $this->param['project_id'] = $this->user['project_id'];
  22 + $lists = $viewDeptUser->lists($this->map,$this->page,$this->row,$this->order);
  23 + $this->response('success',Code::SUCCESS,$lists);
  24 + }
  25 +
  26 + /**
  27 + * @name :(获取成员列表)get_user_list
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2023/5/17 17:38
  31 + */
  32 + public function get_user_list(DeptUserLogic $deptUserLogic){
  33 + //获取当前用户已添加的成员
  34 + $list = $deptUserLogic->get_user_list();
  35 + $this->response('success',Code::SUCCESS,$list);
  36 + }
  37 + /**
  38 + * @name :(添加或编辑成员)save
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2023/5/17 17:36
  42 + */
  43 + public function add(DeptUserLogic $deptUserLogic){
  44 + $this->param['project_id'] = $this->user['project_id'];
  45 + }
  46 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside\User;
  4 +
  5 +use App\Http\Logic\Bside\BaseLogic;
  6 +use App\Models\User\DeptUser;
  7 +use App\Models\User\User;
  8 +
  9 +class DeptUserLogic extends BaseLogic
  10 +{
  11 + public function __construct()
  12 + {
  13 + parent::__construct();
  14 +
  15 + $this->model = new DeptUser();
  16 + $this->param = $this->requestAll;
  17 + }
  18 +
  19 + /**
  20 + * @name :(添加用户时获取成员列表)user_list
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/5/17 17:40
  24 + */
  25 + public function get_user_list(){
  26 + $param = [
  27 + 'project_id'=>$this->user['project_id'],
  28 + 'dept_id'=>$this->param['dept_id'],
  29 + ];
  30 + $dept_list = $this->model->list($param,'id');
  31 + if(!empty($dept_list)){
  32 + $arr = [];
  33 + foreach ($dept_list as $k => $v){
  34 + $arr[] = $v['user_id'];
  35 + }
  36 + }
  37 + $userModel = new User();
  38 + $param = [
  39 + 'project_id'=>$this->user['project_id'],
  40 + 'id'=>['not in',$arr],
  41 + ];
  42 + $list = $userModel->list($param,'id',['id','name','email','mobile','created_at']);
  43 + return $this->success($list);
  44 + }
  45 +}
  1 +<?php
  2 +
  3 +namespace App\Models\User;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class DeptUser extends Base
  8 +{
  9 + protected $table = 'gl_project_dept_user';
  10 +}
  1 +<?php
  2 +
  3 +namespace App\Models\User;
  4 +
  5 +use App\Models\Base;
  6 +use Illuminate\Database\Eloquent\SoftDeletes;
  7 +
  8 +class ProjectDept extends Base
  9 +{
  10 + use SoftDeletes;
  11 +
  12 + //设置关联表名
  13 + protected $table = 'gl_project_dept';
  14 +
  15 +}
  1 +<?php
  2 +
  3 +namespace App\Models\User;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class ViewDeptUser extends Base
  8 +{
  9 + protected $table = 'gl_view_dept_user';
  10 +}