6 changed files with 89 additions and 95 deletions
-
14appsrc/baseservice/db/user_behavior_record_dao.cpp
-
22appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
-
1appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp
-
28appsrc/service/audit_mgr_service.cpp
-
50appsrc/service/disinfection_logs_service.cpp
-
69appsrc/utils/app_timeid_generator.hpp
@ -0,0 +1,69 @@ |
|||||
|
#pragma once
|
||||
|
#include <fstream>
|
||||
|
#include <iostream>
|
||||
|
#include <list>
|
||||
|
#include <map>
|
||||
|
#include <memory>
|
||||
|
#include <set>
|
||||
|
#include <sstream>
|
||||
|
#include <string>
|
||||
|
#include <vector>
|
||||
|
|
||||
|
#include "iflytop/core/core.hpp"
|
||||
|
|
||||
|
namespace iflytop { |
||||
|
using namespace std; |
||||
|
|
||||
|
class AppTimeIdGenerator { |
||||
|
private: |
||||
|
/* data */ |
||||
|
public: |
||||
|
|
||||
|
static string generatoreUserBehaviorTimestamp() { |
||||
|
struct tm tm = {0}; |
||||
|
time_t t = ::time(nullptr); |
||||
|
localtime_r(&t, &tm); |
||||
|
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
|
||||
|
tm.tm_mon + 1, //
|
||||
|
tm.tm_mday, //
|
||||
|
tm.tm_hour, //
|
||||
|
tm.tm_min, tm.tm_sec); |
||||
|
} |
||||
|
|
||||
|
static string generatorAuditFileName() { |
||||
|
struct tm tm = {0}; |
||||
|
time_t t = ::time(nullptr); |
||||
|
localtime_r(&t, &tm); |
||||
|
return fmt::format("AUDIT{:0>4}{:0>2}{:0>2}{:0>2}{:0>2}{:0>2}.csv", tm.tm_year + 1900, //
|
||||
|
tm.tm_mon + 1, //
|
||||
|
tm.tm_mday, //
|
||||
|
tm.tm_hour, //
|
||||
|
tm.tm_min, tm.tm_sec); |
||||
|
} |
||||
|
|
||||
|
static string createDisinfectionID() { |
||||
|
struct tm tm = {0}; |
||||
|
time_t t = ::time(nullptr); |
||||
|
assert(t != -1 && "time(nullptr) failed"); |
||||
|
struct tm* tmp = localtime_r(&t, &tm); |
||||
|
assert(tmp != nullptr && "localtime_r failed"); |
||||
|
return fmt::format("{:0>4}-{:0>2}-{:0>2}-{:0>2}{:0>2}", tm.tm_year + 1900, //
|
||||
|
tm.tm_mon + 1, //
|
||||
|
tm.tm_mday, //
|
||||
|
tm.tm_hour, //
|
||||
|
tm.tm_min); |
||||
|
} |
||||
|
|
||||
|
static string format_zsystem_tp(zsystem_tp tp) { |
||||
|
time_t time = system_clock().to_time_t(tp); |
||||
|
struct tm tm = {0}; |
||||
|
localtime_r(&time, &tm); |
||||
|
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}", tm.tm_year + 1900, //
|
||||
|
tm.tm_mon + 1, //
|
||||
|
tm.tm_mday, //
|
||||
|
tm.tm_hour, //
|
||||
|
tm.tm_min); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue