1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Http\Controllers;
- use App\Models;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Validator;
- class GroupUserController extends Controller
- {
- public function GroupAddUser(Request $request)
- {
- $validator = Validator::make($request->all(), [
- "gid" => "required|integer|min:1",
- "uid" => "required|integer|min:1",
- ]);
- if ($validator->fails()) {
- return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors());
- }
- $currentUid = 0;
- // 判断当前用户是否可以为群组添加用户
- $gid = (int)$request->input("gid");
- $uid = (int)$request->input("uid");
- $groupUser = new Models\GroupUser();
- $result = $groupUser->GroupAddUser($gid, $uid);
- if ($result["code"] == 0) {
- return $this->success($result["data"]);
- }
- return $this->fail($result["code"], $this->error[$result["code"]]);
- }
- public function GroupRemoveUser(Request $request)
- {
- $validator = Validator::make($request->all(), [
- "id" => "required|integer|min:1",
- ]);
- if ($validator->fails()) {
- return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors());
- }
- $currentUid = 0;
- // 判断当前用户是否可以为群组刪除用户
- $id = (int)$request->input("id");
- $groupUser = new Models\GroupUser();
- $code = $groupUser->GroupRemoveUser($id);
- return $this->response($code, $this->error[$code]);
- }
- }
|