#include "errcode.h"

static std::unordered_map<Errcode, std::string> mapErr =
{
    {Errcode::OK, "操作成功"},
    {Errcode::ERR, "系统错误"},
    {Errcode::ERR_TOKEN, "TOKEN错误"},
    {Errcode::ERR_PARAM, "参数错误"},
    {Errcode::ERR_PARAM_NUL, "缺少参数"},
    {Errcode::ERR_DATA_NUL, "数据不存"},

    {Errcode::ERR_LOGIN_USER_NOTEXIST, "用户不存在"},
    {Errcode::ERR_LOGIN_PASSWD, "密码错误"},

    {Errcode::ERR_DB_CONN, "数据库连接错误"},
    {Errcode::ERR_DB_DUPLICATE, "数据库数据重复"},
    {Errcode::ERR_DB_SQL, "数据库执行错误"},
    {Errcode::ERR_DB_VAL, "参数值错误"},
};

std::string ErrcodeStr(Errcode code)
{
    auto iter = mapErr.find(code);
    return (iter != mapErr.end() ? iter->second : "");
}