public LabelsQueryDto TestAPI([FromBody] LabelsCmdDto cmd)
        {
            var request = JsonConvert.DeserializeObject <StoreRequest>(Base64Helper.Base64Decode(cmd.Data));

            #region 参数判断

            if (request == null)
            {
                return(new LabelsQueryDto()
                {
                    Code = ConstantsErrorCode.ERR_CODE_PARAM, Msg = "请求参数不能为空"
                });
            }
            if (string.IsNullOrEmpty(request.UserNo))
            {
                return(new LabelsQueryDto()
                {
                    Code = ConstantsErrorCode.ERR_CODE_PARAM, Msg = "客户编号不能为空"
                });
            }
            if (string.IsNullOrEmpty(request.StoreName))
            {
                return(new LabelsQueryDto()
                {
                    Code = ConstantsErrorCode.ERR_CODE_PARAM, Msg = "店铺名称不能为空"
                });
            }

            #endregion

            #region 业务代码

            //TODO:待定

            #endregion

            return(new LabelsQueryDto()
            {
                Code = ConstantsErrorCode.SUCCESS_CODE_SYS, Msg = "调用成功啦,这是请求参数:" + JsonConvert.SerializeObject(request)
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 发送请求
        /// </summary>
        /// <param name="url"></param>
        /// <param name="api"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private static string SendAPI(string url, string api, string data)
        {
            string       Appkey = GetAppSettingsValue("Labels_Appkey");
            string       Secret = GetAppSettingsValue("Labels_Secret");
            LabelsCmdDto cmd    = new LabelsCmdDto()
            {
                Appkey    = Appkey,
                Data      = Convert.ToBase64String(Encoding.UTF8.GetBytes(data)),
                Timestamp = DateTime.Now.ToString("yyyyMMddHHmmss"),
            };

            var sign = SignDigest.SignTopRequest(cmd.GetParameters(), Secret);

            cmd.Sign = sign;
            IDictionary <string, string> parameters = new Dictionary <string, string>(cmd.GetParameters());

            parameters.Add("Sign", cmd.Sign);

            WebUtils webUtils  = new WebUtils();
            var      resultStr = webUtils.DoPost(url + api, parameters);

            return(resultStr);
        }