作者 Your Name

gx

<?php
namespace App\Http\Controllers\Bside\User;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\User\DeptUserLogic;
use App\Models\User\DeptUser;
use App\Models\User\ViewDeptUser;
class DeptUserController extends BaseController
{
/**
* @param ViewDeptUser $viewDeptUser
* @name :(列表)lists
* @author :lyh
* @method :post
* @time :2023/5/17 17:27
*/
public function lists(ViewDeptUser $viewDeptUser){
$this->param['project_id'] = $this->user['project_id'];
$lists = $viewDeptUser->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(获取成员列表)get_user_list
* @author :lyh
* @method :post
* @time :2023/5/17 17:38
*/
public function get_user_list(DeptUserLogic $deptUserLogic){
//获取当前用户已添加的成员
$list = $deptUserLogic->get_user_list();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @name :(添加或编辑成员)save
* @author :lyh
* @method :post
* @time :2023/5/17 17:36
*/
public function add(DeptUserLogic $deptUserLogic){
$this->param['project_id'] = $this->user['project_id'];
}
}
... ...
<?php
namespace App\Http\Logic\Bside\User;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\User\DeptUser;
use App\Models\User\User;
class DeptUserLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new DeptUser();
$this->param = $this->requestAll;
}
/**
* @name :(添加用户时获取成员列表)user_list
* @author :lyh
* @method :post
* @time :2023/5/17 17:40
*/
public function get_user_list(){
$param = [
'project_id'=>$this->user['project_id'],
'dept_id'=>$this->param['dept_id'],
];
$dept_list = $this->model->list($param,'id');
if(!empty($dept_list)){
$arr = [];
foreach ($dept_list as $k => $v){
$arr[] = $v['user_id'];
}
}
$userModel = new User();
$param = [
'project_id'=>$this->user['project_id'],
'id'=>['not in',$arr],
];
$list = $userModel->list($param,'id',['id','name','email','mobile','created_at']);
return $this->success($list);
}
}
... ...
<?php
namespace App\Models\User;
use App\Models\Base;
class DeptUser extends Base
{
protected $table = 'gl_project_dept_user';
}
... ...
<?php
namespace App\Models\User;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
class ProjectDept extends Base
{
use SoftDeletes;
//设置关联表名
protected $table = 'gl_project_dept';
}
... ...
<?php
namespace App\Models\User;
use App\Models\Base;
class ViewDeptUser extends Base
{
protected $table = 'gl_view_dept_user';
}
... ...