完善提示词预设的接口,完善转发接口
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using LMS.Common.Enum;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -18,44 +19,47 @@ public class Options
|
||||
public OptionTypeEnum Type { get; set; } = OptionTypeEnum.String;
|
||||
|
||||
// 写一个字段,映射Value,判断是不是json字符串,是的话就解析成对象
|
||||
[NotMapped]
|
||||
public object? ValueObject
|
||||
// 写一个字段,映射Value,判断是不是json字符串,是的话就解析成对象
|
||||
public T? GetValueObject<T>()
|
||||
{
|
||||
get
|
||||
if (string.IsNullOrEmpty(Value))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Value))
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
|
||||
if (Type == OptionTypeEnum.JSON)
|
||||
{
|
||||
return JsonConvert.DeserializeObject(Value ?? "{}");
|
||||
}
|
||||
|
||||
if (Type == OptionTypeEnum.Number)
|
||||
{
|
||||
return Convert.ToDouble(Value);
|
||||
}
|
||||
|
||||
return Value;
|
||||
return default;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
Value = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Type == OptionTypeEnum.JSON)
|
||||
if (Type == OptionTypeEnum.JSON)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(Value ?? "{}");
|
||||
}
|
||||
|
||||
if (Type == OptionTypeEnum.Number)
|
||||
{
|
||||
if (double.TryParse(Value, out double result))
|
||||
{
|
||||
Value = JsonConvert.SerializeObject(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Value = value.ToString();
|
||||
return (T)Convert.ChangeType(result, typeof(T));
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
return (T)Convert.ChangeType(Value, typeof(T));
|
||||
}
|
||||
|
||||
// 写一个方法,设置Value的值
|
||||
public void SetValueObject<T>(T value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
Value = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Type == OptionTypeEnum.JSON)
|
||||
{
|
||||
Value = JsonConvert.SerializeObject(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Value = value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace LMS.Repository.Models.DB
|
||||
namespace LMS.Repository.DB
|
||||
{
|
||||
public class Prompt
|
||||
{
|
||||
@@ -45,7 +45,7 @@
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
/// </summary>
|
||||
public string CreateUserId { get; set; }
|
||||
public long CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
@@ -55,7 +55,7 @@
|
||||
/// <summary>
|
||||
/// 更新者
|
||||
/// </summary>
|
||||
public string UpdateUserId { get; set; }
|
||||
public long UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
|
||||
@@ -1,35 +1,12 @@
|
||||
namespace LMS.Repository.Models.DB
|
||||
using LMS.Repository.DTO.PromptTypeDto;
|
||||
|
||||
namespace LMS.Repository.Models.DB
|
||||
{
|
||||
/// <summary>
|
||||
/// 提示词类型的库
|
||||
/// </summary>
|
||||
public class PromptType
|
||||
public class PromptType : PromptTypeBasic
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提示词类型编码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提示词类型名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提示词类型描述
|
||||
/// </summary>
|
||||
public string? Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提示词类型状态
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
/// </summary>
|
||||
@@ -38,7 +15,7 @@
|
||||
/// <summary>
|
||||
/// 创建用户ID
|
||||
/// </summary>
|
||||
public string CreateUserId { get; set; }
|
||||
public long CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
@@ -48,14 +25,11 @@
|
||||
/// <summary>
|
||||
/// 更新者ID
|
||||
/// </summary>
|
||||
public string UpdateUserId { get; set; }
|
||||
public long UpdateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using LMS.Tools.Extensions;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace LMS.Repository.Models.DB
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user