using Microsoft.Azure.Cosmos.Table;
using System;
using System.Collections.Generic;
using System.Text;
using TEAMModelOS.SDK.Context.Attributes.Azure;

namespace TEAMModelOS.SDK.Models
{
    /*
     {
        "id":"uuid",
        "code":"base",
        "pk":"Api",
        "name": "学校基本信息",
        "url": "school/get",
        "method": "GET/POST",
        "descr": "描述"
    }
     */
    /// <summary>
    /// 限流方案  漏斗、令牌桶、sentinel
    /// 平台开放的OpenAIPs
    /// </summary>
    [TableName(Name = "OpenApi")]
    public class OpenApi : TableEntity
    {
        public OpenApi() {

            PartitionKey = "IES5-API";
        } 
        /// <summary>
        /// 接口名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 接口url
        /// </summary>
        public string url { get; set; }
        /// <summary>
        /// 请求方法
        /// </summary>
        public string method { get; set; }
        /// <summary>
        /// 开放的api接口
        /// </summary>
        public string descr { get; set; }
        public int auth { get; set; }
        /// <summary>
        /// r,w,d,l
        /// </summary>
        public string type { get; set; }
    }
    [TableName(Name = "OpenApi")]
    public class Webhook : TableEntity
    {
        public Webhook()
        {

            PartitionKey = "IES5-WEBHOOK";
        }
        /// <summary>
        /// 接口名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 接口url
        /// </summary>
        public string url { get; set; }
        /// <summary>
        /// 请求方法
        /// </summary>
        public string method { get; set; }
        /// <summary>
        /// 开放的api接口
        /// </summary>
        public string descr { get; set; }
        public int auth { get; set; }
        /// <summary>
        /// r,w,d,l
        /// </summary>
        public string type { get; set; }
    }
    public class OpenApp : CosmosEntity {
        /// <summary>
        /// 图标
        /// </summary>
        public string icon { get; set; }
        /// <summary>
        /// 应用名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 应用描述
        /// </summary>
        public string descr { get; set; }
        /// <summary>
        /// 授权信息
        /// </summary>
        public List<int> auths { get; set; } = new List<int>();
        public List<int> webhooks { get; set; } = new List<int>();
        /// <summary>
        /// 学校编码
        /// </summary>
        public string school { get; set; }
        /// <summary>
        /// 生成的token
        /// </summary>
        public string token { get; set; }
        /// <summary>
        /// domain的域名
        /// </summary>
        public string domain { get; set; }
        /// <summary>
        ///webhook
        /// </summary>
        public string webhookToken { get; set; }
        /// <summary>
        /// 0禁用，1正常，2 token封禁
        /// </summary>
        public int status { get; set; }
        public OpenApp()
        {
            pk = "OpenApp";
        }
    }
}
