name = $params["name"]; $this->description = $params["description"]; $this->icon = $params["icon"]; $this->status = "normal"; if ($this->name == "") { return "empty group name"; } $this->save(); return "success"; } public function ModifyGroup(array $params) { $update = []; $gid = $params["gid"]; if ($gid == "") { return "empty group id"; } if ($params["name"] != "") { $update["name"] = $params["name"]; } if ($params["description"] != "") { $update["description"] = $params["description"]; } if ($params["icon"] != "") { $update["icon"] = $params["icon"]; } if (count($update) == 0) { return "nothing to update"; } $this->where("id", $gid) ->where("status", "normal") ->where("is_del", false) ->update($update); return "success"; } public function DeleteGroup(array $params) { $gid = $params["gid"]; if ($gid == "") { return "empty group id"; } $this->where("id", $gid) ->where("is_del", false) ->update(["is_del" => true]); return "success"; } // public function LoadGroup(array $params){ // $gid = $params["gid"]; // if ($gid == ""){ // return"empty group id"; // } // } public function ListGroup(array $params) { $uid = $params["uid"]; $groupUser = new GroupUser(); $groupIds = $groupUser->ListGroupIds($uid); if (count($groupIds) == 0) { return []; } // $result = $this->select("id", "name", "description", "icon", "status") ->where("id", $groupIds) ->where("is_del", false) ->all(); return $result; } }