all(), [ "name" => "required|between:1,64", "description" => "max:255", "icon" => "max:255", ]); if ($validator->fails()) { return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); } $params = []; $params["name"] = $request->input("name"); $params["description"] = $request->input("description"); $params["icon"] = $request->input("icon"); $group = new Models\Group(); $result = $group->CreateGroup($params); if ($result["code"] == 0) { return $this->success($result["data"]); } return $this->response($result["code"], $this->error[$result["code"]]); } public function ModifyGroup(Request $request) { $validator = Validator::make($request->all(), [ "id" => "required|integer|min:1", "name" => "between:1,64", "description" => "max:255", "icon" => "max:255", ]); if ($validator->fails()) { return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); } $params = []; $params["id"] = $request->input("id"); $params["name"] = $request->input("name"); $params["description"] = $request->input("description"); $params["icon"] = $request->input("icon"); $group = new Models\Group(); $code = $group->ModifyGroup($params); return $this->response($code, $this->error[$code]); } public function DeleteGroup(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()); } $params = []; $params["id"] = $request->input("id"); $group = new Models\Group(); $code = $group->DeleteGroup($params); return $this->response($code, $this->error[$code]); } /** * 此方法待定 * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function ListGroup(Request $request) { $validator = Validator::make($request->all(), [ "page" => "integer|min:1", "pageCount" => "integer|min:1", ]); if ($validator->fails()) { return $this->fail(REQUEST_PARAM_ERROR, $this->error[REQUEST_PARAM_ERROR], $validator->errors()); } $params = []; $params["page"] = $request->input("page"); $params["pageCount"] = $request->input("pageCount"); $params["keyword"] = $request->input("keyword"); $group = new Models\Group(); $result = $group->ListGroup($params); return $this->success($result); } }