Change unicode and introduce new model user

This commit is contained in:
Hepatica
2024-08-14 00:59:19 +02:00
parent 4ee7db7a30
commit 598bcba4a9
5 changed files with 60 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ add_executable(SpCloudMain
"Service/FileProcessingService.cpp"
"Service/CommandService.cpp"
"Service/Logger.cpp"
)
"Models/User.cpp")
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET SpCloudMain PROPERTY CXX_STANDARD 20)

View File

@@ -31,7 +31,8 @@ public:
public:
void process_publish(const httplib::Request& req, httplib::Response& res)
{
if (this->authorization.is_user_authorized())
//if (this->authorization.is_user_authorized())
if (true)//Todo change to is user authorized
{
const auto& content = req.files.begin()->second.content;

View File

@@ -0,0 +1,50 @@
#include <string>
class User {
private:
int id;
std::string name;
std::string authToken;
bool isBanned;
public:
// Конструктор
User(int id, const std::string& name, const std::string& authToken, bool isBanned)
: id(id), name(name), authToken(authToken), isBanned(isBanned) {}
// Геттеры и сеттеры для Id
int getId() const {
return id;
}
void setId(int id) {
this->id = id;
}
// Геттеры и сеттеры для Name
std::string getName() const {
return name;
}
void setName(const std::string& name) {
this->name = name;
}
// Геттеры и сеттеры для AuthToken
std::string getAuthToken() const {
return authToken;
}
void setAuthToken(const std::string& authToken) {
this->authToken = authToken;
}
// Геттеры и сеттеры для IsBanned
bool getIsBanned() const {
return isBanned;
}
void setIsBanned(bool isBanned) {
this->isBanned = isBanned;
}
};

View File

@@ -1,10 +1,14 @@
#include "../Models/User.cpp"
class AuthorizationService
{
public:
bool is_user_authorized()
bool is_user_authorized(User user)
{
return true;//Todo implement logic for authorization processing
}
};
};

View File

@@ -9,6 +9,7 @@
#include "Logger.cpp"
class FileProcessingService
{
Logger& logger_;
public:
FileProcessingService(Logger& logger) : logger_(logger)
@@ -42,14 +43,6 @@ public:
void unzip(const std::string& file_path, const std::string& final_files_directory) {
create_directory(final_files_directory);
//Windows version
//std::string command = R"(powershell -Command "& \"C:\Program Files\WinRAR\WinRAR.exe\" x \")" + file_path + R"(\" \")" + final_files_directory + R"(\")";
//Linux version
//std::string command = "unzip " + file_path + " -d " + final_files_directory;
std::string command = "unrar x " + file_path + " " + final_files_directory;
logger_.log(INFO, "Start unzip command" + command);
@@ -68,25 +61,7 @@ public:
return ""; //todo add throwing exception
}
//static void execute_command(const std::string& command) {//todo delete if not needed
// int result = std::system(command.c_str()); // NOLINT(concurrency-mt-unsafe)
// if (result != 0) {
// std::cerr << "Command failed with code: " << result << std::endl;
// }
//}
//void unzip(const std::string& file_path, const std::string& final_files_directory)
//{
// std::string createDirCommand = "mkdir \"" + final_files_directory + "\"";
// system(createDirCommand.c_str());//Todo solve unsafe warning
// const std::string command = "WinRAR x \"" + file_path + "\" \"" + final_files_directory + "\"";
// int result = system(command.c_str());//Todo solve unsafe warning
//}
/*private:
std::mutex file_mutex; */// Мьютекс для синхронизации доступа к файлу
Logger& logger_;
};