// // Created by dongl on 23-5-10. // #ifndef IM2_USEROPERATION_H #define IM2_USEROPERATION_H #include #include #include "event2/bufferevent.h" #include "core/Client.h" #include "MP/Request.h" #include "core/management.h" #define LOGIN_ACCOUNT mp::MP_LOGIN_ACCOUNT #define LOGIN_PHONE mp::MP_LOGIN_PHONE #define LOGIN_EMAIL mp::MP_LOGIN_EMAIL #define REGISTER_EMAIL mp::MP_SUB_TYPE::MP_REGISTER_EMAIL #define REGISTER_PHONE mp::MP_SUB_TYPE::MP_REGISTER_PHONE class UserOperation { public: explicit UserOperation(Client* client); virtual ~UserOperation(); public: // 登陆 std::optional login(const std::string& account, const std::string& password); // 注册 std::optional register_(const std::string& account, const std::string& password, const std::string& code); // 请求验证码 std::optional get_code(const std::string& account); // 查询账户好友 std::optional fetch_friends(uint64_t account); // 查询用户 并 查看是否已为好友 std::optional fetch_user(uint64_t user, uint64_t account); // 添加用户 account 本机账户 带添加账户 std::optional add_user(uint64_t account, uint64_t user); private: // base 包 std::string packet_base(mp::MP_TYPE, mp::MP_SUB_TYPE, const std::string &account, const std::string &password); std::string packet_base(mp::MP_TYPE, mp::MP_SUB_TYPE, const std::string &account, const std::string &password, const std::string &data); std::string packet_base(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, const std::string& account); std::string packet_base(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, uint64_t source, uint64_t target); // 操作报 std::string login_packet(mp::MP_SUB_TYPE subType, const std::string &account, const std::string &password); std::string register_packet(mp::MP_SUB_TYPE subType, const std::string &account, const std::string &password, const std::string &code); private: Client* client; }; #endif //IM2_USEROPERATION_H