mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 13:06:48 +08:00
fix #I81YQA SqlSugar使用MySql时异常
This commit is contained in:
parent
852d52436a
commit
367158e33f
@ -48,9 +48,5 @@ namespace OpenAuth.App
|
||||
return Repository.GetFirst(u => u.AppSecret == modelAppKey);
|
||||
}
|
||||
|
||||
public void Delete(string[] ids)
|
||||
{
|
||||
Repository.DeleteByIds(ids);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
@ -24,6 +28,16 @@ namespace OpenAuth.App
|
||||
_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>
|
||||
/// 获取当前登录用户的数据访问权限
|
||||
/// </summary>
|
||||
|
@ -97,9 +97,5 @@ namespace OpenAuth.App
|
||||
{
|
||||
}
|
||||
|
||||
public void Delete(string[] ids)
|
||||
{
|
||||
Repository.DeleteByIds(ids);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user