using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using System.DrawingCore.Imaging;
using System.IO;
using Library;
using System.Collections;
using LitJson;
using System.Globalization;
using System.Web;
using System.Security.Cryptography;
using System.Text;
using Aliyun.OSS;

namespace MySystem.Areas.Api.Controllers
{
    [Area("Api")]
    [Route("Api/[controller]/[action]")]
    public class PubController : BaseController
    {
        public PubController(IHttpContextAccessor accessor) : base(accessor)
        {
        }
        
        #region OCR识别-营业执照
        public JsonResult BusinessLicenseOcr(string value)
        {
            value = DesDecrypt(value);
            JsonData data = JsonMapper.ToObject(value);
            string Url = data["Url"].ToString();
            if(string.IsNullOrEmpty(Url))
            {
                return Json(new AppResultJson() { Status = "-1", Info = "营业执照识别异常，请手动填写" });
            }
            string content = AliyunOcr.Check(Url);
            if(string.IsNullOrEmpty(content))
            {
                return Json(new AppResultJson() { Status = "-1", Info = "营业执照识别异常，请手动填写" });
            }
            Dictionary<string, object> Obj = new Dictionary<string, object>();
            Obj.Add("OcrData", content);
            return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
        }
        #endregion
    }
}