username = $params["username"]; $this->password = $params["password"]; $this->nickname = $params["nickname"]; $this->icon = $params["icon"]; $this->tel = $params["tel"]; $this->email = $params["email"]; if ($this->username == "" || $this->password == "") { return "empty username or password"; } if ($this->nickname == "") { $this->nickname = $this->username; $params["nickname"] = $this->username; } // todo 这里需要对密码加密 $this->save(); unset($params["password"]); return $params; } public function ChangePassword($uid, $oldPwd, $newPwd) { } public function ModifyUser(array $params) { $update = []; $uid = $params["id"]; if ($uid == "") { return "empty user id"; } if ($params["username"] != "") { $update["username"] = $params["username"]; } if ($params["nickname"] != "") { $update["nickname"] = $params["nickname"]; } if ($params["icon"] != "") { $update["icon"] = $params["icon"]; } if ($params["tel"] != "") { $update["tel"] = $params["tel"]; } if ($params["email"] != "") { $update["email"] = $params["email"]; } if (count($update) == 0) { return "nothing to update"; } $result = $this->where("id", $uid) ->where("is_del", false) ->update($update); Log::debug("result is " . $result, ["aa" => $this->getGrammar()]); return [ "code" => $result == false ? 0 : NO_DATA_IN_SYS_TO_UPDATE, "message" => $result == false ? "success" : "invalid update", ]; } public function DeleteUser($uid) { if ($uid == "") { return "empty user id"; } $result = $this->where("id", $uid) ->where("is_del", false) ->update(["is_del" => true]); return $result > 0 ? "success" : "fail"; } public function ListUser($page, $pageCount) { $data = $this->where("is_del", false) ->paginate($pageCount, ["*"], "page", $page) ->get(); return $data; } }