123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace App\Http\Controllers;
- use App\Models;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Validator;
- class GroupController extends Controller
- {
- public function CreateGroup(Request $request)
- {
- $validator = Validator::make($request->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);
- }
- }
|