master
xiaochanghai 1 year ago
parent da0baf14a7
commit 6759f9b2ed
  1. 956
      Model/Tiobon.Web.pdm
  2. 41
      Tiobon.Core.Api/Controllers/Base/BaseController.cs
  3. 106
      Tiobon.Core.Api/Controllers/Ghre/Ghre_QuestionController.cs
  4. 9
      Tiobon.Core.Api/Tiobon.Core.Model.xml
  5. 29
      Tiobon.Core.Api/Tiobon.Core.xml
  6. 4
      Tiobon.Core.Common/DB/Aop/SqlsugarAop.cs
  7. 4
      Tiobon.Core.Model/Base/Ghre/Ghre_CourseScene.Dto.Base.cs
  8. 1
      Tiobon.Core.Model/Base/Ghre/Ghre_QuestionAnswer.Dto.Base.cs
  9. 8
      Tiobon.Core.Model/Edit/Ghre/Ghre_Question.Dto.EditInput.cs
  10. 19
      Tiobon.Core.Model/Insert/Ghre/Ghre_Question.Dto.InsertInput.cs
  11. 4
      Tiobon.Core.Model/Models/Ghre/Ghre_CourseScene.cs
  12. 4
      Tiobon.Core.Model/Models/Ghre/Ghre_Question.cs

File diff suppressed because it is too large Load Diff

@ -1,4 +1,5 @@
using System.Reflection;
using System.Runtime.InteropServices.Marshalling;
namespace Tiobon.Core.Controllers;
@ -39,19 +40,49 @@ public class BaseController<IServiceBase, TEntity, TEntityDto, TInsertDto, TEdit
return data;
}
public static T ConvertTo<T>(object input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
// 当T是Nullable类型时,需要获取其基础类型
Type targetType = typeof(T);
Type nullableType = Nullable.GetUnderlyingType(targetType);
targetType = nullableType ?? targetType;
// 检查input是否已经是T类型
if (input is T)
{
return (T)input;
}
// 尝试转换
try
{
return (T)Convert.ChangeType(input, targetType);
}
catch (InvalidCastException)
{
throw new InvalidOperationException($"Cannot convert an instance of type {input.GetType().Name} to type {typeof(T).Name}.");
}
}
/// <summary>
/// 根据Id查询数据
/// </summary>
/// <param name="Id">主键ID</param>
/// <returns></returns>
[HttpGet("{Id}")]
public virtual async Task<ServiceResult<object>> QueryById(long Id)
public virtual async Task<ServiceResult<TEntityDto>> QueryById(long Id)
{
var entity = await InvokeServiceAsync("QueryById", [Id]);
if (entity == null)
return Failed<object>("获取失败");
var entity1 = await InvokeServiceAsync("QueryById", [Id]);
var entity = ConvertTo<TEntityDto>(entity1);
if (entity is null)
return Failed<TEntityDto>("获取失败");
else
return Success(entity, "获取成功");
return Success<TEntityDto>(entity, "获取成功");
}
#endregion

@ -1,4 +1,7 @@
namespace Tiobon.Core.Api.Controllers;
using Consul.Filtering;
using SkyWalking.NetworkProtocol.V3;
namespace Tiobon.Core.Api.Controllers;
/// <summary>
/// 题目(Controller)
@ -8,7 +11,106 @@
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghre)]
public class Ghre_QuestionController : BaseController<IGhre_QuestionServices, Ghre_Question, Ghre_QuestionDto, InsertGhre_QuestionInput, EditGhre_QuestionInput>
{
public Ghre_QuestionController(IGhre_QuestionServices service) : base(service)
IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices;
public Ghre_QuestionController(IGhre_QuestionServices service, IGhre_QuestionAnswerServices ghre_QuestionAnswerServices) : base(service)
{
_ghre_QuestionAnswerServices = ghre_QuestionAnswerServices;
}
#region 基础接口
#region 查询
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="filter">条件</param>
/// <returns></returns>
[HttpGet]
public override async Task<ServicePageResult<Ghre_QuestionDto>> QueryByFilter([FromFilter] QueryFilter filter)
{
var data = await _service.QueryFilterPage(filter);
return data;
}
/// <summary>
/// 根据Id查询数据
/// </summary>
/// <param name="Id">主键ID</param>
/// <returns></returns>
[HttpGet("{Id}")]
public override async Task<ServiceResult<Ghre_QuestionDto>> QueryById(long Id)
{
var entity = await _service.QueryById(Id);
if (entity == null)
return Failed<Ghre_QuestionDto>("获取失败");
else
return Success(entity, "获取成功");
}
#endregion
#region 新增
/// <summary>
/// 新增数据
/// </summary>
/// <param name="insertModel"></param>
/// <returns></returns>
[HttpPost]
public override async Task<ServiceResult<string>> Insert([FromBody] InsertGhre_QuestionInput insertModel)
{
insertModel.CourseIds = string.Join(";", insertModel.CourseId.Select(x => x));
var id = await _service.Add(insertModel);
var answers = insertModel.Answers;
if (answers.Any())
{
int i = 100;
answers.ForEach(x =>
{
x.TaxisNo = i;
x.QuestionId = id;
});
i = i + 100;
await _ghre_QuestionAnswerServices.Add(answers);
}
var data = Success<string>(null, "新增成功");
data.Success = id > 0;
if (data.Success)
data.Data = id.ObjToString();
else
return Failed<string>("新增失败");
return data;
}
#endregion
#region 更新
/// <summary>
/// 更新数据
/// </summary>
/// <param name="Id">主键ID</param>
/// <param name="editModel"></param>
/// <returns></returns>
[HttpPut("{Id}")]
public override async Task<ServiceResult> Put(long Id, [FromBody] EditGhre_QuestionInput editModel)
{
var answers1 = await _ghre_QuestionAnswerServices.Query(d => d.QuestionId == Id);
var answerIds = answers1.Select(x => x.Id).ToList();
await _ghre_QuestionAnswerServices.DeleteByIds1(answerIds.ToArray());
var answers = editModel.Answers;
if (answers.Any())
{
int i = 100;
answers.ForEach(x =>
{
x.TaxisNo = i;
x.QuestionId = Id;
});
i = i + 100;
await _ghre_QuestionAnswerServices.Add(answers);
}
return await base.Put(Id, editModel);
}
#endregion
#endregion
}

@ -678,10 +678,12 @@
题目答案 (Dto.Base)
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Ghre_QuestionAnswerBase.AnswerContent">
<member name="P:Tiobon.Core.Model.Models.Ghre_QuestionAnswerBase.QuestionId">
<summary>
题目ID
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Ghre_QuestionAnswerBase.AnswerContent">
<summary>
答案内容
</summary>
@ -1015,6 +1017,11 @@
题目 (Dto.InsertInput)
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.InsertGhre_QuestionInput.Answers">
<summary>
答案
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.InsertGhre_QuestionAnswerInput">
<summary>
题目答案 (Dto.InsertInput)

@ -520,6 +520,35 @@
题目(Controller)
</summary>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.QueryByFilter(Tiobon.Core.Common.QueryFilter)">
<summary>
根据条件查询数据
</summary>
<param name="filter">条件</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.QueryById(System.Int64)">
<summary>
根据Id查询数据
</summary>
<param name="Id">主键ID</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.Insert(Tiobon.Core.Model.Models.InsertGhre_QuestionInput)">
<summary>
新增数据
</summary>
<param name="insertModel"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_QuestionController.Put(System.Int64,Tiobon.Core.Model.Models.EditGhre_QuestionInput)">
<summary>
更新数据
</summary>
<param name="Id">主键ID</param>
<param name="editModel"></param>
<returns></returns>
</member>
<member name="T:Tiobon.Core.Api.Controllers.Ghrs_UserController">
<summary>
系统用户(Controller)

@ -94,7 +94,7 @@ public static class SqlSugarAop
var dyCreateTime = getType.GetProperty("CreateTime");
if (App.User?.ID > 0 && dyCreateBy != null && dyCreateBy.GetValue(entityInfo.EntityValue) == null)
dyCreateBy.SetValue(entityInfo.EntityValue, (int)App.User.ID);
dyCreateBy.SetValue(entityInfo.EntityValue, App.User.ID);
if ((dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) is null) || (dyCreateTime != null && dyCreateTime.GetValue(entityInfo.EntityValue) != null && (DateTime)dyCreateTime.GetValue(entityInfo.EntityValue) == DateTime.MinValue))
dyCreateTime.SetValue(entityInfo.EntityValue, DateTime.Now);
@ -105,7 +105,7 @@ public static class SqlSugarAop
var dyModifyTime = getType.GetProperty("UpdateTime");
if (App.User?.ID > 0 && UpdateBy != null)
UpdateBy.SetValue(entityInfo.EntityValue, (int)App.User.ID);
UpdateBy.SetValue(entityInfo.EntityValue, App.User.ID);
if (dyModifyTime != null)
dyModifyTime.SetValue(entityInfo.EntityValue, DateTime.Now);

@ -29,13 +29,13 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 场景编号
/// </summary>
[Display(Name = "SceneNo"), Description("场景编号"), MaxLength(32, ErrorMessage = "场景编号 不能超过 32 个字符"), EntityColumn(IsOnly = true)]
[Display(Name = "SceneNo"), Description("场景编号"), MaxLength(32, ErrorMessage = "场景编号 不能超过 32 个字符")]
public string SceneNo { get; set; }
/// <summary>
/// 场景名称
/// </summary>
[Display(Name = "SceneName"), Description("场景名称"), MaxLength(32, ErrorMessage = "场景名称 不能超过 32 个字符"), EntityColumn(IsOnly = true)]
[Display(Name = "SceneName"), Description("场景名称"), MaxLength(32, ErrorMessage = "场景名称 不能超过 32 个字符")]
public string SceneName { get; set; }
/// <summary>

@ -29,6 +29,7 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 题目ID
/// </summary>
public long? QuestionId { get; set; }
/// <summary>
/// 答案内容

@ -23,5 +23,13 @@ namespace Tiobon.Core.Model.Models
/// </summary>
public class EditGhre_QuestionInput : Ghre_QuestionBase
{
/// <summary>
/// 答案
/// </summary>
public List<InsertGhre_QuestionAnswerInput> Answers { get; set; }
public List<long> CourseId { get; set; }
}
}

@ -13,15 +13,22 @@
*  
* SimonHsiao
*
*/
*/
namespace Tiobon.Core.Model.Models
namespace Tiobon.Core.Model.Models;
/// <summary>
/// 题目 (Dto.InsertInput)
/// </summary>
public class InsertGhre_QuestionInput : Ghre_QuestionBase
{
/// <summary>
/// 题目 (Dto.InsertInput)
/// 答案
/// </summary>
public class InsertGhre_QuestionInput : Ghre_QuestionBase
{
}
public List<InsertGhre_QuestionAnswerInput> Answers { get; set; }
public List<long> CourseId { get; set; }
}

@ -31,13 +31,13 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 场景编号
/// </summary>
[Display(Name = "SceneNo"), Description("场景编号"), MaxLength(32, ErrorMessage = "场景编号 不能超过 32 个字符")]
[Display(Name = "SceneNo"), Description("场景编号"), MaxLength(32, ErrorMessage = "场景编号 不能超过 32 个字符"), EntityColumn(IsOnly = true)]
public string SceneNo { get; set; }
/// <summary>
/// 场景名称
/// </summary>
[Display(Name = "SceneName"), Description("场景名称"), MaxLength(32, ErrorMessage = "场景名称 不能超过 32 个字符")]
[Display(Name = "SceneName"), Description("场景名称"), MaxLength(32, ErrorMessage = "场景名称 不能超过 32 个字符"), EntityColumn(IsOnly = true)]
public string SceneName { get; set; }
/// <summary>

@ -13,7 +13,7 @@
*  
* SimonHsiao
*
*/
*/
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using SqlSugar;
@ -37,7 +37,7 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 题目编号
/// </summary>
[Display(Name = "CourseINo"), Description("题目编号"), MaxLength(32, ErrorMessage = "题目编号 不能超过 32 个字符")]
[Display(Name = "CourseINo"), Description("题目编号"), MaxLength(32, ErrorMessage = "题目编号 不能超过 32 个字符"), EntityColumn(IsOnly = true)]
public string CourseINo { get; set; }
/// <summary>

Loading…
Cancel
Save