123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include "stdafx.h"
- #include "CUserInfo.h"
- #include "FileOperate.h"
- CUserInfo::CUserInfo() : id(0), port(0)
- {
- }
- CUserInfo::~CUserInfo()
- {
- }
- bool CUserInfo::Init(std::string data)
- {
- try
- {
- nlohmann::json j = nlohmann::json::parse(data.begin(), data.end());
- if (j["ret"].get<int>() == 1)
- {
- auto userinfo = j["data"]["user"];
- //
- this->id = userinfo.at("id").get<int>();
- this->username = userinfo.at("account").get<std::string>();
- this->expiretime = userinfo.at("expired_at").get<std::string>();
- this->password = userinfo.at("passwd").get<std::string>();
- this->unusedTraffic = userinfo.at("unusedTraffic").get<std::string>();
- this->uuid = userinfo.at("uuid").get<std::string>();
- this->level = userinfo.at("level").get<std::string>();
- this->port = userinfo.at("port").get<int>();
- //
- this->access_token = j["data"]["access_token"].get<std::string>();
- this->token_type = j["data"]["token_type"].get<std::string>();
- return true;
- }
- else
- {
- this->m_error_msg = j["msg"].get<std::string>();
- return false;
- }
- }
- catch (...)
- {
- this->m_error_msg = "½âÎöÊý¾Ý´íÎó";
- return false;
- }
- return false;
- }
- LPCSTR CUserInfo::GetLastErrorA()
- {
- return SStringA().Format("%s", m_error_msg.c_str()).GetBuffer(0);
- }
- LPCWSTR CUserInfo::GetLastErrorW()
- {
- return S_CA2W(m_error_msg.c_str(), CP_UTF8);
- }
|