组员用户
This commit is contained in:
@@ -5,12 +5,21 @@ namespace app\common\service;
|
||||
use app\common\logic\UserLogic;
|
||||
use app\common\model\Corp;
|
||||
use app\common\model\User;
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\utils\CrudUtil;
|
||||
use app\crm\model\Country;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class UserService
|
||||
{
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = User::class;
|
||||
|
||||
protected $logic;
|
||||
|
||||
@@ -110,4 +119,63 @@ class UserService
|
||||
{
|
||||
return $this->logic->getList();
|
||||
}
|
||||
|
||||
/** 分页列表 */
|
||||
public function serviceTeam(Request $request)
|
||||
{
|
||||
if (method_exists($this, 'complexQuery')) {
|
||||
$result = $this->complexQuery($request->get());
|
||||
} else {
|
||||
$config = $this->buildQueryConfig($request, 'team');
|
||||
$limit = (int)$request->get('size', 15);
|
||||
$page = (int)$request->get('current', 1);
|
||||
$result = $this->logicList($config, $limit, $page);
|
||||
}
|
||||
return $this->postProcess('List', $result);
|
||||
}
|
||||
|
||||
/** 分页列表 */
|
||||
public function resignMember(Request $request)
|
||||
{
|
||||
$uid = $request->user->uid;
|
||||
$userId = $request->post('user_id');
|
||||
$user = User::find($userId);
|
||||
if ($user->report_to != $uid) {
|
||||
throw new BusinessException('禁止操作非组员');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'status' => 2,
|
||||
];
|
||||
$user = $this->logic->edit($userId,$data);
|
||||
$user = $user->toArray();
|
||||
unset($user['password']);
|
||||
unset($user['open_id']);
|
||||
unset($user['tenant_key']);
|
||||
unset($user['union_id']);
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造 CrudUtil 查询配置
|
||||
*/
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'team':
|
||||
// $config['where']['status'] = 1; // 关键字
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
$config['dataLimit']['type'] = 'relation';
|
||||
$config['dataLimit']['userId'] = $request->user->uid;
|
||||
$config['dataLimit']['userField'] = 'report_to';
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user