fix #I81YQA SqlSugar使用MySql时异常

This commit is contained in:
wintel 2023-09-17 11:41:42 +08:00
parent 852d52436a
commit 367158e33f
4 changed files with 28 additions and 23 deletions

View File

@ -47,10 +47,6 @@ namespace OpenAuth.App
{
return Repository.GetFirst(u => u.AppSecret == modelAppKey);
}
public void Delete(string[] ids)
{
Repository.DeleteByIds(ids);
}
}
}

View File

@ -9,6 +9,10 @@ using SqlSugar;
namespace OpenAuth.App
{
/// <summary>
/// SqlSugar基础类
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class SqlSugarBaseApp<T> where T : class, new()
{
protected ISqlSugarClient SugarClient;
@ -23,6 +27,16 @@ namespace OpenAuth.App
SugarClient = client;
_auth = auth;
}
public void Delete(string[] ids)
{
Repository.DeleteByIds(ids);
}
public T Get(string id)
{
return SugarClient.Queryable<T>().Where("Id=@id", new {id = id}).First();
}
/// <summary>
/// 获取当前登录用户的数据访问权限

View File

@ -96,10 +96,6 @@ namespace OpenAuth.App
public ResourceApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
{
}
public void Delete(string[] ids)
{
Repository.DeleteByIds(ids);
}
}
}

View File

@ -2,18 +2,16 @@ using System;
using System.Linq;
using System.Threading.Tasks;
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using OpenAuth.App.Interface;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
using SqlSugar;
namespace OpenAuth.App
{
public class SysPrinterPlanApp : BaseStringApp<SysPrinterPlan, OpenAuthDBContext>
public class SysPrinterPlanApp : SqlSugarBaseApp<SysPrinterPlan>
{
/// <summary>
/// 加载列表
@ -42,9 +40,9 @@ namespace OpenAuth.App
var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName));
result.columnFields = columnFields;
result.data = objs.OrderBy(u => u.Id)
result.data = objs.OrderByDescending(u => u.CreateTime)
.Skip((request.page - 1) * request.limit)
.Take(request.limit).Select($"new ({propertyStr})");
.Take(request.limit).Select($"{propertyStr}").ToList();
result.count = await objs.CountAsync();
return result;
}
@ -53,23 +51,24 @@ namespace OpenAuth.App
{
//程序类型取入口应用的名称,可以根据自己需要调整
var addObj = obj.MapTo<SysPrinterPlan>();
//addObj.Time = DateTime.Now;
Repository.Add(addObj);
addObj.CreateTime = DateTime.Now;
addObj.CreateUser = _auth.GetUserName();
Repository.Insert(addObj);
}
public void Update(AddOrUpdateSysPrinterPlanReq obj)
{
UnitWork.Update<SysPrinterPlan>(u => u.Id == obj.Id, u => new SysPrinterPlan
Repository.Update(u => new SysPrinterPlan
{
Name = obj.Name,
SourceSql = obj.SourceSql,
PlanContent = obj.PlanContent
});
},u => u.Id == obj.Id);
}
public SysPrinterPlanApp(IUnitWork<OpenAuthDBContext> unitWork,
IRepository<SysPrinterPlan, OpenAuthDBContext> repository, IAuth auth) : base(unitWork, repository, auth)
public SysPrinterPlanApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
{
}
}
}