namespace DataSharing.Share.Dtos.HotlineWeb
{
    /// <summary>
    /// 门户数据返回
    /// </summary>
    /// <typeparam name="TData"></typeparam>
    public class WebPortalDeResponse<TData>
    {
        /// <summary>
        /// 状态
        /// </summary>
        public string code { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string msg { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public TData data { get; set; }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public static WebPortalDeResponse<TData> Success(TData data, string? description = "")
        {
            return new WebPortalDeResponse<TData>
            {
                code = "1",
                data = data,
                msg = (description ?? "接口调用成功！")
            };
        }

        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="code"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public static WebPortalDeResponse<TData> Failed(string? code = "0", string? description = "")
        {
            return new WebPortalDeResponse<TData>
            {
                code = code,
                msg = (description ?? "接口调用失败！")
            };
        }
    }
}

