mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现HTTP服务架构
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
#include "app/Policy.h"
|
||||
#include "database/Dao.h"
|
||||
#include "common/JsonN.h"
|
||||
#include "common/Snowflake.h"
|
||||
|
||||
#include "common/Utils.h"
|
||||
|
||||
void ElectPeriod::parse(std::string jsonstr)
|
||||
{
|
||||
@@ -216,7 +216,6 @@ void AppData::initFromDB()
|
||||
void AppData::init()
|
||||
{
|
||||
this->initFromDB();
|
||||
this->initUser();
|
||||
}
|
||||
|
||||
std::shared_ptr<Station> AppData::getStation(int stationId)
|
||||
@@ -276,12 +275,35 @@ void AppData::loadStatData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AppData::initUser()
|
||||
static std::map<std::string, User> g_mapUser;
|
||||
std::string AppData::userLogin(std::string userId, std::string account)
|
||||
{
|
||||
auto dao = DaoEntity::create("");
|
||||
std::vector<Fields> result;
|
||||
for (auto iter = g_mapUser.begin(); iter!=g_mapUser.end(); ++iter)
|
||||
{
|
||||
if (iter->second.userId == userId) // 重复登录
|
||||
{
|
||||
g_mapUser.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
User user;
|
||||
user.userId = userId;
|
||||
user.account = account;
|
||||
user.loginTime = Utils::time();
|
||||
user.token = Snowflake::instance().getIdStr();
|
||||
g_mapUser[user.token] = user;
|
||||
return user.token;
|
||||
}
|
||||
User AppData::getUser(std::string token)
|
||||
{
|
||||
auto iter = g_mapUser.find(token);
|
||||
if (iter != g_mapUser.end())
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
return User();
|
||||
}
|
||||
|
||||
|
||||
int AppData::getWorkModeIdByName(std::string name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user