diff --git a/app/common/controller/UserController.php b/app/common/controller/UserController.php index efab4a1..2a55181 100644 --- a/app/common/controller/UserController.php +++ b/app/common/controller/UserController.php @@ -22,4 +22,23 @@ class UserController extends BaseController } } + /** + * 编辑用户 + */ + public function edit(Request $request) + { + try { + $uid = $request->user->uid; + $data = $request->all(); + $result = (new UserService())->edit($uid,$data); + unset($result['password']); + unset($result['union_id']); + unset($result['open_id']); + unset($result['tenant_key']); + return $this->success($result, '编辑成功'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + } \ No newline at end of file diff --git a/app/common/logic/UserLogic.php b/app/common/logic/UserLogic.php index 1d6dc93..28ebf6e 100644 --- a/app/common/logic/UserLogic.php +++ b/app/common/logic/UserLogic.php @@ -24,4 +24,22 @@ class UserLogic return $user; } + + /** + * 用户信息 + */ + public function edit(int $uid, array $data) + { + $user = User::find($uid); + + if (!$user) { + throw new BusinessException('账户不存在', 404); + } + + $user->fill($data); + $user->save(); + + return $user; + } + } \ No newline at end of file diff --git a/app/common/model/User.php b/app/common/model/User.php index e9b4627..5d1b8f0 100644 --- a/app/common/model/User.php +++ b/app/common/model/User.php @@ -54,6 +54,7 @@ class User extends Model 'sn', 'name', 'avatar', + 'sex', 'password', 'phone', 'email', @@ -63,7 +64,11 @@ class User extends Model 'union_id', 'user_id', 'open_id', - 'tenant_key' + 'tenant_key', + 'country_id', + 'position', + 'socialize', + 'socialize_pic', ]; // 用户所有角色 diff --git a/app/common/service/UserService.php b/app/common/service/UserService.php index 98375bc..b927c52 100644 --- a/app/common/service/UserService.php +++ b/app/common/service/UserService.php @@ -37,4 +37,18 @@ class UserService 'permissions' => $permissionCodes ]; } + + /** + * 获取用户信息(包括菜单和权限) + */ + public function edit(int $uid, array $data) + { + unset($data['password']); + unset($data['phone']); + unset($data['email']); + unset($data['sn']); + + $user = $this->logic->edit($uid,$data); + return $user; + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index b694023..3563589 100644 --- a/config/route.php +++ b/config/route.php @@ -104,8 +104,14 @@ Route::group('/crm', function () { Route::any('/customer/statistics', [app\crm\controller\CustomerController::class, 'statistics']); Route::any('/customer/getChannel', [app\crm\controller\CustomerController::class, 'getChannel']); Route::any('/customer/getCountry', [app\crm\controller\CustomerController::class, 'getCountry']); + Route::any('/customer/followNext', [app\crm\controller\CustomerController::class, 'followNext']); Route::any('/tagGroup/list', [app\crm\controller\TagGroupController::class, 'list']); Route::any('/tagGroup/updatePivot', [app\crm\controller\TagGroupController::class, 'updatePivot']); + + Route::any('/upload/image', [app\common\controller\UploadController::class, 'uploadImage']); + + + Route::any('/user/edit', [app\common\controller\UserController::class, 'edit']); });