using Hotline.Repository.SqlSugar.DataPermissions;
using Hotline.Settings;
using Hotline.Settings.TimeLimits;
using Hotline.Share.Dtos.Settings;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Dependency;

namespace Hotline.Repository.SqlSugar.TextSearch
{
	public class BusinessTagRepository : BaseRepository<BusinessTag>, IBusinessTagRepository, IScopeDependency
	{

		public BusinessTagRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
		{
		}

		/// <summary>
		/// 绑定分类
		/// </summary>
		/// <param name="model"></param>
		/// <returns></returns>
		public async Task<int> BindingAsync(BusinessTagBindingDto model, CancellationToken cancellationToken) {

			var result =  await Db.Updateable<BusinessTag>()
				.SetColumns(x => x.Classify == model.Classify)
				.Where(x => model.ids.Any(s=>s ==x.Id))
				.ExecuteCommandAsync();
			return result;
		}
	}
}
