using AI.Common.Dtos; using AI.Common.Entities; using AI.Common.Services.Interface; using Mapster; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AI.Common.Services { public class PromptService : IPromptService { private readonly ISqlSugarClient _sqlSugarClient; public PromptService(ISqlSugarClient sqlSugarClient) { this._sqlSugarClient = sqlSugarClient; } public async Task> GetListAsync() { var entities = await _sqlSugarClient.Queryable().ToListAsync(); return entities.Adapt>(); } public async Task AddAsync(Prompts prompts) { await _sqlSugarClient.Insertable(prompts).ExecuteCommandAsync(); } public async Task UpdateAsync(Prompts prompts) { await _sqlSugarClient.Updateable(prompts) .UpdateColumns(x => new { x.Name, x.Prompt }) .ExecuteCommandHasChangeAsync(); } public async Task DeleteAsync(long id) { await _sqlSugarClient.Updateable() .SetColumns(x => x.IsDelete == true) .Where(x => x.Id == id).ExecuteCommandAsync(); } } }