public IActionResult Index()
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs("");

                return(Result(logId, "index"));
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
        public IActionResult GetConfig(string token)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(token);
                if (!IsToken(token))
                {
                    return(Error(logId, "token invalid!"));
                }
                var    entity    = GetInterfaceAccountByToken(token);
                string companyId = entity.CompanyID;
                var    result    = ConfigService.GetConfig(SystemID, companyId);
                var    data      = new
                {
                    title = result.Title
                };
                return(Success(logId, "ok", data));
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
Beispiel #3
0
        public IActionResult GetConfig(string uuid)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(uuid);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "uuid invalid!"));
                }
                var    entity    = GetInterfaceAccountByUuid(uuid);
                string companyId = entity.CompanyID;
                var    result    = ConfigService.GetConfig(SystemID, companyId);
                var    data      = new
                {
                    title       = result.Title,
                    keywords    = result.Keyword,
                    description = result.Description
                };
                return(Success(logId, "ok", data));
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
        public IActionResult Index(string uuid)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(uuid);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "verify uuid fail!"));
                }
                return(Success(logId, "ok", uuid));
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
Beispiel #5
0
        public IActionResult GetToken(string appId, string secret)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(appId);
                if (string.IsNullOrWhiteSpace(appId))
                {
                    return(Error(logId, "appid not empty!"));
                }
                if (string.IsNullOrWhiteSpace(secret))
                {
                    return(Error(logId, "secret not empty!"));
                }

                int    tokenTotalNumber = InterfaceAccessTokenService.GetInterfaceAccessTokenTotalNumberPro(SystemID, appId);
                string token            = new Common.Token.TokenHelper(appId, secret).GetToken(tokenTotalNumber);
                int    expiresIn        = AccessTokenExpiresIn;
                string ipAddress        = Net.Ip;
                int    createTimestamp  = TimeHelper.GetUnixTimestamp();

                bool IsIpAddress = InterfaceAccessWhiteListService.VerifyInterfaceAccessWhiteListByAppIdPro(SystemID, appId, ipAddress);
                if (!IsIpAddress)
                {
                    return(Error(logId, "ip verify fail!"));
                }

                bool createResult = InterfaceAccessTokenService.SaveInterfaceAccessTokenAutoPro(token, SystemID, appId, secret, expiresIn, ipAddress, createTimestamp);
                if (createResult)
                {
                    return(Result(logId, new { token, expiresin = expiresIn }));
                }
                else
                {
                    return(Error(logId, "fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
        public IActionResult Register(string uuid, [FromBody] JObject fromValue)
        {
            long logId = 0;

            try
            {
                int systemId = SystemID;
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "verify uuid fail!"));
                }
                bool   isParams  = IsRegisterParams(fromValue);
                var    entity    = GetInterfaceAccountByUuid(uuid);
                string companyId = entity.CompanyID;
                string memberId  = PrimaryKeyHelper.MakePrimaryKey(PrimaryKeyHelper.PrimaryKeyType.Member);
                string phone     = GetJObjectValue(fromValue, "phone");
                string password  = GetJObjectValue(fromValue, "password");
                string ipAddress = Net.Ip;
                if (!Utility.IsMobilePhone(phone))
                {
                    return(Error(logId, "verify phone fail!"));
                }

                var result = AccountService.SaveAccountRegisterPro(systemId, companyId, memberId, AlgorithmHelper.MD5(password), phone, ipAddress);
                if (result)
                {
                    return(Success(logId, "ok"));
                }
                else
                {
                    return(Error(logId, "fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
Beispiel #7
0
 public IActionResult GetMember(string access_token)
 {
     long logId = 0;
     try
     {
         int systemId = SystemID;
         logId = BaseApiManager.SaveLogs(access_token);
         if (!IsAccessToken(access_token))
             return Error(logId, "验证access_token失败!");
         var entity = AccountService.GetAccountByAccessTokenPro(systemId, access_token);
         var data = new
         {
             memberid = entity.MemberID,
             rank_id = entity.RankID,
             rank_name = entity.RankName,
             user_name = entity.UserName,
             company_name = entity.CompanyName.IIF(""),
             name = entity.Name.IIF(""),
             nickname = entity.NickName.IIF(""),
             head_image_url = entity.HeadImageUrl.IIF(""),
             sex = entity.Sex.ToInt(),
             phone = entity.Phone,
             email = entity.Email.IIF(""),
             address = entity.Address.IIF(""),
             total_points = entity.TotalPoints.ToInt(),
             total_consumption = entity.TotalConsumption.ToDecimal(),
             total_amount = entity.TotalAmount.ToDecimal(),
             remark = entity.Remark.IIF(""),
         };
         return Success(logId, "ok", data);
     }
     catch (Exception ex)
     {
         return Error(logId, ex.Message);
     }
 }
Beispiel #8
0
        public IActionResult GetMedia(string access_token, string mediaid)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(access_token);
                if (!IsAccessToken(access_token))
                {
                    return(Error(logId, "验证token失败!"));
                }
                var entityMember = AccountService.GetAccountByAccessTokenPro(SystemID, access_token);
                if (entityMember == null)
                {
                    return(Error(logId, "验证会员资料失败!"));
                }
                if (string.IsNullOrEmpty(entityMember.CompanyID))
                {
                    return(Error(logId, "公司编号不能为空!"));
                }
                string companyId = entityMember.CompanyID;
                string memberId  = entityMember.MemberID;

                var entity = VMediaService.GetVMedia(SystemID, companyId, memberId, mediaid);
                if (entity == null)
                {
                    return(Error(logId, "mediaid invalid!"));
                }
                var data = new
                {
                    mediaid = entity.MediaID,
                    name    = entity.FileName,
                    size    = entity.FileSize,
                    url     = entity.Url,
                    src     = entity.Src
                };
                return(Success(logId, "ok", data));
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
        public IActionResult Save(string uuid, [FromBody] JObject fromValue)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "verify uuid fail!"));
                }
                bool   isParams = IsSaveParams(fromValue);
                var    entityInterfaceAccount = GetInterfaceAccountByUuid(uuid);
                string companyId = entityInterfaceAccount.CompanyID;

                string clientId  = GetJObjectValue(fromValue, "client_id");
                string url       = GetJObjectValue(fromValue, "url");
                string message   = GetJObjectValue(fromValue, "message");
                string ipAddress = Net.Ip;
                var    entity    = new Log_ErrorRecord()
                {
                    SystemID  = SystemID,
                    ClientID  = clientId.ToInt().ToByte(),
                    Url       = url,
                    Message   = message,
                    IpAddress = ipAddress,
                    State     = true
                };
                var result = ErrorRecordService.SaveErrorRecord(entity);
                if (result)
                {
                    return(Success(logId, "ok"));
                }
                else
                {
                    return(Error(logId, "fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
Beispiel #10
0
        public IActionResult Save(string uuid, [FromBody] JObject fromValue)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "verify uuid fail!"));
                }
                bool   isParams = IsSaveParams(fromValue);
                var    entityInterfaceAccount = GetInterfaceAccountByUuid(uuid);
                string companyId   = entityInterfaceAccount.CompanyID;
                string ipAddress   = Net.Ip;
                string host        = GetJObjectValue(fromValue, "host");
                string absoluteUri = GetJObjectValue(fromValue, "absolute_uri");
                string queryString = GetJObjectValue(fromValue, "query_string");
                var    entity      = new Log_VisitorRecord()
                {
                    SystemID    = SystemID,
                    CompanyID   = companyId,
                    ClientID    = 1,
                    IpAddress   = ipAddress,
                    Host        = host,
                    AbsoluteUri = absoluteUri,
                    QueryString = HttpUtility.UrlDecode(queryString)
                };
                var result = VisitorRecordService.SaveVisitorRecord(entity);
                if (result)
                {
                    return(Success(logId, "ok"));
                }
                else
                {
                    return(Error(logId, "fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }
        public IActionResult Save(string uuid, [FromBody] JObject fromValue)
        {
            long logId = 0;

            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                if (!IsUuid(uuid))
                {
                    return(Error(logId, "verify uuid fail!"));
                }
                bool   isParams = IsSaveParams(fromValue);
                var    entityInterfaceAccount = GetInterfaceAccountByUuid(uuid);
                string companyId = entityInterfaceAccount.CompanyID;
                string ipAddress = Net.Ip;
                string name      = GetJObjectValue(fromValue, "name");
                string phone     = GetJObjectValue(fromValue, "phone");
                string email     = GetJObjectValue(fromValue, "email");
                string address   = GetJObjectValue(fromValue, "address");
                string content   = GetJObjectValue(fromValue, "content");

                if (string.IsNullOrWhiteSpace(name))
                {
                    return(Error("昵称不能为空!"));
                }
                if (string.IsNullOrWhiteSpace(content))
                {
                    return(Error("内容不能为空!"));
                }
                if (!Utility.IsMobilePhone(phone))
                {
                    return(Error("手机号码格式不正确!"));
                }
                if (!Utility.IsEmail(email))
                {
                    return(Error("邮箱地址格式不正确!"));
                }

                var entityConfig = ConfigService.GetConfig(SystemID, companyId);
                if (entityConfig != null)
                {
                    string Shielding = entityConfig.Shielding;
                    if (!string.IsNullOrWhiteSpace(Shielding))
                    {
                        string[] keyword = Shielding.Split("|");
                        if (!IsKeyword(keyword, content))
                        {
                            return(Error("内容有非法虑字!"));
                        }
                    }
                }
                var entity = new Service_MessageBoard()
                {
                    SystemID  = SystemID,
                    CompanyID = companyId,
                    Name      = name,
                    Phone     = phone,
                    Email     = email,
                    Address   = address,
                    Content   = content,
                    IpAddress = ipAddress
                };
                var result = MessageBoardService.SaveMessageBoard(entity);
                if (result)
                {
                    return(Success(logId, "ok"));
                }
                else
                {
                    return(Error(logId, "fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(logId, ex.Message));
            }
        }