39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using AI.Common.Dtos;
|
|
using AI.Common.Entities;
|
|
using AI.Common.Services.Interface;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AI.Common.Services
|
|
{
|
|
public class QuestionLogService : IQuestionLogService
|
|
{
|
|
private readonly ISqlSugarClient _sqlSugarClient;
|
|
|
|
public QuestionLogService(ISqlSugarClient sqlSugarClient)
|
|
{
|
|
this._sqlSugarClient = sqlSugarClient;
|
|
}
|
|
|
|
public async Task<long> RecordAsync(QuestionLog questionLog)
|
|
{
|
|
if (questionLog.Id <= 0)
|
|
{
|
|
// 新增
|
|
return await _sqlSugarClient.Insertable(questionLog).ExecuteReturnBigIdentityAsync();
|
|
}
|
|
|
|
// 更新
|
|
await _sqlSugarClient.Updateable(questionLog)
|
|
.UpdateColumns(x => new { x.QuestionContent, x.GptAnswer }).ExecuteCommandAsync();
|
|
|
|
return questionLog.Id;
|
|
}
|
|
}
|
|
}
|