Demo entry 6770589

retcode_retstr

   

Submitted by anonymous on Nov 14, 2018 at 07:21
Language: C++. Code size: 12.5 kB.

#pragma once

#define SESS_IF_UNKNOWN -1
#define SESS_IF_SUCCESS  0
#define SESS_IF_ERR_DB   1
#define SESS_IF_EXIST    2
#define SESS_IF_ERR_ARG  3
#define SESS_IF_ERR_FLOW 4
#define SESS_IF_ERR_PASS 21
#define SESS_IF_CNTLIMIT 22

#define TEMP_SID_TYPE    1
#define NORM_SID_TYPE    2

#define CHAN_IF_CONTAINER_SIZE_LIMIT 50

enum  CHANIF_RES
{
  CHANIF_SUCCESS   =   0, //成功

  //1-999通用返回码
  CHANIF_UNKNOWN            = 1, //未知错误
  CHANIF_UNAUTH             = 2, //业务无请求权限,未授权
  CHANIF_APP_LIMIT          = 3, //请求频率超出业务限制
  CHANIF_SVR_LIMIT          = 4, //请求频率超出后端服务限制
  CHANIF_BAD_ARG            = 5,  //参数错误,容器元素个数太大
  CHANIF_NODE_NOT_FOUNT     = 6, //后端服务节点没找到
  CHANIF_TIMEOUT            = 7, //后端服务节超时无返回
  CHANIF_DISPATCH_FAIL      = 8, //调用DispatcherManager发送失败

  //999-12500为后端服务自定义返回码
  //10XX返回码为Auther返回码
  CHANIF_AUTH_OVER_TIMES          = 1001,  //操作过快
  CHANIF_AUTH_FROM_USER_NOEXIST   = 1002,  //操作用户不存在  
  CHANIF_AUTH_TO_USER_NOEXIST     = 1003,  //被操作用户不存在  
  CHANIF_AUTH_CHAN_NOEXIST        = 1004,  //频道不存在
  CHANIF_AUTH_SUBCHAN_NOEXIST     = 1005,  //子频道不存在
  CHANIF_AUTH_PARAM_ERROR         = 1006,  //其他参数错误
  CHANIF_AUTH_NO_PERMISSION       = 1007,  //无权限执行操作
  CHANIF_AUTH_DB_ERROR            = 1008,  //数据库操作失败
  CHANIF_AUTH_TOKEN_CHECK_FAIL    = 1009,  //Token验证失败
  CHANIF_AUTH_RISK_VERIFY         = 1010, //需要UDB统一风控验证
  CHANIF_AUTH_RISK_VERIFY_FAIL    = 1011, //UDB统一风控验证失败
  CHANIF_AUTH_VP_UPATE_ERROR      = 1012, //VP多于限定值,上马甲操作失败
  CHANIF_AUTH_REAL_NAME_REGISTER_LIMIT = 1013, // 实名制验证
  CHANIF_AUTH_ANON_LIMIT          = 1014, // 匿名用户限制

  //20XX返回码为TextChat返回码
  CHANIF_TEXTCHAT_GLOBAL_BLACK_LIST               = 2001, //全局禁止发言的黑名单,以频道为单位
  CHANIF_TEXTCHAT_TID_NOT_FOUND                   = 2002, //频道不存在
  CHANIF_TEXTCHAT_SID_NOT_FOUND                   = 2003, //子频道不存在
  CHANIF_TEXTCHAT_USER_NOT_EXIST                  = 2004, //用户发言子频道和实际所在子频道不一致
  CHANIF_TEXTCHAT_CHAN_DISABLE_TEXT               = 2005, //频道被禁止所有人打字
  CHANIF_TEXTCHAT_USR_DISABLE_TEXT                = 2006, //用户被禁言
  CHANIF_TEXTCHAT_VISITOR_DISALBE_TEXT            = 2007, //频道被禁止游客打字
  CHANIF_TEXTCHAT_ACCESS_TIME_LIMIT               = 2008, //进频道需要等待N秒发言
  CHANIF_TEXTCHAT_INTERVAL_TIME_LIMIT             = 2009, //每次发言间隔
  CHANIF_TEXTCHAT_BIND_PHONE_LIMIT                = 2010, //用户需要绑定手机才能发言
  CHANIF_TEXTCHAT_TEXT_COUNTER_LIMITED            = 2011, //超过后台设置的频道发言频率
  CHANIF_TEXTCHAT_FILTER_LIMITED                  = 2012, //被反垃圾或者其他过滤进程过滤
  CHANIF_TEXTCHAT_ANONYMOUS_UID                   = 2017, //禁止匿名用户发言
  CHANIF_TEXTCHAT_REQ_LIMITED                     = 2018, //超过服务器所能承受最大请求
  CHANIF_TEXTCHAT_TEXT_MAX_LONG_LIMITED           = 2019, //文本过长
  CHANIF_TEXTCHAT_TEXT_LENGTH_LIMITED             = 2020, //文本长度超过限制
  CHANIF_TEXTCHAT_TICKET_OR_URL_LIMITED           = 2021, //飞机票或者URL限制
  CHANIF_TEXTCHAT_ADMIN_ONE_CHAT_LIMITED          = 2022, //非管理员以下禁止发送私聊
  CHANIF_TEXTCHAT_REN_PIN_LIMITED                 = 2023, //人品值限制 
  CHANIF_TEXTCHAT_REN_PIN_PLATFORM_LIMITED        = 2024, //人品系统,被全平台禁言一段时间
  CHANIF_TEXTCHAT_POLICE_LIMITED                  = 2025, // 400网警马甲不能发公屏
  CHANIF_TEXTCHAT_VIP_EXPRESSION_TOO_MUCH_LIMITED = 2026, //VIP表情大于5个限制
  CHANIF_TEXTCHAT_TICKET_TOO_MUCH                 = 2027, //飞机票大于1
  CHANIF_TEXTCHAT_SPECIFIC_TICKET_TOO_MUCH        = 2028, //IMAGE yxbq yyvip 类型飞机票大于5
  CHANIF_TEXTCHAT_TICKET_LIMITED                  = 2029, //飞机票限制
  CHANIF_TEXTCHAT_URL_LIMITED                     = 2030, //url限制
  CHANIF_TEXTCHAT_NORNAL_TEXT_INTERVAL_LIMITED    = 2031, //游客发言间隔限制
  CHANIF_TEXTCHAT_MANAGER_TEXT_INTERVAL_LIMITED   = 2032, //管理员发言间隔限制
  CHANIF_TEXTCHAT_RENPIN_UNIFY_RES                = 2034, // 人品系统统一返回码,json格式,包含人品值具体返回码
  CHANIF_TEXTCHAT_NOT_MAINLAND_IP_LIMITED         = 2035, //非大陆ip发言限制

  //30XX返回码为Temp返回码
  // CHANIF_TEMP_SET_SPEAKABLE_FAIL                  = 3001, //设置语音白名单失败
  // CHANIF_TEMP_SYNC_SPEAKABLE_FAIL                 = 3002, //同步语音白名单失败

  //40XX返回码为AuthConfigDb返回码            
  CHANIF_AUTHCONFDB_OP_FAIL                       = 4001, //查询auth的配置库失败
  CHANIF_AUTHCONFDB_PING_TIMEOUT                  = 4002, //处理进程与auth的配置库连接断开

  //50XX返回码为UserCountConfig返回码
  CHANIF_USERCOUNTCONFIG_BAD_QUERY                = 5001, //MySql语句错误
  CHANIF_USERCOUNTCONFIG_MYSQL_NOT_ALIVE          = 5002, //Mysql连接断开
};

enum CHANIF_BACKEND_SERVICE
{
  CHANIF_SELF_SERVICE = 0,
  CHANIF_AUTH_SERVICE = 10,
  CHANIF_TEXTCHAT_SERVICE = 20,
  CHANIF_TEMP_SERVICE = 30,
  CHANIF_AUTHCONFDB_SERVICE = 40,
  CHANIF_USERCOUNTCONFIG_SERVICE = 50,
};


inline void setCommonRes(int32_t & rescode, std::string & reason, int32_t code, uint16_t serviceType = CHANIF_SELF_SERVICE)
{
  switch(serviceType)
  {
    case CHANIF_SELF_SERVICE:
    {
      rescode = code;
      switch (rescode)
      {
        case CHANIF_SUCCESS:
          reason = "success";
          break;
        case CHANIF_UNKNOWN:
          reason = "unknow error";
          break;
        case CHANIF_UNAUTH :
          reason = "unAuth";
          break;
        case CHANIF_APP_LIMIT:
          reason = "reach app op limit";
          break;
        case CHANIF_SVR_LIMIT:
          reason = "reach server op limit";
          break;
        case CHANIF_BAD_ARG:
          reason = "bad argument";
          break;
        case CHANIF_NODE_NOT_FOUNT:
          reason = "node not fount";
          break;
        case CHANIF_TIMEOUT:
          reason = "timeout";
          break;
        case CHANIF_DISPATCH_FAIL:
          reason = "dispatcher send fail";
          break;
        default:
          code = CHANIF_UNKNOWN;
          reason = "unknow error";
          break;
      }
    }
    break;

    case CHANIF_AUTH_SERVICE:
    {
      if(code != CHANIF_SUCCESS)
        rescode = code + 1000;
      switch(rescode)
      {
        case CHANIF_SUCCESS:
        reason = "success";
        break;

        case CHANIF_AUTH_OVER_TIMES:
        reason = "auth, over times"; 
        break;

        case CHANIF_AUTH_FROM_USER_NOEXIST:
        reason = "auth, from user not exist";
        break;

        case CHANIF_AUTH_TO_USER_NOEXIST:
        reason = "auth, to user not exist";
        break;

        case CHANIF_AUTH_CHAN_NOEXIST:
        reason = "auth, channel not exist";
        break;

        case CHANIF_AUTH_SUBCHAN_NOEXIST:
        reason = "auth, sub-channel not exist";
        break;

        case CHANIF_AUTH_PARAM_ERROR:
        reason = "auth, parameter error";
        break;

        case CHANIF_AUTH_NO_PERMISSION:
        reason = "auth, no permission";
        break;

        case CHANIF_AUTH_DB_ERROR:
        reason = "auth, database error";
        break;

        case CHANIF_AUTH_TOKEN_CHECK_FAIL:
        reason = "auth, token check fail";
        break;

        case CHANIF_AUTH_RISK_VERIFY:
        reason = "auth, need udb risk verify";
        break;

        case CHANIF_AUTH_RISK_VERIFY_FAIL:
        reason = "auth, udb risk verify fail";
        break;

        case CHANIF_AUTH_VP_UPATE_ERROR:
        reason = "auth, update member error, vp more than limit";
        break;

        case CHANIF_AUTH_REAL_NAME_REGISTER_LIMIT:
        reason = "auth, real name register limit";
        break;

        case CHANIF_AUTH_ANON_LIMIT:
        reason = "auth, anonymous user limit";
        break;

        default:
          reason = "unknow error";
        break;
      }
    }
    break;

    case CHANIF_TEXTCHAT_SERVICE:
    {
      if(code != CHANIF_SUCCESS)
        rescode = code + 2000;
      switch(rescode)
      {
        case CHANIF_SUCCESS:
        reason = "success";
        break;
        
        case CHANIF_TEXTCHAT_GLOBAL_BLACK_LIST:
        reason = "textchat, global black list";
        break;

        case CHANIF_TEXTCHAT_TID_NOT_FOUND:
        reason = "textchat, channel not found";
        break;

        case CHANIF_TEXTCHAT_SID_NOT_FOUND:
        reason = "textchat, sub-channel not found";
        break;

        case CHANIF_TEXTCHAT_USER_NOT_EXIST:
        reason = "textchat, user not exist";
        break;

        case CHANIF_TEXTCHAT_CHAN_DISABLE_TEXT:
        reason = "textchat, channel disable text";
        break;

        case CHANIF_TEXTCHAT_USR_DISABLE_TEXT:
        reason = "textchat, user disable text";
        break;

        case CHANIF_TEXTCHAT_VISITOR_DISALBE_TEXT:
        reason = "textchat, visitor disable text";
        break;

        case CHANIF_TEXTCHAT_ACCESS_TIME_LIMIT:
        reason = "textchat, access time limit";
        break;

        case CHANIF_TEXTCHAT_INTERVAL_TIME_LIMIT:
        reason = "textchat, interval time limit";
        break;

        case CHANIF_TEXTCHAT_BIND_PHONE_LIMIT:
        reason = "textchat, bind phone limit";
        break;

        case CHANIF_TEXTCHAT_TEXT_COUNTER_LIMITED:
        reason = "textchat, text counter limit";
        break;

        case CHANIF_TEXTCHAT_FILTER_LIMITED:
        reason = "textchat, filter limit";
        break;

        case CHANIF_TEXTCHAT_ANONYMOUS_UID:
        reason = "textchat, anonymous uid";
        break;

        case CHANIF_TEXTCHAT_REQ_LIMITED:
        reason = "textchat, req limit";
        break;

        case CHANIF_TEXTCHAT_TEXT_MAX_LONG_LIMITED:
        reason = "textchat, text max long limit";
        break;

        case CHANIF_TEXTCHAT_TEXT_LENGTH_LIMITED:
        reason = "textchat, text length limit";
        break;

        case CHANIF_TEXTCHAT_TICKET_OR_URL_LIMITED:
        reason = "textchat, tick or url limit";
        break;

        case CHANIF_TEXTCHAT_ADMIN_ONE_CHAT_LIMITED:
        reason = "textchat, administrator ";
        break;

        case CHANIF_TEXTCHAT_REN_PIN_LIMITED:
        reason = "textchat, ren pin limit";
        break;

        case CHANIF_TEXTCHAT_REN_PIN_PLATFORM_LIMITED:
        reason = "textchat, ren pin platform limit";
        break;

        case CHANIF_TEXTCHAT_POLICE_LIMITED:
        reason = "textchat, police limit";
        break;

        case CHANIF_TEXTCHAT_VIP_EXPRESSION_TOO_MUCH_LIMITED:
        reason = "textchat, vip expression too much limit";
        break;

        case CHANIF_TEXTCHAT_TICKET_TOO_MUCH:
        reason = "textchat, ticket too much";
        break;

        case CHANIF_TEXTCHAT_SPECIFIC_TICKET_TOO_MUCH:
        reason = "textchat, specific ticket too much";
        break;

        case CHANIF_TEXTCHAT_TICKET_LIMITED:
        reason = "textchat, ticket limit";
        break;

        case CHANIF_TEXTCHAT_URL_LIMITED:
        reason = "textchat, url limit";
        break;

        case CHANIF_TEXTCHAT_NORNAL_TEXT_INTERVAL_LIMITED:
        reason = "textchat, nornal text interval limit";
        break;

        case CHANIF_TEXTCHAT_MANAGER_TEXT_INTERVAL_LIMITED:
        reason = "textchat, manager text interval limit";
        break;

        case CHANIF_TEXTCHAT_RENPIN_UNIFY_RES:
        reason = "textchat, ren pin unify rescode";
        break;

        case CHANIF_TEXTCHAT_NOT_MAINLAND_IP_LIMITED:
        reason = "textchat, not mainland ip limit";
        break;

        default:
          reason = "unknow error";
        break;
      }
    }
    break;

    case CHANIF_TEMP_SERVICE:
    {
      if(code == true)
        rescode = CHANIF_SUCCESS;//语音白名单 PSyncUserSpeakableRes/PSetUserSpeakableAck.resCode赋值为true,隐式转化为1
      switch(rescode)
      {
        case CHANIF_SUCCESS:
        reason = "success";
        break;

        default:
           reason = "unknow error";
        break;
      }
    }
    break;

    case CHANIF_AUTHCONFDB_SERVICE:
    {
      if(code != CHANIF_SUCCESS)
        rescode = code + 4000;
      switch(rescode)
      {
        case CHANIF_SUCCESS:
        reason = "success";
        break;

        case CHANIF_AUTHCONFDB_OP_FAIL:
        reason = "auth_config_db, db op fail";//重复加入子频道白名单,会Duplicate entry 'sid-uid' for key 'PRIMARY'
        break;

        default:
           reason = "unknow error";
        break;
      }
    }
    break;

    case CHANIF_USERCOUNTCONFIG_SERVICE:
    {
      if(code != CHANIF_SUCCESS)
        rescode = code + 5000;
       switch(rescode)
      {
        case CHANIF_SUCCESS:
        reason = "success";
        break;

        case CHANIF_USERCOUNTCONFIG_BAD_QUERY:
        reason = "user count config, bad query";
        break;

        case CHANIF_USERCOUNTCONFIG_MYSQL_NOT_ALIVE:
        reason = "user count config, mysql not alive";
        break;

        default:
           reason = "unknow error";
        break;
      }
    }
    break;
    
  }
  
}

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).