/** * 过期数据删除引擎 **/ #ifndef DELETEEXPIREDFOLDERENGINE_H #define DELETEEXPIREDFOLDERENGINE_H #include "AppCommon.h" #include "EngineBase.h" #include "EngineFactory.h" class DeleteExpiredFolderEngine : public ai_matrix::EngineBase { public: DeleteExpiredFolderEngine(); ~DeleteExpiredFolderEngine(); APP_ERROR Init() override; APP_ERROR DeInit() override; APP_ERROR Process() override; private: // 获取某月有多少天 int daysInMonth(int year, int month); // 解析字符串为日期结构体 Date strToDate(const std::string &date_str); // 减去指定天数 void subtractDays(Date &date, int n_days); // 格式化日期结构体为字符串 std::string dateToStr(const Date &date); // 接收一个日期字符串和一个整数n,返回n天前的日期字符串 std::string getDateBeforeNDays(const std::string &input_date, int n_days); void getSubfolderNames(std::string &directory, std::vector &folder_names); void deleteFolder(const std::string directory); // 删除向量中小于指定日期的所有元素 void deleteEarlierDatesFolder(std::string &path, std::vector &subfolders, const Date &reference_date); void deletePreviousFolder(std::string path, const std::string &date, int n_days); private: ai_matrix::BaseConfig baseConfig_; }; ENGINE_REGIST(DeleteExpiredFolderEngine) #endif