namespace BBM.ChatGLM.PromptWord
{
    public class PromptWordsManager : ChatGLMDomainService
    {
        private readonly IPromptWordsRepository _promptWordsRepository;
        public PromptWordsManager(IPromptWordsRepository promptWordsRepository)
        {
            _promptWordsRepository = promptWordsRepository;
        }

        public async Task<PromptWords> CreateAsync(PromptWords promptWords)
        {
            return await _promptWordsRepository.InsertAsync(promptWords);
        }

        public async Task<PromptWords> UpdateAsync(PromptWords promptWords)
        {
            var entity = await _promptWordsRepository.GetAsync(promptWords.Id);
            entity.Type = promptWords.Type;
            entity.Content = promptWords.Content;
            return await _promptWordsRepository.UpdateAsync(entity);
        }

        public async Task<List<PromptWords>> PageAsync(string filter, string type, int pageSize, int pageIndex)
        {
            return await _promptWordsRepository.PageAsync(filter, type, pageSize, pageIndex, CurrentTenant.Id);
        }

        public async Task<long> CountAsync(string filter, string type)
        {
            return await _promptWordsRepository.CountAsync(filter, type, CurrentTenant.Id);
        }

        public async Task<int> DeleteAsync(Guid id)
        {
            return await _promptWordsRepository.DeleteAsync(id);
        }
    }
}
