using BPA.Helper;
using BPA.Model;
using BPA.Model.Table;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.Interface
{
    public interface ISqlHelper
    {
        public DbType TempDbType { get; set; }

        public string ConnectionStr { get; set; }

        public SqlSugarScope Db { get; set; }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="dt">数据库类型</param>
        /// <param name="connectStr">数据库连接字符串</param>
        /// <returns></returns>
        OperateResult Init(DbType dt = DbType.Sqlite, string connectStr = "");

        /// <summary>
        /// 添加数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        Task<OperateResult> AddAsync<T>(T data) where T : class, new();

        /// <summary>
        /// 批量添加数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        Task<OperateResult> AddAsync<T>(List<T> data) where T : class, new();

        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task<OperateResult> UpdateAsync<T>(T data) where T : SqlBase, new();

        /// <summary>
        /// 移除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<OperateResult> DeleteAsync<T>(string id) where T : SqlBase, new();

        /// <summary>
        /// 批量移除配方原料
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<OperateResult> DeleteRawMaterAsync(string id);

        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns></returns>
        Task<OperateResult<List<T>>> GetListAsync<T>();

        /// <summary>
        /// 通过配方ID获取物料ID集合
        /// </summary>
        /// <param name="RecipeId"></param>
        /// <returns></returns>
        Task<OperateResult<List<RecipeRawMaterTB>>> GetRawMaterIds(string RecipeId);
    }
}
